diff --git a/classes/Hook.php b/classes/Hook.php index 994c452f5..74d95142c 100644 --- a/classes/Hook.php +++ b/classes/Hook.php @@ -128,6 +128,22 @@ class HookCore extends ObjectModel return Cache::retrieve($cache_id); } + /** + * Return hook ID from name + */ + public static function getNameById($hook_id) + { + $cache_id = 'hook_namebyid_'.$hook_id; + if (!Cache::isStored($cache_id)) + Cache::store($cache_id, Db::getInstance()->getValue(' + SELECT `name` + FROM `'._DB_PREFIX_.'hook` + WHERE `id_hook` = '.(int)$hook_id) + ); + + return Cache::retrieve($cache_id); + } + /** * Get list of hook alias * diff --git a/classes/module/Module.php b/classes/module/Module.php index 83e197387..4f7281ba4 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -731,11 +731,16 @@ abstract class ModuleCore // Get hook id if a name is given as argument if (!is_numeric($hook_id)) { + $hook_name = (int)$hook_id; // Retrocompatibility $hook_id = Hook::getIdByName($hook_id); if (!$hook_id) return false; } + else + $hook_name = Hook::getNameById((int)$hook_id); + + Hook::exec('actionModuleUnRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name)); // Unregister module on hook by id $sql = 'DELETE FROM `'._DB_PREFIX_.'hook_module` @@ -746,6 +751,8 @@ abstract class ModuleCore // Clean modules position $this->cleanPositions($hook_id, $shop_list); + Hook::exec('actionModuleUnRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name)); + return $result; } diff --git a/install-dev/upgrade/sql/1.5.5.0.sql b/install-dev/upgrade/sql/1.5.5.0.sql index f4953cc04..f5d4f6a97 100644 --- a/install-dev/upgrade/sql/1.5.5.0.sql +++ b/install-dev/upgrade/sql/1.5.5.0.sql @@ -17,3 +17,5 @@ CHANGE `module_name` `module_name` VARCHAR(64) NULL DEFAULT NULL; /* PHP:fix_download_product_feature_active(); */; /* PHP:add_module_to_hook(blockmyaccount, actionModuleRegisterHookAfter); */; /* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleRegisterHookAfter); */; +/* PHP:add_module_to_hook(blockmyaccount, actionModuleUnRegisterHookAfter); */; +/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleUnRegisterHookAfter); */; \ No newline at end of file diff --git a/modules/blockmyaccount/blockmyaccount.php b/modules/blockmyaccount/blockmyaccount.php index a83e87ebd..9855c36eb 100644 --- a/modules/blockmyaccount/blockmyaccount.php +++ b/modules/blockmyaccount/blockmyaccount.php @@ -49,7 +49,8 @@ class BlockMyAccount extends Module || !parent::install() || !$this->registerHook('displayLeftColumn') || !$this->registerHook('displayHeader') - || !$this->registerHook('actionModuleRegisterHookAfter')) + || !$this->registerHook('actionModuleRegisterHookAfter') + || !$this->registerHook('actionModuleUnRegisterUnHookAfter')) return false; return true; } @@ -59,6 +60,11 @@ class BlockMyAccount extends Module return (parent::uninstall() && $this->removeMyAccountBlockHook()); } + public function hookActionUnModuleRegisterHookAfter($params) + { + return $this->hookActionModuleRegisterHookAfter($params); + } + public function hookActionModuleRegisterHookAfter($params) { if ($params['hook_name'] == 'displayMyAccountBlock') diff --git a/modules/blockmyaccountfooter/blockmyaccountfooter.php b/modules/blockmyaccountfooter/blockmyaccountfooter.php index 538d4fe4d..0c387417e 100644 --- a/modules/blockmyaccountfooter/blockmyaccountfooter.php +++ b/modules/blockmyaccountfooter/blockmyaccountfooter.php @@ -45,11 +45,22 @@ class Blockmyaccountfooter extends Module public function install() { - if (!$this->addMyAccountBlockHook() || !parent::install() || !$this->registerHook('footer') || !$this->registerHook('header') || !$this->registerHook('actionModuleRegisterHookAfter')) + if (!$this->addMyAccountBlockHook() + || !parent::install() + || !$this->registerHook('footer') + || !$this->registerHook('header') + || !$this->registerHook('actionModuleRegisterHookAfter') + || !$this->registerHook('actionModuleUnRegisterHookAfter') + ) return false; return true; } + public function hookActionUnModuleRegisterHookAfter($params) + { + return $this->hookActionModuleRegisterHookAfter($params); + } + public function uninstall() { return parent::uninstall() && $this->removeMyAccountBlockHook();