From 0eaf34823f30502739d39efe2b592cb223089ed6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 12 Mar 2009 19:00:18 +0000 Subject: [PATCH] Fixes for admin ACLs --- inc/libs/admins_functions.php | 4 ++-- inc/libs/cache_functions.php | 9 +++++++++ inc/modules/admin/what-admins_mails.php | 12 ++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/inc/libs/admins_functions.php b/inc/libs/admins_functions.php index 665f2e9bf8..c0d4c13023 100644 --- a/inc/libs/admins_functions.php +++ b/inc/libs/admins_functions.php @@ -71,7 +71,7 @@ function ADMINS_CHECK_ACL($act, $wht) { // Shall I test for a main or sub menu? (action or what?) $acl_mode = "failed"; - if (GET_EXT_VERSION("cache") >= "0.1.2") { + if ((GET_EXT_VERSION("cache") >= "0.1.2") && (count($GLOBALS['cache_array']['admin_acls']) > 0)) { // Lookup in cache if ((!empty($act)) && (isset($GLOBALS['cache_array']['admin_acls']['action_menu'][$aid])) & ($GLOBALS['cache_array']['admin_acls']['action_menu'][$aid] == $act)) { // Main menu line found @@ -86,7 +86,7 @@ function ADMINS_CHECK_ACL($act, $wht) { // Count cache hits incrementConfigEntry('cache_hits'); } - } else { + } elseif (!EXT_IS_ACTIVE("cache")) { // Old version, so load it from database if (!empty($act)) { // Main menu diff --git a/inc/libs/cache_functions.php b/inc/libs/cache_functions.php index d1cc8d2853..afae515b3e 100644 --- a/inc/libs/cache_functions.php +++ b/inc/libs/cache_functions.php @@ -418,6 +418,9 @@ class CacheSystem { // Destroy the cache on extension changes function FILTER_CACHE_DESTROY_ON_EXT_CHANGE ($data) { + // Return the data anyway if there is no cache extension + if (!isCacheInstanceValid()) return $data; + // Remove cache if ($GLOBALS['cache_instance']->loadCacheFile("config")) $GLOBALS['cache_instance']->destroyCacheFile(); if ($GLOBALS['cache_instance']->loadCacheFile("extensions")) $GLOBALS['cache_instance']->destroyCacheFile(); @@ -429,12 +432,18 @@ function FILTER_CACHE_DESTROY_ON_EXT_CHANGE ($data) { // Destroy the cache on changing admin function FILTER_CACHE_DESTROY_ON_ADMIN_CHANGE () { + // Skip this step if the cache instance is not there + if (!isCacheInstanceValid()) return false; + // Remove cache if ($GLOBALS['cache_instance']->loadCacheFile("admins")) $GLOBALS['cache_instance']->destroyCacheFile(); } // Destroy all cache files function FILTER_CACHE_DESTROY_ALL () { + // Skip this step if the cache instance is not there + if (!isCacheInstanceValid()) return false; + // Remove cache files if ($GLOBALS['cache_instance']->loadCacheFile("admins")) $GLOBALS['cache_instance']->destroyCacheFile(); if ($GLOBALS['cache_instance']->loadCacheFile("admins_acls")) $GLOBALS['cache_instance']->destroyCacheFile(); diff --git a/inc/modules/admin/what-admins_mails.php b/inc/modules/admin/what-admins_mails.php index 37baf61f81..3f8f9d8be8 100644 --- a/inc/modules/admin/what-admins_mails.php +++ b/inc/modules/admin/what-admins_mails.php @@ -131,25 +131,25 @@ ORDER BY m.admin_id, m.mail_template", __FILE__, __LINE__); ADD_SQL(SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_admins_mails` SET admin_id=%s WHERE id=%s ORDER BY `id` LIMIT 1", array($content['admin_id'], $id), __FILE__, __LINE__, false)); - if (($content['admin_id'] < 1) && (REQUEST_ISSET_POST(('template', $id)))) { + if (($content['admin_id'] < 1) && (REQUEST_ISSET_POST('template', $id))) { // Remove any other admin entries ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admins_mails` WHERE mail_template='%s' AND id != '%s'", array(REQUEST_POST('template', $id), $id), __FILE__, __LINE__, false)); - } + } // END - if if (REQUEST_POST('admin_new', REQUEST_POST('template', $id)) > 0) { // Add new admin ADD_SQL(SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_admins_mails` (admin_id, mail_template) VALUES ('%s','%s')", array($content['admin_id'], REQUEST_POST('template', $id)), __FILE__, __LINE__, false)); - } - } + } // END - if + } // END - foreach // Run all queries runFilterChain('run_sqls'); // Query again... $result = SQL_QUERY("SELECT DISTINCT m.id, m.admin_id, a.login, m.mail_template FROM `{!_MYSQL_PREFIX!}_admins_mails` AS m, `{!_MYSQL_PREFIX!}_admins` AS a WHERE m.admin_id=a.id OR m.admin_id < 1 ORDER BY m.admin_id", __FILE__, __LINE__); - } + } // END - if // List found entries $OUT = ""; $SW = 2; @@ -165,7 +165,7 @@ ORDER BY m.admin_id, m.mail_template", __FILE__, __LINE__); // Load row template $OUT .= LOAD_TEMPLATE("admin_admins_mails_list_row", true, $content); $SW = 3 - $SW; - } + } // END - while // Free result SQL_FREERESULT($result); -- 2.39.5