diff --git a/classes/Hook.php b/classes/Hook.php index 61b976a63..451b3b31b 100644 --- a/classes/Hook.php +++ b/classes/Hook.php @@ -126,7 +126,9 @@ class HookCore extends ObjectModel FROM `'._DB_PREFIX_.'hook_alias` ha INNER JOIN `'._DB_PREFIX_.'hook` h ON ha.name = h.name'); foreach ($result as $row) + { $hook_ids[$row['name']] = $row['id_hook']; + } Cache::store($cache_id, $hook_ids); } else @@ -147,9 +149,23 @@ class HookCore extends ObjectModel FROM `'._DB_PREFIX_.'hook` WHERE `id_hook` = '.(int)$hook_id) ); - return Cache::retrieve($cache_id); } + + /** + * Return hook live edit bool from ID + */ + public static function getLiveEditById($hook_id) + { + $cache_id = 'hook_live_editbyid_'.$hook_id; + if (!Cache::isStored($cache_id)) + Cache::store($cache_id, Db::getInstance()->getValue(' + SELECT `live_edit` + FROM `'._DB_PREFIX_.'hook` + WHERE `id_hook` = '.(int)$hook_id) + ); + return Cache::retrieve($cache_id); + } /** * Get list of hook alias @@ -401,6 +417,7 @@ class HookCore extends ObjectModel // Look on modules list $altern = 0; $output = ''; + foreach ($module_list as $array) { // Check errors @@ -456,7 +473,7 @@ class HookCore extends ObjectModel if ($array_return) return $output; else - return ($live_edit ? ' + return ($live_edit ? '
' : '').$output.($live_edit ? '
' : '');// Return html string } @@ -465,13 +482,13 @@ class HookCore extends ObjectModel return '
- - ' + + ' .Tools::safeOutput($moduleInstance->displayName).' - + '.$display.'
'; } diff --git a/classes/module/Module.php b/classes/module/Module.php index be604de92..06d31c8e9 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -669,12 +669,14 @@ abstract class ModuleCore 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) @@ -682,6 +684,7 @@ abstract class ModuleCore $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)