]> 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 85591a9fc2c329912cd369c8cb803ba7946eba4f..8d55ecfb3330bb058f7eda0a3f895f6c714ef03b 100644 (file)
@@ -167,7 +167,7 @@ function addYouAreHereLink ($accessLevel, $FQFN, $return = false) {
 
                // Can we close the you-are-here navigation?
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'type=' . $type . ',getWhat()=' . getWhat() . ',accessLevel=' . $accessLevel . ',isWhatSet()=' . intval(isWhatSet()));
-               if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || ($accessLevel == 'admin')))) {
+               if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (($accessLevel == 'admin') && (getWhat() == 'welcome'))))) {
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'type=' . $type);
                        // Add closing div and br-tag
                        $GLOBALS['nav_depth'] = '0';
@@ -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;
@@ -491,11 +497,14 @@ function fetchUserData ($value, $column = 'userid') {
        $found = false;
 
        // Extra SQL statements
-       $ADD = runFilterChain('convert_user_data_columns', '');
+       $ADD = runFilterChain('convert_user_data_columns', ' ');
 
        // Query for the user
        $result = SQL_QUERY_ESC("SELECT *" . $ADD . " FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `%s`='%s' LIMIT 1",
-               array($column, $value), __FUNCTION__, __LINE__);
+               array(
+                       $column,
+                       $value
+               ), __FUNCTION__, __LINE__);
 
        // Do we have a record?
        if (SQL_NUMROWS($result) == 1) {
@@ -620,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;
 
@@ -668,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.
@@ -1309,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"';
                                }
@@ -1328,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
@@ -1805,9 +1813,10 @@ function registerExtensionPointsData ($subject, $columnName, $lockedMode, $payme
        } // END - if
 
        // Is the 'subject' there?
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ifSqlTableExists(points_data)=' . ifSqlTableExists('points_data') . ',getExtensionMode()=' . getExtensionMode() . ',add=' . $add);
        if (((!ifSqlTableExists('points_data')) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 0)) {
                // Not found so:
-               if (isset($GLOBALS['previous_extension'][getCurrentExtensionName()])) {
+               if ((isset($GLOBALS['previous_extension'][getCurrentExtensionName()])) && (!ifSqlTableExists('points_data'))) {
                        $dummy = $GLOBALS['previous_extension'][getCurrentExtensionName()];
                        reportBug(__FUNCTION__, __LINE__, 'previous_extension[' . gettype($dummy) . ']=' . $dummy . ',getCurrentExtensionName()=' . getCurrentExtensionName() . ' - Under development, please report this!');
                } // END - if