// same for unregister hook
This commit is contained in:
@@ -128,6 +128,22 @@ class HookCore extends ObjectModel
|
|||||||
return Cache::retrieve($cache_id);
|
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
|
* Get list of hook alias
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -731,11 +731,16 @@ abstract class ModuleCore
|
|||||||
// Get hook id if a name is given as argument
|
// Get hook id if a name is given as argument
|
||||||
if (!is_numeric($hook_id))
|
if (!is_numeric($hook_id))
|
||||||
{
|
{
|
||||||
|
$hook_name = (int)$hook_id;
|
||||||
// Retrocompatibility
|
// Retrocompatibility
|
||||||
$hook_id = Hook::getIdByName($hook_id);
|
$hook_id = Hook::getIdByName($hook_id);
|
||||||
if (!$hook_id)
|
if (!$hook_id)
|
||||||
return false;
|
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
|
// Unregister module on hook by id
|
||||||
$sql = 'DELETE FROM `'._DB_PREFIX_.'hook_module`
|
$sql = 'DELETE FROM `'._DB_PREFIX_.'hook_module`
|
||||||
@@ -746,6 +751,8 @@ abstract class ModuleCore
|
|||||||
// Clean modules position
|
// Clean modules position
|
||||||
$this->cleanPositions($hook_id, $shop_list);
|
$this->cleanPositions($hook_id, $shop_list);
|
||||||
|
|
||||||
|
Hook::exec('actionModuleUnRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,3 +17,5 @@ CHANGE `module_name` `module_name` VARCHAR(64) NULL DEFAULT NULL;
|
|||||||
/* PHP:fix_download_product_feature_active(); */;
|
/* PHP:fix_download_product_feature_active(); */;
|
||||||
/* PHP:add_module_to_hook(blockmyaccount, actionModuleRegisterHookAfter); */;
|
/* PHP:add_module_to_hook(blockmyaccount, actionModuleRegisterHookAfter); */;
|
||||||
/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleRegisterHookAfter); */;
|
/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleRegisterHookAfter); */;
|
||||||
|
/* PHP:add_module_to_hook(blockmyaccount, actionModuleUnRegisterHookAfter); */;
|
||||||
|
/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleUnRegisterHookAfter); */;
|
||||||
@@ -49,7 +49,8 @@ class BlockMyAccount extends Module
|
|||||||
|| !parent::install()
|
|| !parent::install()
|
||||||
|| !$this->registerHook('displayLeftColumn')
|
|| !$this->registerHook('displayLeftColumn')
|
||||||
|| !$this->registerHook('displayHeader')
|
|| !$this->registerHook('displayHeader')
|
||||||
|| !$this->registerHook('actionModuleRegisterHookAfter'))
|
|| !$this->registerHook('actionModuleRegisterHookAfter')
|
||||||
|
|| !$this->registerHook('actionModuleUnRegisterUnHookAfter'))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -59,6 +60,11 @@ class BlockMyAccount extends Module
|
|||||||
return (parent::uninstall() && $this->removeMyAccountBlockHook());
|
return (parent::uninstall() && $this->removeMyAccountBlockHook());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hookActionUnModuleRegisterHookAfter($params)
|
||||||
|
{
|
||||||
|
return $this->hookActionModuleRegisterHookAfter($params);
|
||||||
|
}
|
||||||
|
|
||||||
public function hookActionModuleRegisterHookAfter($params)
|
public function hookActionModuleRegisterHookAfter($params)
|
||||||
{
|
{
|
||||||
if ($params['hook_name'] == 'displayMyAccountBlock')
|
if ($params['hook_name'] == 'displayMyAccountBlock')
|
||||||
|
|||||||
@@ -45,11 +45,22 @@ class Blockmyaccountfooter extends Module
|
|||||||
|
|
||||||
public function install()
|
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 false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hookActionUnModuleRegisterHookAfter($params)
|
||||||
|
{
|
||||||
|
return $this->hookActionModuleRegisterHookAfter($params);
|
||||||
|
}
|
||||||
|
|
||||||
public function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
return parent::uninstall() && $this->removeMyAccountBlockHook();
|
return parent::uninstall() && $this->removeMyAccountBlockHook();
|
||||||
|
|||||||
Reference in New Issue
Block a user