|
|
|
@@ -232,6 +232,38 @@ class AdminModulesControllerCore extends AdminController
|
|
|
|
|
$this->smartyOutputContent('controllers/modules/list.tpl');
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ajaxProcessGetTabModulesList()
|
|
|
|
|
{
|
|
|
|
|
$tab_modules_list = Tools::getValue('tab_modules_list');
|
|
|
|
|
$back = Tools::getValue('back_tab_modules_list');
|
|
|
|
|
if ($back)
|
|
|
|
|
$back .= '&tab_modules_open=1';
|
|
|
|
|
$modules_list = array('installed' =>array(), 'not_installed' => array());
|
|
|
|
|
if ($tab_modules_list)
|
|
|
|
|
{
|
|
|
|
|
$tab_modules_list = explode(',', $tab_modules_list);
|
|
|
|
|
$all_modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
|
|
|
|
|
foreach($all_modules as $module)
|
|
|
|
|
{
|
|
|
|
|
if (in_array($module->name, $tab_modules_list))
|
|
|
|
|
{
|
|
|
|
|
$this->fillModuleData($module, 'select', $back);
|
|
|
|
|
if ($module->id)
|
|
|
|
|
$modules_list['installed'][] = $module;
|
|
|
|
|
else
|
|
|
|
|
$modules_list['not_installed'][] = $module;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->context->smarty->assign(array(
|
|
|
|
|
'tab_modules_list' => $modules_list,
|
|
|
|
|
'admin_module_favorites_view' => $this->context->link->getAdminLink('AdminModules').'&select=favorites'
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
$this->smartyOutputContent('controllers/modules/tab_modules_list.tpl');
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ajaxProcessSetFilter()
|
|
|
|
|
{
|
|
|
|
@@ -265,6 +297,22 @@ class AdminModulesControllerCore extends AdminController
|
|
|
|
|
die('OK');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ajaxProcessSaveTabModulePreferences()
|
|
|
|
|
{
|
|
|
|
|
$values = Tools::getValue('value_pref');
|
|
|
|
|
$module = Tools::getValue('module_pref');
|
|
|
|
|
if (Validate::isModuleName($module))
|
|
|
|
|
{
|
|
|
|
|
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'tab_module_preference` WHERE `id_employee` = '.(int)$this->id_employee.' AND `module` = \''.pSQL($module).'\'');
|
|
|
|
|
if (is_array($values) && count($values))
|
|
|
|
|
foreach($values as $value)
|
|
|
|
|
Db::getInstance()->execute('
|
|
|
|
|
INSERT INTO `'._DB_PREFIX_.'tab_module_preference` (`id_tab_module_preference`, `id_employee`, `id_tab`, `module`)
|
|
|
|
|
VALUES (NULL, '.(int)$this->id_employee.', '.(int)$value.', \''.pSQL($module).'\');');
|
|
|
|
|
}
|
|
|
|
|
die('OK');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** Get current URL
|
|
|
|
|
**
|
|
|
|
@@ -730,6 +778,9 @@ class AdminModulesControllerCore extends AdminController
|
|
|
|
|
// Call appropriate module callback
|
|
|
|
|
if (!isset($ppmReturn))
|
|
|
|
|
$this->postProcessCallback();
|
|
|
|
|
|
|
|
|
|
if ($back = Tools::getValue('back'))
|
|
|
|
|
Tools::redirectAdmin($back);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -758,42 +809,6 @@ class AdminModulesControllerCore extends AdminController
|
|
|
|
|
return $html_error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** Display Modules Lists
|
|
|
|
|
**
|
|
|
|
|
*/
|
|
|
|
|
protected $translationsTab = array();
|
|
|
|
|
public function displayModuleOptions($module)
|
|
|
|
|
{
|
|
|
|
|
if (!isset($this->translationsTab['Disable this module']))
|
|
|
|
|
{
|
|
|
|
|
$this->translationsTab['Disable this module'] = $this->l('Disable this module');
|
|
|
|
|
$this->translationsTab['Enable this module for all shops'] = $this->l('Enable this module for all shops');
|
|
|
|
|
$this->translationsTab['Disable'] = $this->l('Disable');
|
|
|
|
|
$this->translationsTab['Enable'] = $this->l('Enable');
|
|
|
|
|
$this->translationsTab['Reset'] = $this->l('Reset');
|
|
|
|
|
$this->translationsTab['Configure'] = $this->l('Configure');
|
|
|
|
|
$this->translationsTab['Delete'] = $this->l('Delete');
|
|
|
|
|
$this->translationsTab['This action will permanently remove the module from the server. Are you sure you want to do this?'] = $this->l('This action will permanently remove the module from the server. Are you sure you want to do this?');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return = '';
|
|
|
|
|
if ($module->id)
|
|
|
|
|
$return .= ' <span class="desactive-module"><a class="action_module" '.($module->active && $module->onclick_option && isset($module->onclick_option_content['desactive']) ? 'onclick="'.$module->onclick_option_content['desactive'].'"' : '').'
|
|
|
|
|
href="'.self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&'.($module->active ? 'enable=0' : 'enable=1').'&tab_module='.$module->tab.'" '.((Shop::isFeatureActive()) ? 'title="'.htmlspecialchars($module->active ? $this->translationsTab['Disable this module'] : $this->translationsTab['Enable this module for all shops']).'"' : '').'>'.($module->active ? $this->translationsTab['Disable'] : $this->translationsTab['Enable']).'</a></span>';
|
|
|
|
|
|
|
|
|
|
if ($module->id && $module->active)
|
|
|
|
|
$return .= (!empty($result) ? '|' : '').' <span class="reset-module"><a class="action_module" '.($module->onclick_option && isset($module->onclick_option_content['reset']) ? 'onclick="'.$module->onclick_option_content['reset'].'"' : '').' href="'.self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&reset&tab_module='.$module->tab.'">'.$this->translationsTab['Reset'].'</a></span>';
|
|
|
|
|
|
|
|
|
|
if ($module->id && isset($module->is_configurable) && $module->is_configurable)
|
|
|
|
|
$return .= (!empty($result) ? '|' : '').' <span class="configure-module"><a class="action_module" '.($module->onclick_option && isset($module->onclick_option_content['configure']) ? 'onclick="'.$module->onclick_option_content['configure'].'"' : '').' href="'.self::$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->translationsTab['Configure'].'</a></span>';
|
|
|
|
|
|
|
|
|
|
$hrefDelete = self::$currentIndex.'&delete='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name);
|
|
|
|
|
$return .= (!empty($result) ? '|' : '').' <span class="delete-module"><a class="action_module" '.($module->onclick_option && isset($module->onclick_option_content['delete']) ? 'onclick="'.$module->onclick_option_content['delete'].'"' : '').' onclick="return confirm(\''.$this->translationsTab['This action will permanently remove the module from the server. Are you sure you want to do this?'].'\');" href="'.$hrefDelete.'">'.$this->translationsTab['Delete'].'</a></span>';
|
|
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function initModulesList(&$modules)
|
|
|
|
|
{
|
|
|
|
|
foreach ($modules as $k => $module)
|
|
|
|
@@ -925,7 +940,7 @@ class AdminModulesControllerCore extends AdminController
|
|
|
|
|
// Module has not been filtered
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function initContent()
|
|
|
|
|
{
|
|
|
|
|
// Adding Css
|
|
|
|
@@ -951,7 +966,13 @@ class AdminModulesControllerCore extends AdminController
|
|
|
|
|
|
|
|
|
|
// Retrieve Modules Preferences
|
|
|
|
|
$modules_preferences = '';
|
|
|
|
|
$tab_modules_preferences = array();
|
|
|
|
|
$modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'module_preference` WHERE `id_employee` = '.(int)$this->id_employee);
|
|
|
|
|
$tab_modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'tab_module_preference` WHERE `id_employee` = '.(int)$this->id_employee);
|
|
|
|
|
|
|
|
|
|
foreach($tab_modules_preferences_tmp as $i => $j)
|
|
|
|
|
$tab_modules_preferences[$j['module']][] = $j['id_tab'];
|
|
|
|
|
|
|
|
|
|
foreach ($modules_preferences_tmp as $k => $v)
|
|
|
|
|
{
|
|
|
|
|
if ($v['interest'] == null)
|
|
|
|
@@ -971,6 +992,13 @@ class AdminModulesControllerCore extends AdminController
|
|
|
|
|
// Browse modules list
|
|
|
|
|
foreach ($modules as $km => $module)
|
|
|
|
|
{
|
|
|
|
|
//if we are in favorites view we only display installed modules
|
|
|
|
|
if (Tools::getValue('select') == 'favorites' && !$module->id)
|
|
|
|
|
{
|
|
|
|
|
unset($modules[$km]);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Upgrade Module process, init check if a module could be upgraded
|
|
|
|
|
if (Module::initUpgradeModule($module))
|
|
|
|
|
{
|
|
|
|
@@ -1033,34 +1061,11 @@ class AdminModulesControllerCore extends AdminController
|
|
|
|
|
unset($modules[$km]);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$obj = null;
|
|
|
|
|
if ($module->onclick_option)
|
|
|
|
|
$obj = new $module->name();
|
|
|
|
|
|
|
|
|
|
// Fill module data
|
|
|
|
|
$modules[$km]->logo = '../../img/questionmark.png';
|
|
|
|
|
if (file_exists('../modules/'.$module->name.'/logo.gif'))
|
|
|
|
|
$modules[$km]->logo = 'logo.gif';
|
|
|
|
|
if (file_exists('../modules/'.$module->name.'/logo.png'))
|
|
|
|
|
$modules[$km]->logo = 'logo.png';
|
|
|
|
|
$modules[$km]->optionsHtml = $this->displayModuleOptions($module);
|
|
|
|
|
$modules[$km]->categoryName = (isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name']);
|
|
|
|
|
$modules[$km]->options['install_url'] = self::$currentIndex.'&install='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
|
|
|
|
$modules[$km]->options['update_url'] = self::$currentIndex.'&update='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
|
|
|
|
$modules[$km]->options['uninstall_url'] = self::$currentIndex.'&uninstall='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
|
|
|
|
|
|
|
|
|
$modules[$km]->options['uninstall_onclick'] = ((!$module->onclick_option) ?
|
|
|
|
|
((empty($module->confirmUninstall)) ? '' : 'return confirm(\''.addslashes($module->confirmUninstall).'\');') :
|
|
|
|
|
$obj->onclickOption('uninstall', $modules[$km]->options['uninstall_url']));
|
|
|
|
|
|
|
|
|
|
if ((Tools::getValue('module_name') == $module->name || in_array($module->name, explode('|', Tools::getValue('modules_list')))) && (int)Tools::getValue('conf') > 0)
|
|
|
|
|
$modules[$km]->message = $this->_conf[(int)Tools::getValue('conf')];
|
|
|
|
|
|
|
|
|
|
if ((Tools::getValue('module_name') == $module->name || in_array($module->name, explode('|', Tools::getValue('modules_list')))) && (int)Tools::getValue('conf') > 0)
|
|
|
|
|
$this->fillModuleData($module);
|
|
|
|
|
$module->categoryName = (isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name']);
|
|
|
|
|
|
|
|
|
|
if (isset($modules_preferences[$modules[$km]->name]))
|
|
|
|
|
$modules[$km]->preferences = $modules_preferences[$modules[$km]->name];
|
|
|
|
|
unset($obj);
|
|
|
|
|
}
|
|
|
|
|
unset($object);
|
|
|
|
|
}
|
|
|
|
@@ -1109,6 +1114,7 @@ class AdminModulesControllerCore extends AdminController
|
|
|
|
|
$tpl_vars['check_openssl'] = (extension_loaded('openssl') ? 'ok' : 'ko');
|
|
|
|
|
|
|
|
|
|
$tpl_vars['add_permission'] = $this->tabAccess['add'];
|
|
|
|
|
$tpl_vars['tab_modules_preferences'] = $tab_modules_preferences;
|
|
|
|
|
|
|
|
|
|
if ($this->logged_on_addons)
|
|
|
|
|
{
|
|
|
|
|