More fixes for admin functions, thanks to Piter01
[mailer.git] / inc / libs / admins_functions.php
index b77ee5259a592a2fb2d8046279659f7bae0f5ab6..c5d0db38d4de683a8a5c81a07980cefda2332cad 100644 (file)
@@ -47,24 +47,13 @@ function ADMINS_CHECK_ACL($act, $wht) {
        // Default is deny
        $ret = false;
 
-       // Get admin's defult access right
-       if (!empty($cacheArray['admins']['def_acl'][get_session('admin_login')])) {
-               // Load from cache
-               $default = $cacheArray['admins']['def_acl'][get_session('admin_login')];
-
-               // Count cache hits
-               $_CONFIG['cache_hits']++;
-       } elseif (!is_object($cacheInstance)) {
-               // Load from database
-               $result = SQL_QUERY_ESC("SELECT default_acl FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
-                array(get_session('admin_login')), __FILE__, __LINE__);
-               list($default) = SQL_FETCHROW($result);
-               SQL_FREERESULT($result);
-       }
-
        // Get admin's ID
        $aid = GET_ADMIN_ID(get_session('admin_login'));
 
+       // Get admin's defult access right
+       $default = GET_ADMIN_DEFAULT_ACL($aid);
+
+
        if (!empty($wht)) {
                // Check for parent menu:
                // First get it's action value
@@ -98,7 +87,7 @@ function ADMINS_CHECK_ACL($act, $wht) {
                                        }
                                        if ($lines == 1) {
                                                // Count cache hits
-                                               $_CONFIG['cache_hits']++;
+                                               if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
                                                break;
                                        }
                                }
@@ -212,16 +201,10 @@ function ADMINS_CHANGE_ADMIN_ACCOUNT($POST) {
                                        // Update password cookie
                                        set_session("admin_md5", $hash);
                                }
-
-                       }
+                       } // END - if
 
                        // Get default ACL from admin to check if we can allow him to change the default ACL
-                       $result = SQL_QUERY_ESC("SELECT default_acl FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
-                        array(get_session('admin_login')), __FILE__, __LINE__);
-                       list($default) = SQL_FETCHROW($result);
-
-                       // Free result
-                       SQL_FREERESULT($result);
+                       $default = GET_ADMIN_DEFAULT_ACL(GET_ADMIN_ID(get_session('admin_login')));
 
                        // Update admin account
                        if ($default == "allow") {
@@ -337,10 +320,8 @@ function ADMINS_DELETE_ADMIN_ACCOUNTS ($POST) {
                                // Entry found
                                $content = SQL_FETCHARRAY($result);
                                SQL_FREERESULT($result);
-                               $eval = "\$content['mode'] = ADMINS_".strtoupper($content['mode'])."_MODE;";
-                               eval($eval);
-                               $eval = "\$content['la_mode'] = ADMINS_".strtoupper($content['la_mode'])."_LA_SETTING;";
-                               eval($eval);
+                               $content['mode'] = constant('ADMINS_'.strtoupper($content['mode']).'_MODE');
+                               $content['la_mode'] = constant('ADMINS_'.strtoupper($content['la_mode']).'_LA_SETTING');
 
                                // Prepare some more data
                                $content['sw'] = $SW;
@@ -398,10 +379,8 @@ function ADMINS_LIST_ADMIN_ACCOUNTS() {
        $SW = 2; $OUT = "";
        while ($content = SQL_FETCHARRAY($result)) {
                // Compile some variables
-               $eval = "\$content['mode'] = ADMINS_".strtoupper($content['mode'])."_MODE;";
-               eval($eval);
-               $eval = "\$content['la_mode'] = ADMINS_".strtoupper($content['la_mode'])."_LA_SETTING;";
-               eval($eval);
+               $content['mode'] = constant('ADMINS_'.strtoupper($content['mode']).'_MODE');
+               $content['la_mode'] = constant('ADMINS_'.strtoupper($content['la_mode']).'_LA_SETTING');
 
                // Prepare some more data
                $content['sw']         = $SW;