diff --git a/admin-dev/themes/default/css/admin-theme.css b/admin-dev/themes/default/css/admin-theme.css index a0f3f4317..5711b217e 100644 --- a/admin-dev/themes/default/css/admin-theme.css +++ b/admin-dev/themes/default/css/admin-theme.css @@ -1,5 +1,5 @@ @import url(http://fonts.googleapis.com/css?family=Josefin+Sans:200,400,700); -/*! +/* * Bootstrap v3.0.0 * * Copyright 2013 Twitter, Inc @@ -8,7 +8,7 @@ * * Designed and built with all the love in the world by @mdo and @fat. */ -/*! normalize.css v2.1.0 | MIT License | git.io/normalize */ +/* normalize.css v2.1.0 | MIT License | git.io/normalize */ /* line 22, ../bower_components/sass-bootstrap/lib/_normalize.scss */ article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { display: block; } @@ -5718,7 +5718,7 @@ th.visible-print, td.visible-print { /* line 523, ../bower_components/sass-bootstrap/lib/_mixins.scss */ th.hidden-print, td.hidden-print { display: none !important; } } -/*! +/* * Font Awesome 3.2.1 * the iconic font designed for Bootstrap * ------------------------------------------------------------------------------ @@ -9323,8 +9323,7 @@ textarea:focus, input[type="text"]:focus, input[type="password"]:focus, input[ty -webkit-box-shadow: #00a4e7 0 0 0 inset; box-shadow: #00a4e7 0 0 0 inset; } } -/*! - * Ladda +/* Ladda * http://lab.hakim.se/ladda * MIT licensed * diff --git a/classes/module/Module.php b/classes/module/Module.php index 5a84a9d51..f63a4f81f 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -675,67 +675,75 @@ abstract class ModuleCore */ public function registerHook($hook_name, $shop_list = null) { - // Check hook name validation and if module is installed - if (!Validate::isHookName($hook_name)) - throw new PrestaShopException('Invalid hook name'); - if (!isset($this->id) || !is_numeric($this->id)) - return false; - - // Retrocompatibility - $hook_name_bak = $hook_name; - if ($alias = Hook::getRetroHookName($hook_name)) - $hook_name = $alias; - - Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name)); - // Get hook id - $id_hook = Hook::getIdByName($hook_name); - $live_edit = Hook::getLiveEditById((int)Hook::getIdByName($hook_name_bak)); - - // If hook does not exist, we create it - if (!$id_hook) - { - $new_hook = new Hook(); - $new_hook->name = pSQL($hook_name); - $new_hook->title = pSQL($hook_name); - $new_hook->live_edit = pSQL($live_edit); - $new_hook->add(); - $id_hook = $new_hook->id; - if (!$id_hook) - return false; - } - - // If shop lists is null, we fill it with all shops - if (is_null($shop_list)) - $shop_list = Shop::getShops(true, null, true); - $return = true; - foreach ($shop_list as $shop_id) + if (is_array($hook_name)) + $hook_names = $hook_name; + else + $hook_names = array($hook_name); + + foreach ($hook_names as $hook_name) { - // Check if already register - $sql = 'SELECT hm.`id_module` - FROM `'._DB_PREFIX_.'hook_module` hm, `'._DB_PREFIX_.'hook` h - WHERE hm.`id_module` = '.(int)($this->id).' AND h.`id_hook` = '.$id_hook.' - AND h.`id_hook` = hm.`id_hook` AND `id_shop` = '.(int)$shop_id; - if (Db::getInstance()->getRow($sql)) - continue; + // Check hook name validation and if module is installed + if (!Validate::isHookName($hook_name)) + throw new PrestaShopException('Invalid hook name'); + if (!isset($this->id) || !is_numeric($this->id)) + return false; - // Get module position in hook - $sql = 'SELECT MAX(`position`) AS position - FROM `'._DB_PREFIX_.'hook_module` - WHERE `id_hook` = '.(int)$id_hook.' AND `id_shop` = '.(int)$shop_id; - if (!$position = Db::getInstance()->getValue($sql)) - $position = 0; + // Retrocompatibility + $hook_name_bak = $hook_name; + if ($alias = Hook::getRetroHookName($hook_name)) + $hook_name = $alias; - // Register module in hook - $return &= Db::getInstance()->insert('hook_module', array( - 'id_module' => (int)$this->id, - 'id_hook' => (int)$id_hook, - 'id_shop' => (int)$shop_id, - 'position' => (int)($position + 1), - )); + Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name)); + // Get hook id + $id_hook = Hook::getIdByName($hook_name); + $live_edit = Hook::getLiveEditById((int)Hook::getIdByName($hook_name_bak)); + + // If hook does not exist, we create it + if (!$id_hook) + { + $new_hook = new Hook(); + $new_hook->name = pSQL($hook_name); + $new_hook->title = pSQL($hook_name); + $new_hook->live_edit = pSQL($live_edit); + $new_hook->add(); + $id_hook = $new_hook->id; + if (!$id_hook) + return false; + } + + // If shop lists is null, we fill it with all shops + if (is_null($shop_list)) + $shop_list = Shop::getShops(true, null, true); + + foreach ($shop_list as $shop_id) + { + // Check if already register + $sql = 'SELECT hm.`id_module` + FROM `'._DB_PREFIX_.'hook_module` hm, `'._DB_PREFIX_.'hook` h + WHERE hm.`id_module` = '.(int)($this->id).' AND h.`id_hook` = '.$id_hook.' + AND h.`id_hook` = hm.`id_hook` AND `id_shop` = '.(int)$shop_id; + if (Db::getInstance()->getRow($sql)) + continue; + + // Get module position in hook + $sql = 'SELECT MAX(`position`) AS position + FROM `'._DB_PREFIX_.'hook_module` + WHERE `id_hook` = '.(int)$id_hook.' AND `id_shop` = '.(int)$shop_id; + if (!$position = Db::getInstance()->getValue($sql)) + $position = 0; + + // Register module in hook + $return &= Db::getInstance()->insert('hook_module', array( + 'id_module' => (int)$this->id, + 'id_hook' => (int)$id_hook, + 'id_shop' => (int)$shop_id, + 'position' => (int)($position + 1), + )); + } + + Hook::exec('actionModuleRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name)); } - - Hook::exec('actionModuleRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name)); return $return; } diff --git a/install-dev/data/theme.sql b/install-dev/data/theme.sql index fcfa73ead..e393888dc 100644 --- a/install-dev/data/theme.sql +++ b/install-dev/data/theme.sql @@ -153,12 +153,7 @@ INSERT INTO `PREFIX_hook_module_exceptions` (`id_shop`, `id_module`, `id_hook`, UNION SELECT 'orderfollow' as page UNION SELECT 'orderslip' as page UNION SELECT 'discount' as page - UNION SELECT '' as page - UNION SELECT '' as page - UNION SELECT '' as page - UNION SELECT '' as page - UNION SELECT '' as page - UNION SELECT '' as page + UNION SELECT 'product' as page ) pages WHERE id_hook = @id_hook ); diff --git a/modules/blocknewproducts/blocknewproducts.php b/modules/blocknewproducts/blocknewproducts.php index 3185ebc44..844c5d6e3 100644 --- a/modules/blocknewproducts/blocknewproducts.php +++ b/modules/blocknewproducts/blocknewproducts.php @@ -105,7 +105,9 @@ class BlockNewProducts extends Module protected function getCacheId($name = null) { - return parent::getCacheId('blocknewproducts|'.date('Ymd')); + if ($name === null) + $name = 'blocknewproducts'; + return parent::getCacheId($name.'|'.date('Ymd')); } public function hookLeftColumn($params) @@ -125,7 +127,7 @@ class BlockNewProducts extends Module public function hookHeader($params) { - $this->context->controller->addCSS(($this->_path).'blocknewproducts.css', 'all'); + $this->context->controller->addCSS($this->_path.'blocknewproducts.css', 'all'); } public function hookAddProduct($params) diff --git a/modules/blocknewsletter/blocknewsletter.php b/modules/blocknewsletter/blocknewsletter.php index 1be48971e..dba05baaf 100644 --- a/modules/blocknewsletter/blocknewsletter.php +++ b/modules/blocknewsletter/blocknewsletter.php @@ -61,8 +61,7 @@ class Blocknewsletter extends Module public function install() { - if (parent::install() == false || $this->registerHook('leftColumn') == false || $this->registerHook('header') == false - || $this->registerHook('actionCustomerAccountAdd') == false) + if (!parent::install() || !$this->registerHook(array('header', 'footer', 'actionCustomerAccountAdd'))) return false; Configuration::updateValue('NW_SALT', Tools::passwdGen(16)); @@ -83,9 +82,8 @@ class Blocknewsletter extends Module public function uninstall() { - if (!parent::uninstall()) - return false; - return Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'newsletter'); + Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'newsletter'); + return parent::uninstall(); } public function getContent()