diff --git a/classes/module/Module.php b/classes/module/Module.php index 8ac07dfd5..beced80e4 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -1062,9 +1062,17 @@ abstract class ModuleCore $item->currencies_mode = isset($tmp_module->currencies_mode) ? $tmp_module->currencies_mode : null; $item->confirmUninstall = isset($tmp_module->confirmUninstall) ? $tmp_module->confirmUninstall : null; - // Method pointer to get dynamically the onclick content $item->onclick_option = method_exists($module, 'onclickOption') ? true : false; - + if ($item->onclick_option) + { + $href = Context::getContext()->link->getAdminLink('Module', true).'&module_name='.$tmp_module->name.'&tab_module='.$tmp_module->tab; + $item->onclick_option_content = array(); + $option_tab = array('desactive', 'reset', 'configure', 'delete'); + foreach ($option_tab as $opt) + $item->onclick_option_content[$opt] = $tmp_module->onclickOption($opt, $href); + } + + $module_list[] = $item; if (!$xml_exist || $needNewConfigFile) { diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index 354d01a04..a8163d063 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -795,18 +795,18 @@ class AdminModulesControllerCore extends AdminController } $return = ''; - $href = self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&tab_module='.$module->tab; if ($module->id) - $return .= ' active && method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('desactive', $href).'"' : '').' 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']).''; + $return .= ' 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']).''; if ($module->id && $module->active) - $return .= (!empty($result) ? '|' : '').' '.$this->translationsTab['Reset'].''; + $return .= (!empty($result) ? '|' : '').' 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'].''; if ($module->id && isset($module->is_configurable) && $module->is_configurable) - $return .= (!empty($result) ? '|' : '').' '.$this->translationsTab['Configure'].''; + $return .= (!empty($result) ? '|' : '').' 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'].''; $hrefDelete = self::$currentIndex.'&delete='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name); - $return .= (!empty($result) ? '|' : '').' '.$this->translationsTab['Delete'].''; + $return .= (!empty($result) ? '|' : '').' 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'].''; return $return; }