X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=8d55ecfb3330bb058f7eda0a3f895f6c714ef03b;hb=49a9663311b732d12ba0c53af2f9eb39a7850fbc;hp=bb31db5bdf8fb718021f3ee35fdd1519659ed79b;hpb=d3ea83baa3f2607db46c26f7d8527c84b994f116;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index bb31db5bdf..8d55ecfb33 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -87,7 +87,7 @@ function addYouAreHereLink ($accessLevel, $FQFN, $return = false) { $file = basename($FQFN); // Init variables - $LINK_ADD = ''; + $linkAdd = ''; $OUT = ''; $ADD = ''; $prefix = ''; @@ -125,13 +125,11 @@ function addYouAreHereLink ($accessLevel, $FQFN, $return = false) { $type = 'what'; $search = $file; $modCheck = getModule(); - $ADD = ''; } else { // Other $type = 'menu'; $search = $file; $modCheck = getModule(); - $ADD = ''; } // Begin the navigation line @@ -140,18 +138,19 @@ function addYouAreHereLink ($accessLevel, $FQFN, $return = false) { $GLOBALS['nav_depth'] = '0'; // Run the pre-filter chain - $ret = runFilterChain('pre_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'search' => $search, 'prefix' => $prefix, 'link_add' => $LINK_ADD, 'content' => '', 'add' => $ADD)); + $ret = runFilterChain('pre_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'search' => $search, 'prefix' => $prefix, 'link_add' => $linkAdd, 'content' => '', 'add' => $ADD)); // Add pre-content $prefix = $ret['content']; // Add default content - $prefix .= '
{--YOU_ARE_HERE--} Home'; + $prefix .= '
{--YOU_ARE_HERE--} Home'; } elseif ($return === false) { // Count depth $GLOBALS['nav_depth']++; } + // Add arrow $prefix .= ' -> '; // We need to remove .php and the end @@ -160,19 +159,21 @@ function addYouAreHereLink ($accessLevel, $FQFN, $return = false) { $search = substr($search, 0, -4); } // END - if + // Is ext-sql_patches installed? + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isExtensionInstalledAndNewer()=' . intval(isExtensionInstalledAndNewer('sql_patches', '0.2.3')) . ',youre_here=' . getConfig('youre_here') . ',isAdmin()=' . intval(isAdmin()) . ',modCheck=' . $modCheck); if (((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (getConfig('youre_here') == 'Y')) || ((isAdmin()) && ($modCheck == 'admin'))) { // Output HTML code - $OUT = $prefix . '' . getTitleFromMenu($accessLevel, $search, $type, $ADD) . ''; + $OUT = $prefix . '' . getTitleFromMenu($accessLevel, $search, $type, $ADD) . ''; // Can we close the you-are-here navigation? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'type=' . $type . 'getWhat()=' . getWhat()); - if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (getWhat() == 'welcome')))) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'type=' . $type . ',getWhat()=' . getWhat() . ',accessLevel=' . $accessLevel . ',isWhatSet()=' . intval(isWhatSet())); + 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'; // Run the post-filter chain - $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'search' => $search, 'prefix' => $prefix, 'link_add' => $LINK_ADD, 'content' => $OUT, 'add' => $ADD)); + $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'search' => $search, 'prefix' => $prefix, 'link_add' => $linkAdd, 'content' => $OUT, 'add' => $ADD)); // Get content from filter back $OUT = $ret['content']; @@ -211,7 +212,11 @@ function addMenu ($mode, $action, $what) { // Load SQL data and add the menu to the output stream... $result_main = SQL_QUERY_ESC("SELECT - `title`,`what`,`action`,`visible`,`locked` + `title`, + `what`, + `action`, + `visible`, + `locked` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE @@ -245,10 +250,13 @@ WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL - ".$ADD." + " . $ADD . " ORDER BY `sort` ASC", - array($mode, $content['action']), __FUNCTION__, __LINE__); + array( + $mode, + $content['action'] + ), __FUNCTION__, __LINE__); // Do we have some entries? if (!SQL_HASZERONUMS($result_sub)) { @@ -415,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? @@ -464,19 +472,22 @@ function fetchUserData ($value, $column = 'userid') { // Secure userid $value = bigintval($value); - // Set it here - setCurrentUserId($value); - // Don't look for invalid userids... 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; @@ -486,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) { @@ -615,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; @@ -663,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. @@ -1304,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 @@ -1794,14 +1807,21 @@ function registerExtensionPointsData ($subject, $columnName, $lockedMode, $payme $add = ''; // Is the extension equal or newer 0.8.9? - if ((getExtensionMode() == 'register') || (getExtensionMode() == 'update') || (isExtensionInstalledAndNewer('sql_patches', '0.8.9'))) { + if (((isInstallationPhase()) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (isExtensionInstalledAndNewer('sql_patches', '0.8.9'))) { // Then add provider $add = " AND `account_provider`='EXTENSION'"; } // END - if // Is the 'subject' there? - if (((!ifSqlTableExist('points_data')) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 0)) { - // Not found so add an SQL query + //* 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()])) && (!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 + + // ... add an SQL query addExtensionSql(sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('%s','%s','%s','%s')", $subject, $columnName,