]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Removed already no longer used last parameter from addMaxReceiveList(), so more EL...
[mailer.git] / inc / mysql-manager.php
index d97d33d37fd9899ef59c376b858fcc3c557cdc8c..8d55ecfb3330bb058f7eda0a3f895f6c714ef03b 100644 (file)
@@ -423,7 +423,7 @@ function isMember () {
        // Init user data array
        initUserData();
 
-       // Fix "deleted" cookies first
+       // Fix "deleted" cookies
        fixDeletedCookies(array('userid', 'u_hash'));
 
        // Are cookies set and can the member data be loaded?
@@ -476,12 +476,18 @@ function fetchUserData ($value, $column = 'userid') {
                if (!isValidUserId($value)) {
                        // Invalid, so abort here
                        reportBug(__FUNCTION__, __LINE__, 'User id ' . $value . ' is invalid.');
+               } // END - if
+
+               // Unset cached values if found and different
+               if ((isCurrentUserIdSet()) && (getCurrentUserId() != $value)) {
+                       // Unset it
+                       unsetCurrentUserId();
                } elseif (isUserDataValid()) {
                        // Use cache, so it is fine
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' is valid, using cache #1');
                        return true;
-               }
-       } elseif (isUserDataValid())  {
+               } // END - if
+       } elseif (isUserDataValid()) {
                // Using cache is fine
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' is valid, using cache #2');
                return true;
@@ -623,7 +629,7 @@ function isAdmin () {
 }
 
 // Generates a list of "max receiveable emails per day"
-function addMaxReceiveList ($mode, $default = '', $return = false) {
+function addMaxReceiveList ($mode, $default = '') {
        $OUT = '';
        $result = false;
 
@@ -671,13 +677,8 @@ function addMaxReceiveList ($mode, $default = '', $return = false) {
        // Free result
        SQL_FREERESULT($result);
 
-       if ($return === true) {
-               // Return generated HTML code
-               return $OUT;
-       } else {
-               // Output directly (default)
-               outputHtml($OUT);
-       }
+       // Return generated HTML code
+       return $OUT;
 }
 
 // Checks whether the given email address is used.
@@ -1312,18 +1313,18 @@ function getAdminMenuMode ($adminId) {
 }
 
 // Generates an option list from various parameters
-function generateOptions ($table, $id, $name, $default = '', $special = '', $whereStatement = '', $disabled = array(), $callback = '') {
+function generateOptions ($table, $key, $value, $default = '', $extra = '', $whereStatement = '', $disabled = array(), $callback = '') {
        $ret = '';
        if ($table == '/ARRAY/') {
                // Selection from array
-               if ((is_array($id)) && (is_array($name)) && ((count($id)) == (count($name)) || (!empty($callback)))) {
+               if ((is_array($key)) && (is_array($value)) && ((count($key)) == (count($value)) || (!empty($callback)))) {
                        // Both are arrays
-                       foreach ($id as $idx => $value) {
-                               $ret .= '<option value="' . $value . '"';
-                               if ($default == $value) {
+                       foreach ($key as $idx => $optionValue) {
+                               $ret .= '<option value="' . $optionValue . '"';
+                               if ($default == $optionValue) {
                                        // Selected by default
                                        $ret .= ' selected="selected"';
-                               } elseif (isset($disabled[$value])) {
+                               } elseif (isset($disabled[$optionValue])) {
                                        // Disabled!
                                        $ret .= ' disabled="disabled"';
                                }
@@ -1331,65 +1332,69 @@ function generateOptions ($table, $id, $name, $default = '', $special = '', $whe
                                // Is the call-back function set?
                                if (!empty($callback)) {
                                        // Call it
-                                       $name[$idx] = call_user_func_array($callback, array($id[$idx]));
+                                       $value[$idx] = call_user_func_array($callback, array($key[$idx]));
                                } // END - if
 
                                // Finish option tag
-                               $ret .= '>' . $name[$idx] . '</option>';
+                               $ret .= '>' . $value[$idx] . '</option>';
                        } // END - foreach
                } else {
                        // Problem in request
-                       reportBug(__FUNCTION__, __LINE__, 'Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name) . ',callback=' . $callback);
+                       reportBug(__FUNCTION__, __LINE__, 'Not all are arrays: key[' . count($key) . ']=' . gettype($key) . ',value[' . count($value) . ']=' . gettype($value) . ',callback=' . $callback);
                }
        } else {
-               // Data from database
-               $SPEC = ',`' . $id . '`';
-               if (!empty($special)) {
-                       $SPEC = ',`' . $special . '` AS `special`';
+           ///////////////////////
+               // Data from database /
+               ///////////////////////
+
+               // Init extra column (if requested)
+               $extraColumn = '';
+               if (!empty($extra)) {
+                       $extraColumn = ',`' . $extra . '` AS `extra`';
                } // END - if
 
-               // Query the database
-               $result = SQL_QUERY_ESC("SELECT `%s` AS `id`,`%s` AS `name`".$SPEC." FROM `{?_MYSQL_PREFIX?}_%s` ".$whereStatement." ORDER BY `%s` ASC",
+               // Run SQL query
+               $result = SQL_QUERY_ESC("SELECT `%s` AS `key`,`%s` AS `value`" . $extraColumn . " FROM `{?_MYSQL_PREFIX?}_%s` " . $whereStatement . " ORDER BY `%s` ASC",
                        array(
-                               $id,
-                               $name,
+                               $key,
+                               $value,
                                $table,
-                               $name
+                               $value
                        ), __FUNCTION__, __LINE__);
 
                // Do we have rows?
                if (!SQL_HASZERONUMS($result)) {
                        // Found data so add them as OPTION lines
                        while ($content = SQL_FETCHARRAY($result)) {
-                               // Is special set?
-                               if (!isset($content['special'])) {
+                               // Is extra set?
+                               if (!isset($content['extra'])) {
                                        // Set it to empty
-                                       $content['special'] = '';
+                                       $content['extra'] = '';
                                } // END - if
 
-                               $ret .= '<option value="' . $content['id'] . '"';
+                               $ret .= '<option value="' . $content['key'] . '"';
 
-                               if ($default == $content['id']) {
+                               if ($default == $content['key']) {
                                        // Selected by default
                                        $ret .= ' selected="selected"';
-                               } elseif (isset($disabled[$content['id']])) {
+                               } elseif (isset($disabled[$content['key']])) {
                                        // Disabled!
                                        $ret .= ' disabled="disabled"';
                                }
 
                                // Add it, if set
-                               if (!empty($content['special'])) {
-                                       $content['special'] = ' (' . $content['special'] . ')';
+                               if (!empty($content['extra'])) {
+                                       $content['extra'] = ' (' . $content['extra'] . ')';
                                } // END - if
 
                                // Is the call-back function set?
                                if (!empty($callback)) {
                                        // Call it
-                                       $content['name'] = call_user_func_array($callback, array($content['name']));
+                                       $content['value'] = call_user_func_array($callback, array($content['value']));
                                } // END - if
 
                                // Finish option list
-                               $ret .= '>' . $content['name'] . $content['special'] . '</option>';
+                               $ret .= '>' . $content['value'] . $content['extra'] . '</option>';
                        } // END - while
                } else {
                        // No data found