]> git.mxchange.org Git - mailer.git/commitdiff
Fixes for admin ACLs
authorRoland Häder <roland@mxchange.org>
Thu, 12 Mar 2009 19:00:18 +0000 (19:00 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 12 Mar 2009 19:00:18 +0000 (19:00 +0000)
inc/libs/admins_functions.php
inc/libs/cache_functions.php
inc/modules/admin/what-admins_mails.php

index 665f2e9bf8e4bfad40bcb5d2562781fe38ae5c72..c0d4c13023df4398210569cb391dad0960c30404 100644 (file)
@@ -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
index d1cc8d28537b2d760adfe3e112f5e371cfd0af1a..afae515b3e16625c145946b9e7b1c266575102a1 100644 (file)
@@ -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();
index 37baf61f81114e519a4835581569f23d33e13d9a..3f8f9d8be87362a6de60422b4f51569836862673 100644 (file)
@@ -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);