Remove myaac_hooks table, load info directly from .json files and cache them

This commit is contained in:
slawkens
2020-01-13 20:19:34 +01:00
parent aaaba5cc84
commit e08557e5ae
7 changed files with 62 additions and 54 deletions

View File

@@ -27,6 +27,7 @@ define('HOOK_LOGOUT', 15);
define('HOOK_FIRST', HOOK_STARTUP);
define('HOOK_LAST', HOOK_LOGOUT);
require_once LIBS . 'plugins.php';
class Hook
{
private $_name, $_type, $_file;
@@ -90,27 +91,8 @@ class Hooks
public function load()
{
global $db;
$cache = Cache::getInstance();
if ($cache->enabled()) {
$tmp = '';
if ($cache->fetch('hooks', $tmp)) {
$hooks = unserialize($tmp);
}
}
if (!isset($hooks)) {
$hooks = $db->query('SELECT `name`, `type`, `file` FROM `' . TABLE_PREFIX . 'hooks` WHERE `enabled` = 1 ORDER BY `ordering`;')->fetchAll();
if ($cache->enabled()) {
$cache->set('hooks', serialize($hooks), 600);
}
}
foreach($hooks as $hook) {
foreach(Plugins::getHooks() as $hook) {
$this->register($hook['name'], $hook['type'], $hook['file']);
}
}
}
?>