]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/admins_functions.php
A lot rewrites from double-quote to single-quote, some fixes for extension handling...
[mailer.git] / inc / libs / admins_functions.php
index c0d4c13023df4398210569cb391dad0960c30404..66f918e0505186a995bdbdb8a2048b95bc2b3853 100644 (file)
@@ -60,10 +60,10 @@ function ADMINS_CHECK_ACL($act, $wht) {
        if (!empty($wht)) {
                // Check for parent menu:
                // First get it's action value
-               $parent_action = GET_ACTION("admin", $wht);
+               $parent_action = GET_ACTION('admin', $wht);
 
                // Check with this function...
-               $parent = ADMINS_CHECK_ACL($parent_action, "");
+               $parent = ADMINS_CHECK_ACL($parent_action, '');
        } else {
                // Anything else is true!
                $parent = false;
@@ -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") && (count($GLOBALS['cache_array']['admin_acls']) > 0)) {
+       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');
                }
-       } elseif (!EXT_IS_ACTIVE("cache")) {
+       } elseif (!EXT_IS_ACTIVE('cache')) {
                // Old version, so load it from database
                if (!empty($act)) {
                        // Main menu
@@ -115,26 +115,28 @@ function ADMINS_CHECK_ACL($act, $wht) {
        } // END - if
 
        // Return value
+       //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:act={$act},wht={$wht},default={$default},acl_mode={$acl_mode}<br />\n";
        return $ret;
 }
 
 // Create email link to admins's account
-function ADMINS_CREATE_EMAIL_LINK ($email, $mod="admin") {
-       if (strpos("@", $email) > 0) {
+function ADMINS_CREATE_EMAIL_LINK ($email, $mod='admin') {
+       // Is it an email?
+       if (strpos($email, "@") !== false) {
                // Create email link
-               $result = SQL_QUERY_ESC("SELECT id
+               $result = SQL_QUERY_ESC("SELECT `id`
 FROM `{!_MYSQL_PREFIX!}_admins`
-WHERE email='%s' LIMIT 1",
+WHERE `email`='%s' LIMIT 1",
                        array($email), __FUNCTION__, __LINE__);
 
                // Is there an entry?
                if (SQL_NUMROWS($result) == 1) {
                        // Load userid
-                       list($uid) = SQL_FETCHROW($result);
+                       list($aid) = SQL_FETCHROW($result);
 
                        // Rewrite email address to contact link
-                       $email = "{!URL!}/modules.php?module=".$mod."&amp;what=user_contct&amp;uid=".bigintval($uid);
-               }
+                       $email = "{!URL!}/modules.php?module=".$mod."&amp;what=admins_contct&amp;admin=".bigintval($aid);
+               } // END - if
 
                // Free memory
                SQL_FREERESULT($result);
@@ -158,7 +160,7 @@ function ADMINS_CHANGE_ADMIN_ACCOUNT($POST) {
                // When both passwords match update admin account
                if ($POST['pass1'][$id] == $POST['pass2'][$id]) {
                        // Save only when both passwords are the same (also when they are empty)
-                       $add = ""; $cache_update = "1";
+                       $add = ''; $cache_update = "1";
 
                        // Generate hash
                        $hash = generateHash($POST['pass1'][$id]);
@@ -233,7 +235,7 @@ WHERE id=%s LIMIT 1",
 
                // Display message
                if (!empty($message)) {
-                       LOAD_TEMPLATE("admin_settings_saved", false, $message);
+                       LOAD_TEMPLATE('admin_settings_saved', false, $message);
                }
        }
 
@@ -247,7 +249,7 @@ function ADMINS_EDIT_ADMIN_ACCOUNTS ($POST) {
        $currMode = GET_ADMIN_DEFAULT_ACL(GET_CURRENT_ADMIN_ID());
 
        // Begin the edit loop
-       $OUT = ""; $SW = 2;
+       $OUT = ''; $SW = 2;
        foreach ($POST['sel'] as $id => $selected) {
                // Secure ID number
                $id = bigintval($id);
@@ -293,7 +295,7 @@ function ADMINS_DELETE_ADMIN_ACCOUNTS ($POST) {
        SQL_FREERESULT($result_main);
        if ($accounts > 1) {
                // Delete accounts
-               $OUT = ""; $SW = 2;
+               $OUT = ''; $SW = 2;
                foreach ($POST['sel'] as $id => $selected) {
                        // Secure ID number
                        $id = bigintval($id);
@@ -323,7 +325,7 @@ function ADMINS_DELETE_ADMIN_ACCOUNTS ($POST) {
                LOAD_TEMPLATE("admin_del_admins");
        } else {
                // Cannot delete last account!
-               LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_ADMINS_CANNOT_DELETE_LAST'));
+               LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_ADMINS_CANNOT_DELETE_LAST'));
        }
 }
 
@@ -359,7 +361,7 @@ function ADMINS_REMOVE_ADMIN_ACCOUNTS ($POST) {
 function ADMINS_LIST_ADMIN_ACCOUNTS() {
        // Select all admin accounts
        $result = SQL_QUERY("SELECT id, login, email, default_acl AS mode, la_mode FROM `{!_MYSQL_PREFIX!}_admins` ORDER BY login ASC", __FUNCTION__, __LINE__);
-       $OUT = ""; $SW = 2;
+       $OUT = ''; $SW = 2;
        while ($content = SQL_FETCHARRAY($result)) {
                // Compile some variables
                $content['mode'] = constant('ADMINS_'.strtoupper($content['mode']).'_MODE');
@@ -385,9 +387,9 @@ function ADMINS_LIST_ADMIN_ACCOUNTS() {
 // Filter for adding extra data to the query
 function FILTER_ADD_EXTRA_SQL_DATA ($add = "") {
        // Is the admins extension updated? (should be!)
-       if (GET_EXT_VERSION("admins") >= "0.3")   $add .= ", default_acl AS def_acl";
-       if (GET_EXT_VERSION("admins") >= "0.6.7") $add .= ", la_mode";
-       if (GET_EXT_VERSION("admins") >= "0.7.2") $add .= ", login_failures, UNIX_TIMESTAMP(last_failure) AS last_failure";
+       if (GET_EXT_VERSION('admins') >= '0.3.0')   $add .= ", default_acl AS def_acl";
+       if (GET_EXT_VERSION('admins') >= '0.6.7') $add .= ", la_mode";
+       if (GET_EXT_VERSION('admins') >= '0.7.2') $add .= ", login_failures, UNIX_TIMESTAMP(last_failure) AS last_failure";
 
        // Return it
        return $add;