[-] CORE: Copy live_edit bool when register alias hook
This commit is contained in:
1 parent
5d2e19fe3b
commit
076b6d11a2
2 files changed
+24
-4
No files matched your search
+21
-4
@@ -126,7 +126,9 @@ class HookCore extends ObjectModel
|
|||||||
FROM `'._DB_PREFIX_.'hook_alias` ha
|
FROM `'._DB_PREFIX_.'hook_alias` ha
|
||||||
INNER JOIN `'._DB_PREFIX_.'hook` h ON ha.name = h.name');
|
INNER JOIN `'._DB_PREFIX_.'hook` h ON ha.name = h.name');
|
||||||
foreach ($result as $row)
|
foreach ($result as $row)
|
||||||
|
{
|
||||||
$hook_ids[$row['name']] = $row['id_hook'];
|
$hook_ids[$row['name']] = $row['id_hook'];
|
||||||
|
}
|
||||||
Cache::store($cache_id, $hook_ids);
|
Cache::store($cache_id, $hook_ids);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -147,7 +149,21 @@ class HookCore extends ObjectModel
|
|||||||
FROM `'._DB_PREFIX_.'hook`
|
FROM `'._DB_PREFIX_.'hook`
|
||||||
WHERE `id_hook` = '.(int)$hook_id)
|
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);
|
return Cache::retrieve($cache_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,6 +417,7 @@ class HookCore extends ObjectModel
|
|||||||
// Look on modules list
|
// Look on modules list
|
||||||
$altern = 0;
|
$altern = 0;
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
foreach ($module_list as $array)
|
foreach ($module_list as $array)
|
||||||
{
|
{
|
||||||
// Check errors
|
// Check errors
|
||||||
@@ -456,7 +473,7 @@ class HookCore extends ObjectModel
|
|||||||
if ($array_return)
|
if ($array_return)
|
||||||
return $output;
|
return $output;
|
||||||
else
|
else
|
||||||
return ($live_edit ? '<script type="text/javascript">hooks_list.push(\''.$hook_name.'\'); </script>
|
return ($live_edit ? '<script type="text/javascript">hooks_list.push(\''.$hook_name.'\');</script>
|
||||||
<div id="'.$hook_name.'" class="dndHook" style="min-height:50px">' : '').$output.($live_edit ? '</div>' : '');// Return html string
|
<div id="'.$hook_name.'" class="dndHook" style="min-height:50px">' : '').$output.($live_edit ? '</div>' : '');// Return html string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,13 +482,13 @@ class HookCore extends ObjectModel
|
|||||||
return '<script type="text/javascript"> modules_list.push(\''.Tools::safeOutput($moduleInstance->name).'\');</script>
|
return '<script type="text/javascript"> modules_list.push(\''.Tools::safeOutput($moduleInstance->name).'\');</script>
|
||||||
<div id="hook_'.(int)$id_hook.'_module_'.(int)$moduleInstance->id.'_moduleName_'.str_replace('_', '-', Tools::safeOutput($moduleInstance->name)).'"
|
<div id="hook_'.(int)$id_hook.'_module_'.(int)$moduleInstance->id.'_moduleName_'.str_replace('_', '-', Tools::safeOutput($moduleInstance->name)).'"
|
||||||
class="dndModule" style="border: 1px dotted red;'.(!strlen($display) ? 'height:50px;' : '').'">
|
class="dndModule" style="border: 1px dotted red;'.(!strlen($display) ? 'height:50px;' : '').'">
|
||||||
<span style="font-family: Georgia;font-size:13px;font-style:italic;">
|
<span style="font-family: Georgia;font-size:13px;font-style:italic;">
|
||||||
<img style="padding-right:5px;" src="'._MODULE_DIR_.Tools::safeOutput($moduleInstance->name).'/logo.gif">'
|
<img style="padding-right:5px;" src="'._MODULE_DIR_.Tools::safeOutput($moduleInstance->name).'/logo.gif">'
|
||||||
.Tools::safeOutput($moduleInstance->displayName).'<span style="float:right">
|
.Tools::safeOutput($moduleInstance->displayName).'<span style="float:right">
|
||||||
<a href="#" id="'.(int)$id_hook.'_'.(int)$moduleInstance->id.'" class="moveModule">
|
<a href="#" id="'.(int)$id_hook.'_'.(int)$moduleInstance->id.'" class="moveModule">
|
||||||
<img src="'._PS_ADMIN_IMG_.'arrow_out.png"></a>
|
<img src="'._PS_ADMIN_IMG_.'arrow_out.png"></a>
|
||||||
<a href="#" id="'.(int)$id_hook.'_'.(int)$moduleInstance->id.'" class="unregisterHook">
|
<a href="#" id="'.(int)$id_hook.'_'.(int)$moduleInstance->id.'" class="unregisterHook">
|
||||||
<img src="'._PS_ADMIN_IMG_.'delete.gif"></span></a>
|
<img src="'._PS_ADMIN_IMG_.'delete.gif"></a></span>
|
||||||
</span>'.$display.'</div>';
|
</span>'.$display.'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -669,12 +669,14 @@ abstract class ModuleCore
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Retrocompatibility
|
// Retrocompatibility
|
||||||
|
$hook_name_bak = $hook_name;
|
||||||
if ($alias = Hook::getRetroHookName($hook_name))
|
if ($alias = Hook::getRetroHookName($hook_name))
|
||||||
$hook_name = $alias;
|
$hook_name = $alias;
|
||||||
|
|
||||||
Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
|
Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
|
||||||
// Get hook id
|
// Get hook id
|
||||||
$id_hook = Hook::getIdByName($hook_name);
|
$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 hook does not exist, we create it
|
||||||
if (!$id_hook)
|
if (!$id_hook)
|
||||||
@@ -682,6 +684,7 @@ abstract class ModuleCore
|
|||||||
$new_hook = new Hook();
|
$new_hook = new Hook();
|
||||||
$new_hook->name = pSQL($hook_name);
|
$new_hook->name = pSQL($hook_name);
|
||||||
$new_hook->title = pSQL($hook_name);
|
$new_hook->title = pSQL($hook_name);
|
||||||
|
$new_hook->live_edit = pSQL($live_edit);
|
||||||
$new_hook->add();
|
$new_hook->add();
|
||||||
$id_hook = $new_hook->id;
|
$id_hook = $new_hook->id;
|
||||||
if (!$id_hook)
|
if (!$id_hook)
|
||||||
|
|||||||
Reference in new issue
Block a user