X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=8d55ecfb3330bb058f7eda0a3f895f6c714ef03b;hb=49a9663311b732d12ba0c53af2f9eb39a7850fbc;hp=85591a9fc2c329912cd369c8cb803ba7946eba4f;hpb=73269492aee20bde51abbe872ea4d1e1220ee629;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 85591a9fc2..8d55ecfb33 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -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 .= ''; } // 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 .= ''; } // 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