]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/admins_functions.php
Moved to this position, so both are closer to each other
[mailer.git] / inc / libs / admins_functions.php
index 663c0ab399cf58ad406ec3804edd61eb1eecceee..e50ce362a3a9b6f3e72e81c345232f853d9e3f5e 100644 (file)
@@ -53,9 +53,6 @@ function isAdminsAllowedByAcl ($action, $what) {
                return $GLOBALS[__FUNCTION__][$adminId][$action][$what];
        }
 
-       // But default result is failed
-       $GLOBALS[__FUNCTION__][$action][$what] = FALSE;
-
        // Get admin's defult access right
        $default = getAdminDefaultAcl($adminId);
 
@@ -123,6 +120,9 @@ function isAdminsAllowedByAcl ($action, $what) {
                SQL_FREERESULT($result);
        }
 
+       // But default result is failed
+       $GLOBALS[__FUNCTION__][$adminId][$action][$what] = FALSE;
+
        // Check ACL and (maybe) allow
        //* DEBUG: */ debugOutput('default='.$default.',acl_mode='.$aclMode.',parent='.intval($parent));
        if ((($default == 'allow') && ($aclMode != 'deny')) || (($default == 'deny') && ($aclMode == 'allow')) || ($parent === TRUE) || (($default == 'NO-ACL') && ($aclMode == 'failed') && ($parent === FALSE))) {
@@ -194,17 +194,17 @@ function adminsChangeAdminAccount ($postData, $element = '', $displayMessage = T
 
                        // Admin account saved
                        $message = '{--ADMIN_ACCOUNT_SAVED--}';
-               } elseif ((!empty($postData['pass1'])) && (!empty($postData['pass2']))) {
+               } elseif ((!empty($postData['password1'])) && (!empty($postData['password2']))) {
                        // Update only if both passwords match
-                       if (($postData['pass1'][$id] == $postData['pass2'][$id])) {
+                       if (($postData['password1'][$id] == $postData['password2'][$id])) {
                                // Save only when both passwords are the same (also when they are empty)
                                $add = ''; $cache_update = 1;
 
                                // Generate hash
-                               $hash = generateHash($postData['pass1'][$id]);
+                               $hash = generateHash($postData['password1'][$id]);
 
                                // Save password when set
-                               if (!empty($postData['pass1'][$id])) {
+                               if (!empty($postData['password1'][$id])) {
                                        $add = sprintf(",`password`='%s'", SQL_ESCAPE($hash));
                                } // END - if
 
@@ -225,7 +225,7 @@ function adminsChangeAdminAccount ($postData, $element = '', $displayMessage = T
                                                if (!empty($add)) {
                                                        setAdminMd5($hash);
                                                } // END - if
-                                       } elseif (generateHash($postData['pass1'][$id], $salt) != getAdminMd5()) {
+                                       } elseif (generateHash($postData['password1'][$id], $salt) != getAdminMd5()) {
                                                // Update password cookie
                                                setAdminMd5($hash);
                                        }
@@ -513,9 +513,12 @@ function sendAdminsEmails ($subject, $template, $content, $userid) {
 
        // No entries found?
        if (SQL_HASZERONUMS($result)) {
-               // Create new entry (to all admins)
-               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (`admin_id`, `mail_template`) VALUES (0, '%s')",
-                       array($template), __FUNCTION__, __LINE__);
+               // Is ext-admins' version at least 0.7.9?
+               if (isExtensionInstalledAndNewer('admins', '0.7.9')) {
+                       // Create new entry (to all admins)
+                       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (`admin_id`, `mail_template`) VALUES (NULL, '%s')",
+                               array($template), __FUNCTION__, __LINE__);
+               } // END - if
 
                // Select all email adresses (default)
                $result = SQL_QUERY('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC',
@@ -551,6 +554,9 @@ function sendAdminsEmails ($subject, $template, $content, $userid) {
                                        $userid
                                ));
                        }
+
+                       // Abort here as below while() loop will cause problems
+                       return;
                } elseif (($adminId == '0') || (empty($adminId))) {
                        // Select all email adresses
                        $result = SQL_QUERY('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC',
@@ -568,7 +574,7 @@ function sendAdminsEmails ($subject, $template, $content, $userid) {
        // Is the template a bug report?
        if ($template == 'admin_report_bug') {
                // Then set 'Reply-To:' again
-               $mailHeader = 'Reply-To: webmaster@mxchange.org' . chr(10);
+               $mailHeader = 'Reply-To: webmaster@mxchange.org' . PHP_EOL;
        } // END - if
 
        // Load email addresses and send away