From 5828ff274e4c4e80f479e211f6b291452ded3620 Mon Sep 17 00:00:00 2001 From: quix0r Date: Sun, 3 Jul 2011 21:47:01 +0000 Subject: [PATCH] Countless fixes, ext-grade started: - Extension ext-grade started: First tables created - Countless fixes applied, this includes extension and cache management as well as avoiding around 3 needless SQL queries and badly handled ALTER TABLE queries in db-mysql3.php - TODOs.txt updated --- DOCS/TODOs.txt | 16 +-- inc/classes/cachesystem.class.php | 1 + inc/config-functions.php | 2 +- inc/db/lib-mysql3.php | 24 +++-- inc/extensions-functions.php | 88 ++++++++--------- inc/extensions/ext-admins.php | 2 +- inc/extensions/ext-autopurge.php | 8 +- inc/extensions/ext-beg.php | 12 +-- inc/extensions/ext-bonus.php | 6 +- inc/extensions/ext-cache.php | 12 +-- inc/extensions/ext-coupon.php | 24 +++-- inc/extensions/ext-grade.php | 49 +++++++++- inc/extensions/ext-order.php | 4 +- inc/extensions/ext-sql_patches.php | 63 ++++++++---- inc/extensions/ext-user.php | 3 - inc/filter-functions.php | 11 ++- inc/filter/cache_filter.php | 2 +- inc/filter/coupon_filter.php | 13 +-- inc/filter/online_filter.php | 14 +-- inc/filters.php | 19 ++-- inc/functions.php | 13 +++ inc/language/coupon_de.php | 3 - inc/libs/register_functions.php | 7 +- inc/loader/load-admins.php | 9 +- inc/loader/load-extension.php | 28 ++---- inc/loader/load-refdepths.php | 2 +- inc/loader/load-themes.php | 4 +- inc/modules/admin/admin-inc.php | 19 +++- inc/modules/admin/what-add_rallye.php | 2 +- inc/modules/admin/what-adminedit.php | 2 +- inc/modules/admin/what-config_coupon.php | 10 -- inc/modules/admin/what-config_home.php | 15 ++- inc/modules/admin/what-extensions.php | 13 ++- inc/modules/admin/what-list_admins_acls.php | 2 +- inc/modules/admin/what-list_country.php | 17 ++-- inc/modules/admin/what-list_links.php | 1 - inc/modules/admin/what-unlock_sponsor.php | 2 +- inc/modules/guest/what-sponsor_login.php | 2 +- inc/modules/guest/what-top10.php | 6 +- inc/modules/member/what-categories.php | 10 +- inc/mysql-manager.php | 98 ++++++++++++++----- inc/session.php | 2 +- inc/template-functions.php | 2 +- inc/wrapper-functions.php | 2 +- mailid.php | 2 +- .../de/html/admin/admin_config_coupon.tpl | 45 --------- .../de/html/admin/admin_config_order.tpl | 2 +- .../de/html/admin/admin_config_refid.tpl | 2 +- 48 files changed, 395 insertions(+), 300 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 3e4f77a6cd..f4ede999e5 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -4,7 +4,7 @@ ./beg.php:171: // @TODO Opps, what is missing here??? ./birthday_confirm.php:93: // @TODO Try to rewrite the following unset() ./inc/cache/config-local.php:124:// @TODO Rewrite the following three constants, somehow... -./inc/classes/cachesystem.class.php:504: // @TODO Add support for more types which break in last else-block +./inc/classes/cachesystem.class.php:505: // @TODO Add support for more types which break in last else-block ./inc/config-functions.php:136: // @TODO Make this all better... :-/ ./inc/daily/daily_beg.php:52:// @TODO This should be converted in a daily beg rallye ./inc/daily/daily_birthday.php:95: // @TODO 4 is hard-coded here, should we move it out in config? @@ -35,15 +35,15 @@ ./inc/extensions/ext-network.php:38: * @TODO Yoo!Media: What is LayerAd compared to Layer click? * ./inc/extensions/ext-network.php:93: // @TODO network_type_handle is an internal name and needs documentation ./inc/extensions/ext-newsletter.php:218: // @TODO Move these into configuration -./inc/extensions/ext-order.php:351: // @TODO This should be moved out to inc/daily/ +./inc/extensions/ext-order.php:356: // @TODO This should be moved out to inc/daily/ ./inc/extensions/ext-rallye.php:329: // @TODO Move this code into a hook ./inc/extensions/ext-rallye.php:92: // @TODO Fix config_rallye_prices to list_rallye_prices ./inc/extensions/ext-yoomedia.php:121: // @TODO Can this be moved into a database table? ./inc/extensions/ext-yoomedia.php:54:// @TODO Only deprecated when 'ext-network' is ready! setExtensionDeprecated('Y'); ./inc/extensions-functions.php:155: // @TODO Do we still need this? setExtensionUpdateNotes(''); -./inc/extensions-functions.php:1939:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' +./inc/extensions-functions.php:1931:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' ./inc/extensions-functions.php:424:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) -./inc/extensions-functions.php:554: // @TODO Extension is loaded, what next? +./inc/extensions-functions.php:559: // @TODO Extension is loaded, what next? ./inc/filter/bonus_filter.php:56: // @TODO This query isn't right, it will only update if the user was for a longer time away! ./inc/filter/cache_filter.php:92: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. ./inc/functions.php:1223: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? @@ -125,7 +125,7 @@ ./inc/modules/admin/what-del_email.php:61: // @TODO Unused: cat_id, payment_id ./inc/modules/admin/what-edit_user.php:18: * @TODO Add support for ext-country * ./inc/modules/admin/what-email_stats.php:46:// @TODO Unused at the moment -./inc/modules/admin/what-extensions.php:364: // @TODO Rewrite this to a filter +./inc/modules/admin/what-extensions.php:371: // @TODO Rewrite this to a filter ./inc/modules/admin/what-guest_add.php:129: // @TODO This can be somehow rewritten to a function ./inc/modules/admin/what-guest_add.php:67: // @TODO Cant this be rewritten? ./inc/modules/admin/what-guest_add.php:80: // @TODO This can be somehow rewritten to a function @@ -138,7 +138,7 @@ ./inc/modules/admin/what-list_cats.php:69: // @TODO Rewrite this to countSum.....() function ./inc/modules/admin/what-list_links.php:55: // @TODO Try to rewrite this to a filter ./inc/modules/admin/what-list_links.php:85: // @TODO Find a way to rewrite this. See some lines above for different queries -./inc/modules/admin/what-list_links.php:94: // @TODO Rewrite this to includes/filter +./inc/modules/admin/what-list_links.php:93: // @TODO Rewrite this to includes/filter ./inc/modules/admin/what-list_refs.php:107: // @TODO Try to rewrite some to EL ./inc/modules/admin/what-list_unconfirmed.php:107: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus ./inc/modules/admin/what-list_unconfirmed.php:84: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); @@ -185,8 +185,8 @@ ./inc/mysql-manager.php:1479: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() ./inc/mysql-manager.php:1567: // @TODO Rewrite these lines to a filter ./inc/mysql-manager.php:1591: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1965: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:2009:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1959: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:2003:// @TODO Fix inconsistency between last_module and getWhat() ./inc/mysql-manager.php:368: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/purge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter diff --git a/inc/classes/cachesystem.class.php b/inc/classes/cachesystem.class.php index 8f0b7e7175..aaaebe6052 100644 --- a/inc/classes/cachesystem.class.php +++ b/inc/classes/cachesystem.class.php @@ -333,6 +333,7 @@ class CacheSystem { } // END - if // Remove cache file from system + //* DEBUG: */ debug_report_bug(__METHOD__, __LINE__, 'About to remove ' . basename($this->fqfn) . '!'); removeFile($this->fqfn); // Reset read status diff --git a/inc/config-functions.php b/inc/config-functions.php index 01d538db19..6a89335d85 100644 --- a/inc/config-functions.php +++ b/inc/config-functions.php @@ -218,7 +218,7 @@ function updateOldConfigFile () { $new = strtolower($new); } // END - if - /// ... and write it to the new config + // ... and write it to the new config //* DEBUG: */ debugOutput('function=' . $function . ',new=' . $new . ',comment=' . $comment); changeDataInInclude(getCachePath() . 'config-local.php', $comment, $function . "('" . $oldNew . "', \"", '");', constant($new), 0); //* DEBUG: */ debugOutput('CHANGED!'); diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 6a11f697f1..03f3079edc 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -378,7 +378,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { $tableName = str_replace('`', '', $tableArray[2]); // Debug log - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ',tableName=' . $tableName); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ',tableName=' . $tableName . ',tableArray=
' . print_r($tableArray, true) . '
'); // Shall we add/drop? if (((strpos($sql, 'ADD') !== false) || (strpos($sql, 'DROP') !== false) || (strpos($sql, 'CHANGE') !== false)) && ($noIndex === true)) { @@ -424,14 +424,15 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { // Skip this query silently because InnoDB does not understand fulltext indexes //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,tableName=%s,hasZeroNums=%d,file=%s,line=%s", $sql, $tableName, intval((is_bool($result)) ? 0 : isSqlTableColumnFound($columnName)), $F, $L)); } elseif ($noIndex === false) { - // And column name as well - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableArray=
' . print_r($tableArray, true) . '
'); + // And column name as well without backticks $keyName = str_replace('`', '', $tableArray[5]); + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyName=' . $keyName . ',tableArray=
' . print_r($tableArray, true) . '
'); // Is this "UNIQUE" or so? FULLTEXT has been handled the elseif() block above - if (in_array(strtoupper($keyName), array('INDEX', 'UNIQUE', 'KEY', 'FULLTEXT'))) { + if (in_array(strtoupper($tableArray[4]), array('INDEX', 'UNIQUE', 'KEY', 'FULLTEXT'))) { // Init loop - $begin = 1; $keyName = ','; + $begin = 1; + $keyName = ','; while (strpos($keyName, ',') !== false) { // Use last $keyName = str_replace('`', '', $tableArray[count($tableArray) - $begin]); @@ -447,13 +448,18 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { } // END - if // Shall we run it? - if (!isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) { - // Send it to the SQL_QUERY() function - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql); + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ', tableArray[3]=' . $tableArray[3] . ',keyName=' . $keyName); + if ((!isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) && ($tableArray[3] == 'ADD')) { + // Send it to the SQL_QUERY() function to add it + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql); + $result = SQL_QUERY($sql, $F, $L, $enableCodes); + } elseif ((isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) && ($tableArray[3] == 'DROP')) { + // Send it to the SQL_QUERY() function to drop it + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql); $result = SQL_QUERY($sql, $F, $L, $enableCodes); } else { // Not executed - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not executed: ' . $sql); + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not executed: ' . $sql); } } else { // Other ALTER TABLE query diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 9c270f2ff0..5ed3e89ecf 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -178,7 +178,7 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = fal return true; } -// Registeres an extension and possible update depencies +// Registers an extension and possible update dependencies function registerExtension ($ext_name, $taskId, $dry_run = false) { // Set current extension name //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',task_id=' . $taskId . ',dry_run=' . intval($dry_run) . ' - ENTERED!'); @@ -482,6 +482,7 @@ function doExtensionSqls ($ext_id, $load_mode) { // Check wether the given extension is installed function isExtensionInstalled ($ext_name) { // We don't like empty extension names here + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - ENTERED!'); if (empty($ext_name)) { // Please fix them all debug_report_bug(__FUNCTION__, __LINE__, 'ext_name is empty.'); @@ -493,25 +494,28 @@ function isExtensionInstalled ($ext_name) { // Check if there is a cache entry if (isset($GLOBALS['ext_is_installed'][$ext_name])) { // Use cache built from below queries + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - CACHE!'); $isInstalled = $GLOBALS['ext_is_installed'][$ext_name]; } elseif (isset($GLOBALS['cache_array']['extension']['ext_id'][$ext_name])) { // Found! + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - FOUND!'); $isInstalled = true; // Count cache hits incrementStatsEntry('cache_hits'); } elseif ((isInstallationPhase())) { // Extensions are all inactive/not installed during installation + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - installion phase'); } else { // Look in database $ext_id = getExtensionId($ext_name); - // Log debug message - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Extension ' . $ext_name . ' has ext_id=' . $ext_id); - // Do we have a record? $isInstalled = ($ext_id > 0); + // Log debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_id=' . $ext_id . ',isInstalled=' . intval($isInstalled)); + // Is it installed, then cache the entry if ($isInstalled === true) { // Dummy call (get is okay here) @@ -523,6 +527,7 @@ function isExtensionInstalled ($ext_name) { } // Return status + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',isInstalled=' . intval($isInstalled) . ' - EXIT!'); return $isInstalled; } @@ -620,16 +625,16 @@ function getExtensionVersion ($ext_name, $force = false) { if (SQL_NUMROWS($result) == 1) { // Load entry $data = SQL_FETCHARRAY($result); + + // Set cache + $GLOBALS['cache_array']['extension']['ext_version'][$ext_name] = $data['ext_version']; } elseif (isDebugModeEnabled()) { - // Not found, please report all - debug_report_bug(__FUNCTION__, __LINE__, sprintf(": Cannot find extension %s in database!", $ext_name)); + // Not found, may happen while an extension is uninstalled + logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot find extension %s in database!", $ext_name)); } // Free result SQL_FREERESULT($result); - - // Set cache - $GLOBALS['cache_array']['extension']['ext_version'][$ext_name] = $data['ext_version']; } // Extension version should not be invalid @@ -855,7 +860,7 @@ function getExtensionId ($ext_name) { incrementStatsEntry('cache_hits'); } else { // Load from database - $result = SQL_QUERY_ESC("SELECT `id` AS ext_id FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id` AS `ext_id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", array($ext_name), __FUNCTION__, __LINE__); // Is the entry there? @@ -1218,11 +1223,11 @@ function addExtensionDependency ($updateDepends) { // Is it not yet added? if ((isset($updateDepends, $GLOBALS['ext_running_updates'][getCurrentExtensionName()])) && (in_array($updateDepends, getExtensionUpdatesRunning()))) { /* - * Double-adding isn't fine, too. This may mean that - * addExtensionDependency() was called outside the switch() command in - * the extension's file which requires fixing. + * Double-adding happens when the extension and an update of the same + * extension requires the same other extension again. */ - debug_report_bug(__FUNCTION__, __LINE__, 'updateDepends=' . $updateDepends . ',extensionMode=' . getExtensionMode() . ',currentExtension=' . getCurrentExtensionName() . ' - CALLED TWICE!'); + logDebugMessage(__FUNCTION__, __LINE__, 'updateDepends=' . $updateDepends . ',extensionMode=' . getExtensionMode() . ',currentExtension=' . getCurrentExtensionName() . ' - called twice.'); + return; } // END - if // Add it to the list of extension update depencies map @@ -1634,28 +1639,29 @@ function removeExtensionFromArray () { } // END - if } } // END - foreach + + // Remove from other caches as well + unset($GLOBALS['ext_is_installed'][$ext_name]); + unset($GLOBALS['loaded_extension'][$ext_name]); } // "Getter" for 'extension has a CSS file' (with same name, of course) function getExtensionHasCss () { - // Default is no CSS - $hasCss = 'N'; - - // Construct FQFN for check - $FQFN = sprintf("%stheme/%s/css/%s.css", - getPath(), - getCurrentTheme(), - getCurrentExtensionName() - ); + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__][getCurrentExtensionName()][getCurrentTheme()])) { + // Construct FQFN for check + $FQFN = sprintf("%stheme/%s/css/%s.css", + getPath(), + getCurrentTheme(), + getCurrentExtensionName() + ); - // Is it there? - if (isFileReadable($FQFN)) { - // Readable, so it is there... - $hasCss = 'Y'; + // Is it there? + $GLOBALS[__FUNCTION__][getCurrentExtensionName()][getCurrentTheme()] = convertBooleanToYesNo(isFileReadable($FQFN)); } // END - if // Return it - return $hasCss; + return $GLOBALS[__FUNCTION__][getCurrentExtensionName()][getCurrentTheme()]; } // Checks wether the given extension has a language file @@ -1665,17 +1671,8 @@ function ifExtensionHasLanguageFile ($ext_name) { // Count cache hits incrementStatsEntry('cache_hits'); } else { - // Not readable is default - $readable = 'N'; - - // Is the language file readable for this extension? - if (isLanguageIncludeReadable($ext_name)) { - // Readable - $readable = 'Y'; - } // END - if - - // Put it in cache - $GLOBALS['cache_array']['extension']['ext_lang'][$ext_name] = $readable; + // Determine it and put it in cache + $GLOBALS['cache_array']['extension']['ext_lang'][$ext_name] = convertBooleanToYesNo(isLanguageIncludeReadable($ext_name)); } // Return result @@ -1731,15 +1728,10 @@ function isExtensionFunctionFileReadable ($ext_name) { $funcsInclude = sprintf("inc/libs/%s_functions.php", $ext_name); // Is this include there? - if ((isFileReadable($funcsInclude)) && (!isExtensionLibraryLoaded($ext_name)) && (getExtensionMode() == 'test')) { - // Cache it! - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_func=Y - FOUND!'); - $GLOBALS['cache_array']['extension']['ext_func'][$ext_name] = 'Y'; - } else { - // Cache it! - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_func=N - NOT FOUND!'); - $GLOBALS['cache_array']['extension']['ext_func'][$ext_name] = 'N'; - } + $isIncludeFound = ((isFileReadable($funcsInclude)) && (!isExtensionLibraryLoaded($ext_name)) && (getExtensionMode() == 'test')); + + // And put in cache, converted + $GLOBALS['cache_array']['extension']['ext_func'][$ext_name] = convertBooleanToYesNo($isIncludeFound); } // Return result diff --git a/inc/extensions/ext-admins.php b/inc/extensions/ext-admins.php index efb790295c..965c8335a8 100644 --- a/inc/extensions/ext-admins.php +++ b/inc/extensions/ext-admins.php @@ -118,7 +118,7 @@ PRIMARY KEY (`id`) break; case '0.3.1': // SQL queries for v0.3.1 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins_acls` MODIFY id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins_acls` CHANGE `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT"); break; case '0.4.0': // SQL queries for v0.4.0 diff --git a/inc/extensions/ext-autopurge.php b/inc/extensions/ext-autopurge.php index a92b734c67..1fc0951f73 100644 --- a/inc/extensions/ext-autopurge.php +++ b/inc/extensions/ext-autopurge.php @@ -55,14 +55,14 @@ switch (getExtensionMode()) { addExtensionDependency('bonus'); // SQL commands to run - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_pool` MODIFY data_type ENUM('TEMP','SEND','NEW','ADMIN','ACTIVE','DELETED') NOT NULL DEFAULT 'TEMP'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus` MODIFY `data_type` ENUM('NEW','QUEUE','SEND','DELETED') NOT NULL DEFAULT 'NEW'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_pool` CHANGE `data_type` `data_type` ENUM('TEMP','SEND','NEW','ADMIN','ACTIVE','DELETED') NOT NULL DEFAULT 'TEMP'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus` CHANGE `data_type` ENUM('NEW','QUEUE','SEND','DELETED') NOT NULL DEFAULT 'NEW'"); break; case 'remove': // Do stuff when removing extension // SQL commands to run - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_pool` MODIFY `data_type` ENUM('TEMP','SEND','NEW','ADMIN','ACTIVE') NOT NULL DEFAULT 'TEMP'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus` MODIFY `data_type` ENUM('NEW','QUEUE','SEND') NOT NULL DEFAULT 'NEW'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_pool` CHANGE `data_type` `data_type` ENUM('TEMP','SEND','NEW','ADMIN','ACTIVE') NOT NULL DEFAULT 'TEMP'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus` CHANGE `data_type` `data_type` ENUM('NEW','QUEUE','SEND') NOT NULL DEFAULT 'NEW'"); addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('config_autopurge','list_autopurge')"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` DROP `ap_notified`"); break; diff --git a/inc/extensions/ext-beg.php b/inc/extensions/ext-beg.php index 069bd9de86..59a28de5a8 100644 --- a/inc/extensions/ext-beg.php +++ b/inc/extensions/ext-beg.php @@ -159,11 +159,9 @@ PRIMARY KEY (`id`) addConfigAddSql('beg_rallye', "ENUM('Y','N') NOT NULL DEFAULT 'N'"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `beg_points` FLOAT(21,5) UNSIGNED NOT NULL DEFAULT 0.00000"); - $visible = 'N'; $locked = 'Y'; - if (isExtensionActive('beg')) { - $visible = 'Y'; - $locked = 'N'; - } // END - if + // Determine if menu entries are locked and/or visible to the user + $visible = convertBooleanToYesNo(isExtensionActive('beg')); + $locked = convertBooleanToYesNo(!isExtensionActive('beg')); addMemberMenuSql('main','beg2','Bettel-Rallye', $visible, $locked, 7); addAdminMenuSql('user','list_beg','Bettel-Rallye','Listet alle Teilnehmer der monatlichen Bettel-Rallye auf.','12'); @@ -311,7 +309,9 @@ INDEX (`userid`) case 'init': // When extension is initialized // Remove old entries $OLD = getBegTimeout(); - if (getBegUseridTimeout() > $OLD) $OLD = getBegUseridTimeout(); + if (getBegUseridTimeout() > $OLD) { + $OLD = getBegUseridTimeout(); + } // END - if SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE (UNIX_TIMESTAMP() - `timeout`) >= ' . ($OLD + 60*60) . '', __FILE__, __LINE__); // Check for beg rallye is active and send mails out diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index 553388d744..e7e5e68e46 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -72,7 +72,7 @@ switch (getExtensionMode()) { KEY (`cat_id`), PRIMARY KEY (`id`) ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Bonus mails'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` MODIFY `link_type` ENUM('NORMAL','BONUS') NOT NULL DEFAULT 'NORMAL'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `link_type` `link_type` ENUM('NORMAL','BONUS') NOT NULL DEFAULT 'NORMAL'"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` ADD `bonus_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` ADD INDEX (`bonus_id`)"); @@ -125,8 +125,8 @@ PRIMARY KEY (`id`) break; case '0.2.1': // SQL queries for v0.2.1 - // Add extension dependency because of the update command - addExtensionDependency('sql_patches'); + // Add extension dependency to ex-tuser because of the ALTER command + addExtensionDependency('user'); addConfigAddSql('login_bonus', 'FLOAT(20,3) NOT NULL DEFAULT 10.000'); addConfigAddSql('turbo_bonus', 'FLOAT(20,3) NOT NULL DEFAULT 100.000'); diff --git a/inc/extensions/ext-cache.php b/inc/extensions/ext-cache.php index ee324dcf1c..fe584e1459 100644 --- a/inc/extensions/ext-cache.php +++ b/inc/extensions/ext-cache.php @@ -100,14 +100,8 @@ switch (getExtensionMode()) { break; case '0.0.4': // SQL queries for v0.0.4 - // Is the cache extension itself there? - if (isExtensionActive('cache')) { - // Check for cache when extension is already installed - if ($GLOBALS['cache_instance']->loadCacheFile('extension')) $GLOBALS['cache_instance']->removeCacheFile(); - } // END - if - // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Spalte "keep_active" ist hinzugefügt. Cache wurde reinitialisiert."); + setExtensionUpdateNotes("Spalte "keep_active" ist hinzugefügt."); break; case '0.0.5': // SQL queries for v0.0.5 @@ -249,7 +243,7 @@ switch (getExtensionMode()) { // Update notes (these will be set as task text!) setExtensionUpdateNotes("Daten von gefundenen Sprachdateien werden zu den Erweiterungen gecacht."); break; - } + } // END - switch break; case 'modify': // When the extension got modified @@ -264,7 +258,7 @@ switch (getExtensionMode()) { default: // Unknown extension mode logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName())); break; -} +} // END - switch // [EOF] ?> diff --git a/inc/extensions/ext-coupon.php b/inc/extensions/ext-coupon.php index b092481bb7..7f9ab18d82 100644 --- a/inc/extensions/ext-coupon.php +++ b/inc/extensions/ext-coupon.php @@ -43,14 +43,14 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.0.0'); +setThisExtensionVersion('0.0.1'); // Version history array (add more with , '0.1' and so on) -setExtensionVersionHistory(array('0.0.0')); +setExtensionVersionHistory(array('0.0.0', '0.0.1')); switch (getExtensionMode()) { case 'register': // Do stuff when installtion is running - // This extension requires an up-to-date user + // This extension requires an up-to-date ext-user addExtensionDependency('user'); // Coupon data @@ -62,7 +62,7 @@ switch (getExtensionMode()) { `coupon_type` ENUM('CODE','API') NOT NULL DEFAULT 'CODE', `total_created` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `total_cashed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -`points` FLOAT(20,5) NOT NULL DEFAULT 0.00000, +`points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, `coupon_description` TEXT, PRIMARY KEY (`id`) ) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Created coupons'"); @@ -82,10 +82,7 @@ UNIQUE KEY (`coupon_code`) // Configuration entries addConfigAddSql('coupon_default_time', 'BIGINT(20) NOT NULL DEFAULT ' . (getOneDay() * 7)); - addConfigAddSql('coupon_default_points', 'FLOAT(20,5) NOT NULL DEFAULT 100.00000'); - addConfigAddSql('coupon_points_account', "ENUM('ORDER','GENERAL') NOT NULL DEFAULT 'ORDER'"); - addConfigAddSql('coupon_payment_method', "ENUM('DIRECT','REF') NOT NULL DEFAULT 'DIRECT'"); - addConfigAddSql('coupon_locked_points_mode', "ENUM('LOCKED','UNLOCKED') NOT NULL DEFAULT 'LOCKED'"); + addConfigAddSql('coupon_default_points', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 100.00000'); addConfigAddSql('coupon_autopurge_time', 'BIGINT(20) NOT NULL DEFAULT ' . (getOneDay() * 7)); addConfigAddSql('coupon_userid', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0'); @@ -131,7 +128,16 @@ UNIQUE KEY (`coupon_code`) case 'update': // Update an extension switch (getCurrentExtensionVersion()) { case '0.0.1': // SQL queries for v0.0.1 - addExtensionSql(''); + addConfigDropSql('coupon_points_account'); + addConfigDropSql('coupon_payment_method'); + addConfigDropSql('coupon_locked_points_mode'); + + // This extension's update requires an up-to-date ext-sql_patches and ext-order + addExtensionDependency('sql_patches'); + addExtensionDependency('order'); + + // Insert data in new table + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`ext_name`,`column_name`,`locked_mode`,`payment_method`) VALUES('coupon','order_points','LOCKED','DIRECT')"); // Update notes (these will be set as task text!) setExtensionUpdateNotes(''); diff --git a/inc/extensions/ext-grade.php b/inc/extensions/ext-grade.php index aa953614e6..750c41fba8 100644 --- a/inc/extensions/ext-grade.php +++ b/inc/extensions/ext-grade.php @@ -51,11 +51,58 @@ enableExtensionProductive(false); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running - // SQL commands to run + // General and grade level data + addDropTableSql('grade_data'); + addCreateTableSql('grade_data', "( +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`grade_name` VARCHAR(255) NOT NULL DEFAULT '', +`grade_parent_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL, +PRIMARY KEY (`id`), +INDEX (`grade_parent_id`) +) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade general data'"); + + // Data for if a grade level has been reached + addDropTableSql('grade_cash_data'); + addCreateTableSql('grade_cash_data', "( +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`grade_cash_name` VARCHAR(255) NOT NULL DEFAULT '', +`grade_cash_type` ENUM('DISCOUNT','BONUS') NOT NULL DEFAULT 'DISCOUNT', +`reached_points` FLOAT(20,5) UNSIGNED NULL DEFAULT NULL, +`reached_mails` BIGINT(20) UNSIGNED NULL DEFAULT NULL, +`time_valid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +PRIMARY KEY (`id`), +) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade data if the grade have been \"cashed\"'"); + + // Connection grade<->cash data + addDropTableSql('grade_cash_connect'); + addCreateTableSql('grade_cash_conenct', "( +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`grade_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`grade_cash_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +PRIMARY KEY (`id`), +UNIQUE KEY `grade_cash` (`grade_id`, `grade_cash_id`), +INDEX (`grade_cash_id`) +) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade<->cash data connection'"); + + // Connection grade<->user data + addDropTableSql('grade_user_connect'); + addCreateTableSql('grade_user_connect', "( +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`grade_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`grade_expired TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', +PRIMARY KEY (`id`), +UNIQUE KEY (`userid`, `grade_id`), +INDEX (`grade_id`) +) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade<->user connection'"); break; case 'remove': // Do stuff when removing extension // SQL commands to run + addDropTableSql('grade_data'); + addDropTableSql('grade_cash_data'); + addDropTableSql('grade_cash_connect'); + addDropTableSql('grade_user_connect'); break; case 'activate': // Do stuff when admin activates this extension diff --git a/inc/extensions/ext-order.php b/inc/extensions/ext-order.php index 97256d5ccf..c730ffb8c3 100644 --- a/inc/extensions/ext-order.php +++ b/inc/extensions/ext-order.php @@ -329,8 +329,8 @@ INDEX (`pool_id`) break; case '0.5.3': // SQL queries for v0.5.3 - addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `order_points` FLOAT(20,5) NOT NULL DEFAULT 0.00000'); - addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `locked_order_points` FLOAT(20,5) NOT NULL DEFAULT 0.00000'); + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `order_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000'); + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `locked_order_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000'); // This update depends on ext-user addExtensionDependency('user'); diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index 41b96a4ef7..aadb6f7534 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.7.9'); +setThisExtensionVersion('0.8.0'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9')); +setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9', '0.8.0')); // Keep this extension always active! setExtensionAlwaysActive('Y'); @@ -60,21 +60,26 @@ switch (getExtensionMode()) { addDropTableSql('admin_menu_las'); addDropTableSql('admin_menu_las_data'); addDropTableSql('admin_las_stats'); - addDropTableSql('filters'); addDropTableSql('dns_cache'); // Delete admin menu entries - addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE -`what`='config_extensions' OR -`what`='config_home' OR -`what`='list_unconfirmed' OR -`what`='config_refid' OR -`what`='config_title' OR -`what`='sub_points' OR -`what`='config_admin' OR -`what`='config_proxy' OR -`what`='config_session' OR -`what`='list_filter'"); + addExtensionSql("DELETE LOW_PRIORITY FROM + `{?_MYSQL_PREFIX?}_admin_menu` +WHERE + `what` +IN ( + 'config_extensions', + 'config_home', + 'list_unconfirmed', + 'config_refid', + 'config_title', + 'sub_points', + 'config_admin', + 'config_proxy', + 'config_session', + 'list_filter', + 'list_point_accounts' +)"); // Delete/update member menu entries addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE @@ -209,7 +214,7 @@ switch (getExtensionMode()) { break; case '0.1.5': // SQL queries for v0.1.5 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_extensions` DROP ext_has_admin"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_extensions` DROP `ext_has_admin`"); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Spalte ext_has_admin aus der Tabelle {?_MYSQL_PREFIX?}_extensions entfernt, da sie keinen Sinn mehr macht."); @@ -445,7 +450,7 @@ PRIMARY KEY (`id`) case '0.3.6': // SQL queries for v0.3.6 addConfigAddSql('salt_length', 'TINYINT(3) UNSIGNED NOT NULL DEFAULT 10'); addConfigAddSql('pass_scramble', "VARCHAR(255) NOT NULL DEFAULT ''"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` MODIFY `password` VARCHAR(255) NOT NULL DEFAULT ''"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` CHANGE `password` `password` VARCHAR(255) NOT NULL DEFAULT ''"); addConfigAddSql('rand_no', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0'); addConfigAddSql('file_hash', "VARCHAR(255) NOT NULL DEFAULT ''"); addConfigAddSql('master_salt', "VARCHAR(255) NOT NULL DEFAULT ''"); @@ -617,9 +622,9 @@ PRIMARY KEY (`id`) break; case '0.5.9': // SQL queries for v0.5.9 - addDropTableSql('filters'); + // Table 'filters' is vital because many functionality depends on it, so don't remove it addCreateTableSql('filters', "( -`filter_id` BIGINT(20) UNSIGNED AUTO_INCREMENT, +`filter_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `filter_name` VARCHAR(50) NOT NULL DEFAULT '', `filter_function` VARCHAR(100) NOT NULL DEFAULT '', `filter_active` ENUM('N','Y') NOT NULL DEFAULT 'Y', @@ -724,7 +729,7 @@ PRIMARY KEY (`filter_id`) `added` DATETIME NOT NULL, PRIMARY KEY (`hostname`), INDEX (`ip`) -) ENGINE = {?_TABLE_TYPE?}"); +) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Cache for DNS requests'"); // Configuration addConfigAddSql('dns_cache_timeout', 'BIGINT(20) NOT NULL DEFAULT ' . (60*60*24)); @@ -802,6 +807,26 @@ INDEX (`ip`) // Update notes (these will be set as task text!) setExtensionUpdateNotes("Adminscript what-config_email.php nach what-list_email_max_rec.php umbenannt."); break; + + case '0.8.0': // SQL queries for v0.8.0 + // Points account data + addDropTableSql('points_data'); + addCreateTableSql('points_data', "( +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`ext_name` VARCHAR(255) NOT NULL DEFAULT '', +`column_name` VARCHAR(255) NOT NULL DEFAULT 'points', +`locked_mode` ENUM('LOCKED','UNLOCKED') NOT NULL DEFAULT 'LOCKED', +`payment_method` ENUM('DIRECT','REF') NOT NULL DEFAULT 'REF', +PRIMARY KEY(`id`), +INDEX (`ext_name`) +) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Points account data'"); + + // Admin menu + addAdminMenuSql('setup','list_point_accounts','Guthabenkonten...','Veralten Sie hier bequem Einstellungen zu den Guthabenkonten.',5); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Tabelle points_data erzeugt, diese soll das {?POINTS?}-Guthaben komplett lenken."); + break; } // END - switch break; diff --git a/inc/extensions/ext-user.php b/inc/extensions/ext-user.php index 0bcac1b6b7..5fdfa40d1b 100644 --- a/inc/extensions/ext-user.php +++ b/inc/extensions/ext-user.php @@ -410,9 +410,6 @@ PRIMARY KEY (`id`) addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `pool_id`=NULL WHERE `pool_id`=0'); addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `userid` IS NULL'); - // This update depends on ext-bonus - addExtensionDependency('bonus'); - // Update notes (these will be set as task text!) setExtensionUpdateNotes("NULL ist wichtiger als 0 und UNSIGNED auch."); break; diff --git a/inc/filter-functions.php b/inc/filter-functions.php index 4d766f980e..0ec69f0fb3 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -58,7 +58,9 @@ function initFilterSystem () { } elseif ((!isInstallationPhase()) && (isExtensionInstalledAndNewer('sql_patches', '0.5.9'))) { // Init add $add = ''; - if (isExtensionINstalledAndNewer('sql_patches', '0.6.0')) $add = ", `filter_counter`"; + if (isExtensionINstalledAndNewer('sql_patches', '0.6.0')) { + $add = ", `filter_counter`"; + } // END - if // Load all filters $result = SQL_QUERY('SELECT @@ -133,6 +135,7 @@ ORDER BY registerFilter('post_extension_installed', 'SOLVE_TASK'); registerFilter('post_extension_installed', 'LOAD_INCLUDES'); registerFilter('post_extension_installed', 'REMOVE_UPDATES'); + registerFilter('post_extension_installed', 'EXTENSION_MARK_INSTALLED'); // Solving tasks registerFilter('solve_task', 'SOLVE_TASK'); @@ -225,7 +228,7 @@ function registerFilter ($filterName, $filterFunction, $silentAbort = true, $for // "Unregisters" a filter from the given chain function unregisterFilter ($F, $L, $filterName, $filterFunction, $force = false, $dry_run = false) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ENTRY: F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',dry_run=' . intval($dry_run) . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',dry_run=' . intval($dry_run) . ' - ENTERED!'); // Extend the filter function name only if not loaded from database if (!isset($GLOBALS['cache_array']['filter']['loaded'][$filterName][$filterFunction])) { @@ -242,11 +245,11 @@ function unregisterFilter ($F, $L, $filterName, $filterFunction, $force = false, // Shall we remove? (default, not while just showing an extension removal) if ($dry_run === false) { // Mark for filter removal - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'REMOVE: F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ' - REMOVE!'); $GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction] = 'R'; } // END - if - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ENTRY: F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',dry_run=' . intval($dry_run) . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',dry_run=' . intval($dry_run) . ' - EXIT!'); } // "Runs" the given filters, filterData is optional and can be any type of data diff --git a/inc/filter/cache_filter.php b/inc/filter/cache_filter.php index dd9d22b7d8..704d3e8f3c 100644 --- a/inc/filter/cache_filter.php +++ b/inc/filter/cache_filter.php @@ -104,7 +104,7 @@ function FILTER_CACHE_DESTROY_ALL ($data) { function FILTER_CACHE_DESTROY_FILTER ($data) { // Skip this step if the cache instance is not there //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); - if ((!isCacheInstanceValid()) || (getConfig('update_filter_usage') != 'Y')) { + if ((!isCacheInstanceValid()) || ((isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') != 'Y'))) { return false; } // END - if diff --git a/inc/filter/coupon_filter.php b/inc/filter/coupon_filter.php index cafe31b95e..098c83ec8f 100644 --- a/inc/filter/coupon_filter.php +++ b/inc/filter/coupon_filter.php @@ -43,17 +43,8 @@ if (!defined('__SECURITY')) { // Filter to change column name for the right "points account" function FILTER_COUPON_CHANGE_POINTS_COLUMN_NAME ($data) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); - // Are the points locked? - if (($data['locked'] === true) && (getConfig('coupon_locked_points_mode') == 'LOCKED')) { - // Locked points may be routed to special account - $data['column'] = 'locked_order_points'; - } elseif (getConfig('coupon_points_account') == 'ORDER') { - // These points should be routed to 'order' account - $data['column'] = 'order_points'; - } else { - // Else all went to general account - $data['column'] = 'points'; - } + // Get the column name from extension's name and 'locked' + $data['column'] = getPointsColumnNameFromExtensionNameLocked('coupon', $data['locked']); // Return data //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); diff --git a/inc/filter/online_filter.php b/inc/filter/online_filter.php index d31c793c63..68e73929e5 100644 --- a/inc/filter/online_filter.php +++ b/inc/filter/online_filter.php @@ -57,20 +57,14 @@ function FILTER_UPDATE_ONLINE_LIST ($data) { // Initialize variables $userid = '0'; - $isMember = 'N'; - $isAdmin = 'N'; - $action = getActionFromModuleWhat(getModule(), getWhat()); + $isMember = convertBooleanToYesNo(isMember()); + $isAdmin = convertBooleanToYesNo(isAdmin()); + $action = getActionFromModuleWhat(getModule(), getWhat()); // Valid userid? if (isMember()) { - // Is valid user + // Is valid user, so get the userid $userid = getMemberId(); - $isMember = 'Y'; - } // END - if - - if (isAdmin()) { - // Is administrator - $isAdmin = 'Y'; } // END - if // Now search for the user diff --git a/inc/filters.php b/inc/filters.php index c8b52da2c8..020521858b 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -61,6 +61,7 @@ function FILTER_FLUSH_FILTERS () { // Is the extension sql_patches updated? if ((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9'))) { // Abort silently here + logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters, sql_patches might be missing. isExtensionInstalled()=' . isExtensionInstalled('sql_patches') . ',isExtensionInstalledAndOlder()=' . isExtensionInstalledAndOlder('sql_patches', '0.5.9')); return false; } // END - if @@ -242,6 +243,7 @@ function FILTER_LOAD_INCLUDES ($pool) { // Filter for running SQL commands function FILTER_RUN_SQLS ($data) { // Debug message + //* DEBUG: */ die('getSqls()=
'.print_r(getSqls(), true).'
ext_update_depends=
'.print_r($GLOBALS['ext_update_depends'], true).'
'); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Entered!'); // Is the array there? @@ -600,16 +602,15 @@ function FILTER_RUN_RESET_INCLUDES () { // Is the config entry set? if (isExtensionInstalledAndNewer('sql_patches', '0.4.2')) { - // Create current week mark - $currWeek = getWeek(); - // Has it changed? - if ((getConfig('last_week') != $currWeek) || (isWeeklyResetDebugEnabled())) { + if (((isConfigEntrySet('last_week')) && (getConfig('last_week') != getWeek())) || (isWeeklyResetDebugEnabled())) { // Include weekly reset scripts mergeIncludePool('reset', getArrayFromDirectory('inc/weekly/', 'weekly_')); // Update config if not in debug mode - if (!isWeeklyResetDebugEnabled()) updateConfiguration('last_week', $currWeek); + if (!isWeeklyResetDebugEnabled()) { + updateConfiguration('last_week', getWeek()); + } // END - if } // END - if // Create current month mark @@ -783,7 +784,7 @@ function FILTER_RUN_HOURLY_RESET () { } // END - if // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D - if (((getConfig('last_hour') != getHour()) || (isDebugResetEnabled())) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestParameterSet('register')) && (!isCssOutputMode())) { + if ((((isConfigEntrySet('last_hour')) && (getConfig('last_hour') != getHour())) || (isDebugResetEnabled())) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestParameterSet('register')) && (!isCssOutputMode())) { // Tell every module we are in reset-mode! doHourly(); } // END - if @@ -1078,5 +1079,11 @@ function FILTER_SET_CURRENT_DATE () { setConfigEntry('START_TDAY', makeTime(0, 0, 0, time())); } +// Filter for marking extension as installed +function FILTER_EXTENSION_MARK_INSTALLED ($data) { + // Mark it as installed + $GLOBALS['ext_is_installed'][$data['ext_name']] = true; +} + // [EOF] ?> diff --git a/inc/functions.php b/inc/functions.php index d8f842c1f4..4b5a7854cb 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2360,6 +2360,19 @@ function getReferalId () { return $GLOBALS['refid']; } +// Converts a boolean variable into 'Y' for true and 'N' for false +function convertBooleanToYesNo ($boolean) { + // Default is 'N' + $converted = 'N'; + if ($boolean === true) { + // Set 'Y' + $converted = 'Y'; + } // END - if + + // Return it + return $converted; +} + //----------------------------------------------------------------------------- // Automatically re-created functions, all taken from user comments on www.php.net //----------------------------------------------------------------------------- diff --git a/inc/language/coupon_de.php b/inc/language/coupon_de.php index 7c1a6d33c7..1974e5cacf 100644 --- a/inc/language/coupon_de.php +++ b/inc/language/coupon_de.php @@ -47,9 +47,6 @@ addMessages(array( 'ADMIN_CONFIG_COUPON_DEFAULT_TIME' => "Zeit, bis Gutscheine ablaufen sollen. Sie können diesen Ausgangswert beim Erstellen von neuen Gutscheinen nachträglich anpassen.", 'ADMIN_CONFIG_COUPON_DEFAULT_POINTS' => "Ausgangsvergütung in {?POINTS?}. Sie können diesen Ausgangswert beim Erstellen von neuen Gutscheinen nachträglich anpassen.", 'ADMIN_CONFIG_COUPON_AUTOPURGE_TIME' => "Dauer bis abgelaufene Gutscheine aus der Datenbank entfernt werden", - 'ADMIN_CONFIG_COUPON_SELECT_PAYMENT_METHOD' => "Soll nur dem Mitglied direkt die Gutschrift aus dem Einlösen von Gutscheinen oder über das Referal-System gutgeschrieben werden?", - 'ADMIN_CONFIG_COUPON_SELECT_POINTS_ACCOUNT' => "Sollen die {?POINTS?} aus den eingelösten Gutscheinen dem allgemeinen oder dem Werbekonto gutgeschrieben werden?", - 'ADMIN_CONFIG_COUPON_SELECT_LOCKED_POINTS_MODE' => "Wenn das Mitglied noch zu bestätigende Mails offen hat, sollen die eingelösten Gutscheine einem gesperrten Konto oder dem oben eingestellten gutgeschrieben werden?", 'ADMIN_CONFIG_COUPON_USERID' => "Mitgliederaccount, von dem die eingelösten {?POINTS?} abgebucht werden sollen:", // Admin - Send coupon to members diff --git a/inc/libs/register_functions.php b/inc/libs/register_functions.php index 2c64352d76..f1c329ea0b 100644 --- a/inc/libs/register_functions.php +++ b/inc/libs/register_functions.php @@ -369,11 +369,14 @@ function doRegistration () { // Write catgories if ((is_array(postRequestParameter('cat'))) && (count(postRequestParameter('cat')))) { - foreach (postRequestParameter('cat') as $cat => $joined) { + foreach (postRequestParameter('cat') as $categoryId => $joined) { if ($joined == 'Y') { // Insert category entry SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_cats` (`userid`, `cat_id`) VALUES (%s, %s)", - array($userid, bigintval($cat)), __FUNCTION__, __LINE__); + array( + $userid, + bigintval($categoryId) + ), __FUNCTION__, __LINE__); } // END - if } // END - foreach } // END - if diff --git a/inc/loader/load-admins.php b/inc/loader/load-admins.php index f769d6b98c..190347f9a3 100644 --- a/inc/loader/load-admins.php +++ b/inc/loader/load-admins.php @@ -140,17 +140,20 @@ if (isExtensionInstalledAndNewer('admins', '0.3')) { $GLOBALS['cache_instance']->removeCacheFile(); unset($GLOBALS['cache_array']['admin_acls']); } - } else { + } elseif (count($GLOBALS['cache_array']['admin_acls']) > 0) { // Nope, cache file is corrupted! $GLOBALS['cache_instance']->removeCacheFile(); unset($GLOBALS['cache_array']['admin_acls']); + } elseif (isDebugModeEnabled()) { + // This may drive a lot messages to the logfile + //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'No entry found in admin_acls to rewrite.'); } } elseif (isHtmlOutputMode()) { // Create cache file here $GLOBALS['cache_instance']->init(); - // Load all modules and their data (column 'id' is no longer required) - $result = SQL_QUERY('SELECT `admin_id`, `action_menu`, `what_menu`, `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` ORDER BY `admin_id` ASC, `action_menu` ASC, `what_menu` ASC', __FILE__, __LINE__); + // Load all admins and their data + $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_admins_acls` ORDER BY `admin_id` ASC, `action_menu` ASC, `what_menu` ASC', __FILE__, __LINE__); // Add all rows while ($content = SQL_FETCHARRAY($result)) { diff --git a/inc/loader/load-extension.php b/inc/loader/load-extension.php index aad9cd0ab7..3922ef4d2d 100644 --- a/inc/loader/load-extension.php +++ b/inc/loader/load-extension.php @@ -61,7 +61,9 @@ if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache // Loop through all foreach ($EXT_DUMMY['ext_name'] as $k => $ext_name) { // Load CSS file - if ($EXT_DUMMY['ext_css'][$k] == 'Y') addExtensionCssFile($ext_name . '.css'); + if ($EXT_DUMMY['ext_css'][$k] == 'Y') { + addExtensionCssFile($ext_name . '.css'); + } // END - if // Load extension file itself if (($EXT_DUMMY['ext_active'][$k] == 'Y') || ($EXT_DUMMY['ext_keep'][$k] == 'Y')) { @@ -136,34 +138,24 @@ if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache // Add more if sql_patches is recent enougth $add = ''; - if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) $add = ", `ext_has_css` AS ext_css"; + if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) { + $add = ', `ext_has_css` AS `ext_css`'; + } // END - if // Load all modules and their data - $result = SQL_QUERY('SELECT `id` AS ext_id, `ext_name`, `ext_active`, `ext_version`'.$add.' FROM `{?_MYSQL_PREFIX?}_extensions` ORDER BY `ext_name` ASC', __FILE__, __LINE__); + $result = SQL_QUERY('SELECT `id` AS `ext_id`, `ext_name`, `ext_active`, `ext_version`' . $add . ' FROM `{?_MYSQL_PREFIX?}_extensions` ORDER BY `ext_name` ASC', __FILE__, __LINE__); while ($content = SQL_FETCHARRAY($result)) { // Load extension loadExtension($content['ext_name'], 'test'); // Get menu entry - $content['ext_menu'] = 'N'; - if (ifModuleHasMenu($content['ext_name'], true)) { - // Extension is a module and has menu... pew! - $content['ext_menu'] = 'Y'; - } // END - if + $content['ext_menu'] = convertBooleanToYesNo(ifModuleHasMenu($content['ext_name'], true)); // Get language entry - $content['ext_lang'] = 'N'; - if (isLanguageIncludeReadable($content['ext_name'])) { - // Readable - $content['ext_lang'] = 'Y'; - } // END - if + $content['ext_lang'] = convertBooleanToYesNo(isLanguageIncludeReadable($content['ext_name'])); // Get function entry - $content['ext_func'] = 'N'; - if (isExtensionFunctionFileReadable($content['ext_name'])) { - // Readable - $content['ext_func'] = 'Y'; - } // END - if + $content['ext_func'] = convertBooleanToYesNo(isExtensionFunctionFileReadable($content['ext_name'])); // Transfer EXT_ALWAYS_ACTIVE flag $content['ext_keep'] = getThisExtensionAlwaysActive(); diff --git a/inc/loader/load-refdepths.php b/inc/loader/load-refdepths.php index e563c8737d..e1a05818aa 100644 --- a/inc/loader/load-refdepths.php +++ b/inc/loader/load-refdepths.php @@ -52,7 +52,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('refdepths')) && ($GLOBALS['cache $GLOBALS['cache_instance']->init(); // Load all modules and their data - $result = SQL_QUERY('SELECT id, level, percents FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY level', __FILE__, __LINE__); + $result = SQL_QUERY('SELECT `id`, `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC', __FILE__, __LINE__); while ($content = SQL_FETCHARRAY($result)) { // Add row to cache file $GLOBALS['cache_instance']->addRow($content); diff --git a/inc/loader/load-themes.php b/inc/loader/load-themes.php index 4461adc71c..d41705652a 100644 --- a/inc/loader/load-themes.php +++ b/inc/loader/load-themes.php @@ -76,9 +76,9 @@ if (($GLOBALS['cache_instance']->loadCacheFile('themes')) && ($GLOBALS['cache_in // Load all themes and their data if (isExtensionInstalledAndNewer('theme', '0.0.7')) { - $result = SQL_QUERY('SELECT id, theme_path, theme_active, theme_ver, theme_name FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id`', __FILE__, __LINE__); + $result = SQL_QUERY('SELECT `id`, `theme_path`, `theme_active`, `theme_ver`, `theme_name` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id` ASC', __FILE__, __LINE__); } else { - $result = SQL_QUERY('SELECT id, theme_path, theme_active, theme_ver FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id`', __FILE__, __LINE__); + $result = SQL_QUERY('SELECT `id`, `theme_path`, `theme_active`, `theme_ver` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id` ASC', __FILE__, __LINE__); } while ($content = SQL_FETCHARRAY($result)) { // Add row to cache file diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 926c89df17..82cb196abe 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -697,7 +697,7 @@ function adminGetMenuMode () { // Change activation status function adminChangeActivationStatus ($IDs, $table, $row, $idRow = 'id') { - $count = '0'; $newStatus = 'Y'; + $count = '0'; if ((is_array($IDs)) && (count($IDs) > 0)) { // "Walk" all through and count them foreach ($IDs as $id => $selected) { @@ -708,7 +708,12 @@ function adminChangeActivationStatus ($IDs, $table, $row, $idRow = 'id') { if (!empty($selected)) { // Determine new status $result = SQL_QUERY_ESC("SELECT %s FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1", - array($row, $table, $idRow, $id), __FUNCTION__, __LINE__); + array( + $row, + $table, + $idRow, + $id + ), __FUNCTION__, __LINE__); // Row found? if (SQL_NUMROWS($result) == 1) { @@ -716,11 +721,17 @@ function adminChangeActivationStatus ($IDs, $table, $row, $idRow = 'id') { list($currStatus) = SQL_FETCHROW($result); // And switch it N<->Y - if ($currStatus == 'Y') $newStatus = 'N'; else $newStatus = 'Y'; + $newStatus = convertBooleanToYesNo(!($currStatus == 'Y')); // Change this status SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s` SET %s='%s' WHERE %s=%s LIMIT 1", - array($table, $row, $newStatus, $idRow, $id), __FUNCTION__, __LINE__); + array( + $table, + $row, + $newStatus, + $idRow, + $id + ), __FUNCTION__, __LINE__); // Count up affected rows $count += SQL_AFFECTEDROWS(); diff --git a/inc/modules/admin/what-add_rallye.php b/inc/modules/admin/what-add_rallye.php index 22bfb3beae..ace68d7486 100644 --- a/inc/modules/admin/what-add_rallye.php +++ b/inc/modules/admin/what-add_rallye.php @@ -49,7 +49,7 @@ if (isFormSent()) { $END = mktime(postRequestParameter('end_hour') , postRequestParameter('end_min') , postRequestParameter('end_sec') , postRequestParameter('end_month') , postRequestParameter('end_day') , postRequestParameter('end_year') ); // Is there already a rallye running? - $result = SQL_QUERY_ESC("SELECT id, admin_id FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE (start_time <= %s AND end_time >= %s) OR (start_time >= %s AND start_time <= %s) LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id`, `admin_id` FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE (`start_time` <= %s AND `end_time` >= %s) OR (`start_time` >= %s AND `start_time` <= %s) LIMIT 1", array($START, $START, $START, $END), __FILE__, __LINE__); if (SQL_HASZERONUMS($result)) { diff --git a/inc/modules/admin/what-adminedit.php b/inc/modules/admin/what-adminedit.php index 05290a1e3b..738f9d01d0 100644 --- a/inc/modules/admin/what-adminedit.php +++ b/inc/modules/admin/what-adminedit.php @@ -189,7 +189,7 @@ LIMIT 1", doAdminProcessMenuWeightning('admin', $AND); // Run SQL - $result = SQL_QUERY("SELECT id, action, what, title, sort FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." ORDER BY `sort` ASC", __FILE__, __LINE__); + $result = SQL_QUERY("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." ORDER BY `sort` ASC", __FILE__, __LINE__); // Do we have entries? if (!SQL_HASZERONUMS($result)) { diff --git a/inc/modules/admin/what-config_coupon.php b/inc/modules/admin/what-config_coupon.php index 36118680ad..cfd0aa9bf8 100644 --- a/inc/modules/admin/what-config_coupon.php +++ b/inc/modules/admin/what-config_coupon.php @@ -53,16 +53,6 @@ if (isFormSent()) { // Add userid selection $content['coupon_userid'] = addMemberSelectionBox(getConfig('coupon_userid'), false, true, true, 'coupon_userid'); - // Init all other template entries - foreach (array('payment_method_ref', 'payment_method_direct', 'points_account_order', 'points_account_general', 'locked_points_mode_locked', 'locked_points_mode_unlocked') as $entry) { - $content['coupon_' . $entry] = ''; - } // END - foreach - - // Set current selections - foreach (array('payment_method', 'points_account', 'locked_points_mode') as $entry) { - $content['coupon_' . $entry . '_' . strtolower(getConfig('coupon_' . $entry))] = ' checked="checked"'; - } // END - foreach - // Prepare some template data $content['coupon_default_time_selection'] = createConfigurationTimeSelections('coupon_default_time' , 'WDh'); $content['coupon_autopurge_time_selection'] = createConfigurationTimeSelections('coupon_autopurge_time', 'WDh'); diff --git a/inc/modules/admin/what-config_home.php b/inc/modules/admin/what-config_home.php index 5810fb04d9..cda95994d6 100644 --- a/inc/modules/admin/what-config_home.php +++ b/inc/modules/admin/what-config_home.php @@ -77,10 +77,17 @@ switch ($sub) { } // END - if // Load all what menu points - $result = SQL_QUERY("SELECT id, what, title -FROM `{?_MYSQL_PREFIX?}_guest_menu` -WHERE `action`='main' AND `what` != '' AND `what` IS NOT NULL AND `locked`='N' -ORDER BY `sort` ASC", __FILE__, __LINE__); + $result = SQL_QUERY("SELECT + `id`, `what`, `title` +FROM + `{?_MYSQL_PREFIX?}_guest_menu` +WHERE + `action`='main' AND + `what` != '' AND + `what` IS NOT NULL AND + `locked`='N' +ORDER BY + `sort` ASC", __FILE__, __LINE__); // Init variables $OUT = ''; diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php index 4b9f9a988b..e7bdea2baf 100644 --- a/inc/modules/admin/what-extensions.php +++ b/inc/modules/admin/what-extensions.php @@ -278,7 +278,11 @@ switch ($do) { if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) { // Load extension data with CSS informations $result = SQL_QUERY("SELECT - `id` AS ext_id, `ext_name`, `ext_active`, `ext_has_css` AS ext_css, `ext_version` + `id` AS `ext_id`, + `ext_name`, + `ext_active`, + `ext_has_css` AS `ext_css`, + `ext_version` FROM `{?_MYSQL_PREFIX?}_extensions` ".$where." @@ -287,7 +291,10 @@ ORDER BY } else { // Load extension data without CSS informations $result = SQL_QUERY("SELECT - `id` AS ext_id, `ext_name`, `ext_active`, `ext_version` + `id` AS `ext_id`, + `ext_name`, + `ext_active`, + `ext_version` FROM `{?_MYSQL_PREFIX?}_extensions` ".$where." @@ -303,7 +310,7 @@ ORDER BY // Prepare CSS selection output $cssSelection = '---'; if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) { - $cssSelection = translateYesNo($content['ext_css']); + $cssSelection = '{%pipe,translateYesNo=' . $content['ext_css'] . '%}'; } // END - if // Prepare data for the row template diff --git a/inc/modules/admin/what-list_admins_acls.php b/inc/modules/admin/what-list_admins_acls.php index b5fb48cd43..8924be90af 100644 --- a/inc/modules/admin/what-list_admins_acls.php +++ b/inc/modules/admin/what-list_admins_acls.php @@ -173,7 +173,7 @@ LIMIT 1", if (SQL_HASZERONUMS($result)) { // Finally add the new ACL SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_acls` (`admin_id`, `action_menu`, `what_menu`, `access_mode`) -VALUES ('%s','%s','%s','%s')", +VALUES (%s,'%s','%s','%s')", array( bigintval(postRequestParameter('admin_id')), postRequestParameter('action_menu'), diff --git a/inc/modules/admin/what-list_country.php b/inc/modules/admin/what-list_country.php index 05fe8420bd..31692ad9c5 100644 --- a/inc/modules/admin/what-list_country.php +++ b/inc/modules/admin/what-list_country.php @@ -46,15 +46,15 @@ addYouAreHereLink('admin', __FILE__); // Add new code? if ((isFormSent('add')) && (isPostRequestParameterSet('code')) && (isPostRequestParameterSet('descr'))) { // Check if country code does already exist - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_countries` WHERE code='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_countries` WHERE `code`='%s' LIMIT 1", array(strtoupper(postRequestParameter('code'))), __FILE__, __LINE__); if (SQL_HASZERONUMS($result)) { // Save entry - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_countries` (code, descr, is_active) VALUES ('%s','%s','%s')", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_countries` (`code`, `descr`, `is_active`) VALUES ('%s','%s','%s')", array( - strtoupper(substr(postRequestParameter('code'), 0, 2)), - postRequestParameter('descr'), - postRequestParameter('is_active') + strtoupper(substr(postRequestParameter('code'), 0, 2)), + postRequestParameter('descr'), + postRequestParameter('is_active') ), __FILE__, __LINE__); // Country added @@ -113,7 +113,7 @@ if ((isFormSent('add')) && (isPostRequestParameterSet('code')) && (isPostRequest $content['is_active'] = generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $isActive); } else { // Only display status when in delete-mode - $content['is_active'] = translateYesNo($isActive); + $content['is_active'] = '{%pipe,translateYesNo=' . $isActive . '%}'; } // Insert row template and switch color @@ -136,10 +136,11 @@ if ((isFormSent('add')) && (isPostRequestParameterSet('code')) && (isPostRequest // Load main template loadTemplate('admin_list_country_form', false, $content); - } + } // END - if } else { // Shall we modify / remove entries now? - $message = ''; initSqls(); + $message = ''; + initSqls(); if ((isPostRequestParameterSet('modify')) && (isPostRequestParameterSet('id'))) { // Modify foreach (postRequestParameter('id') as $id => $sel) { diff --git a/inc/modules/admin/what-list_links.php b/inc/modules/admin/what-list_links.php index 46a1f82f1d..367c945f1a 100644 --- a/inc/modules/admin/what-list_links.php +++ b/inc/modules/admin/what-list_links.php @@ -85,7 +85,6 @@ if (isGetRequestParameterSet('userid')) { // @TODO Find a way to rewrite this. See some lines above for different queries while (list($id, $id2, $type) = SQL_FETCHROW($result)) { // Initializes all variables - $cat = ''; $DATA = ''; $PROBLEM = '{--ADMIN_GENERAL_MAIL_PROBLEM--}'; $result_data = false; diff --git a/inc/modules/admin/what-unlock_sponsor.php b/inc/modules/admin/what-unlock_sponsor.php index 3a1852f825..b70f6b73a5 100644 --- a/inc/modules/admin/what-unlock_sponsor.php +++ b/inc/modules/admin/what-unlock_sponsor.php @@ -70,7 +70,7 @@ WHERE LIMIT 1", array($content['id']), __FILE__, __LINE__); - /// Is there an entry? + // Is there an entry? if (SQL_NUMROWS($result_main) == 1) { // Load data $content = SQL_FETCHARRAY($result_main); diff --git a/inc/modules/guest/what-sponsor_login.php b/inc/modules/guest/what-sponsor_login.php index 7082a5cf0c..f6c598620b 100644 --- a/inc/modules/guest/what-sponsor_login.php +++ b/inc/modules/guest/what-sponsor_login.php @@ -136,7 +136,7 @@ LIMIT 1", displayMessage('{--SPONSOR_ACCOUNT_EMAIL_FAILED--}'); } } else { - /// ??? Other status? + // ??? Other status? displayMessage('{--SPONSOR_ACCOUNT_STATUS_FAILED--}'); } } else { diff --git a/inc/modules/guest/what-top10.php b/inc/modules/guest/what-top10.php index a4dc1f524a..ebde2cb86c 100644 --- a/inc/modules/guest/what-top10.php +++ b/inc/modules/guest/what-top10.php @@ -51,7 +51,7 @@ if ((!isExtensionActive('top10')) && (!isAdmin())) { // Init array $rows = array(); -//// TOP logins +// TOP logins $result = SQL_QUERY("SELECT `userid`, `total_logins`, `last_online` FROM @@ -107,7 +107,7 @@ $rows['logins_out'] = $OUT; // Free result SQL_FREERESULT($result); -//// TOP earners +// TOP earners $result = SQL_QUERY("SELECT d.userid, (SUM(p.points) - d.used_points) AS `points`, @@ -171,7 +171,7 @@ $rows['points_out'] = $OUT; // Free result SQL_FREERESULT($result); -//// TOP referal "hunter" +// TOP referal "hunter" $result = SQL_QUERY("SELECT d.userid, SUM(r.counter) AS refs, diff --git a/inc/modules/member/what-categories.php b/inc/modules/member/what-categories.php index 45e79d7492..dad195c708 100644 --- a/inc/modules/member/what-categories.php +++ b/inc/modules/member/what-categories.php @@ -56,7 +56,7 @@ if (!SQL_HASZERONUMS($result)) { $LEAST = false; if (isFormSent()) { $count = '0'; - foreach (postRequestParameter('cat') as $cat => $joined) { + foreach (postRequestParameter('cat') as $categoryId => $joined) { if ($joined != 'Y') $count++; } // END - foreach @@ -72,7 +72,7 @@ if (!SQL_HASZERONUMS($result)) { $count = '0'; // Go through all entries - foreach (postRequestParameter('cat') as $cat => $joined) { + foreach (postRequestParameter('cat') as $categoryId => $joined) { // Ini sql here $sql = ''; @@ -80,10 +80,10 @@ if (!SQL_HASZERONUMS($result)) { switch ($joined) { case 'Y': $result_user = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid`=%s AND `cat_id`=%s LIMIT 1", - array(getMemberId(), bigintval($cat)), __FILE__, __LINE__); + array(getMemberId(), bigintval($categoryId)), __FILE__, __LINE__); // Debug message - //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'cat='.$cat.',joined='.$joined.',getMemberId()='.getMemberId().',SQL_HASZERONUMS()='.intval(SQL_HASZERONUMS($result_user))); + //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'categoryId='.$categoryId.',joined='.$joined.',getMemberId()='.getMemberId().',SQL_HASZERONUMS()='.intval(SQL_HASZERONUMS($result_user))); if (SQL_HASZERONUMS($result_user)) { $sql = "INSERT INTO `{?_MYSQL_PREFIX?}_user_cats` (`userid`, `cat_id`) VALUES (%s,%s)"; @@ -100,7 +100,7 @@ if (!SQL_HASZERONUMS($result)) { if (!empty($sql)) { // Run SQL command - SQL_QUERY_ESC(trim($sql), array(getMemberId(), bigintval($cat)), __FILE__, __LINE__); + SQL_QUERY_ESC(trim($sql), array(getMemberId(), bigintval($categoryId)), __FILE__, __LINE__); // Count this row $count += SQL_AFFECTEDROWS(); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 6df25311c6..45dbbf1a0a 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1738,7 +1738,7 @@ function generateCategoryOptionsList ($mode) { } // Add bonus mail to queue -function addBonusMailToQueue ($subject, $text, $receiverList, $points, $seconds, $url, $cat, $mode='normal', $receiver=0) { +function addBonusMailToQueue ($subject, $text, $receiverList, $points, $seconds, $url, $categoryId, $mode='normal', $receiver=0) { // Is admin or bonus extension there? if (!isAdmin()) { // Abort here @@ -1759,27 +1759,21 @@ function addBonusMailToQueue ($subject, $text, $receiverList, $points, $seconds, // HTML extension active? if (isExtensionActive('html_mail')) { - // No HTML by default - $HTML = 'N'; - - // HTML mode? - if ($mode == 'html') { - // Yes, please - $HTML = 'Y'; - } // END - if + // Determine if we have HTML mode active + $HTML = convertBooleanToYesNo($mode == 'html'); // Add HTML mail SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` (`subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `mails_sent`, `html_msg`) -VALUES ('%s','%s','%s','%s','%s','NEW', UNIX_TIMESTAMP(),'%s','%s','%s','%s','%s')", +VALUES ('%s','%s','%s',%s,%s,'NEW', UNIX_TIMESTAMP(),'%s',%s,%s,%s,'%s')", array( $subject, $text, $receiverList, $points, - $seconds, + bigintval($seconds), $url, - $cat, + bigintval($categoryId), $target, bigintval($receiver), $HTML @@ -1788,15 +1782,15 @@ VALUES ('%s','%s','%s','%s','%s','NEW', UNIX_TIMESTAMP(),'%s','%s','%s','%s','%s // Add regular mail SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` (`subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `mails_sent`) -VALUES ('%s','%s','%s','%s','%s','NEW', UNIX_TIMESTAMP(),'%s','%s','%s','%s')", +VALUES ('%s','%s','%s',%s,%s,'NEW', UNIX_TIMESTAMP(),'%s',%s,%s,%s)", array( $subject, $text, $receiverList, $points, - $seconds, + bigintval($seconds), $url, - $cat, + bigintval($categoryId), $target, bigintval($receiver), ), __FUNCTION__, __LINE__); @@ -1804,7 +1798,7 @@ VALUES ('%s','%s','%s','%s','%s','NEW', UNIX_TIMESTAMP(),'%s','%s','%s','%s')", } // Generate a receiver list for given category and maximum receivers -function generateReceiverList ($cat, $receiver, $mode = '') { +function generateReceiverList ($categoryId, $receiver, $mode = '') { // Init variables $CAT_TABS = ''; $CAT_WHERE = ''; @@ -1812,8 +1806,8 @@ function generateReceiverList ($cat, $receiver, $mode = '') { $result = false; // Secure data - $cat = bigintval($cat); - $receiver = bigintval($receiver); + $categoryId = bigintval($categoryId); + $receiver = bigintval($receiver); // Is the receiver zero and mode set? if (($receiver == '0') && (!empty($mode))) { @@ -1822,10 +1816,10 @@ function generateReceiverList ($cat, $receiver, $mode = '') { } // END - if // Category given? - if ($cat > 0) { + if ($categoryId > 0) { // Select category $CAT_TABS = "LEFT JOIN `{?_MYSQL_PREFIX?}_user_cats` AS c ON d.`userid`=c.`userid`"; - $CAT_WHERE = sprintf(" AND c.`cat_id`=%s", $cat); + $CAT_WHERE = sprintf(" AND c.`cat_id`=%s", $categoryId); } // END - if // Exclude users in holiday? @@ -1836,13 +1830,13 @@ function generateReceiverList ($cat, $receiver, $mode = '') { if ((isExtensionActive('html_mail')) && ($mode == 'html')) { // Only include HTML receivers - $result = SQL_QUERY_ESC("SELECT d.userid FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED' AND d.`html`='Y'".$CAT_WHERE." ORDER BY d.{?order_select?} {?order_mode?} LIMIT %s", + $result = SQL_QUERY_ESC("SELECT d.`userid` FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED' AND d.`html`='Y'".$CAT_WHERE." ORDER BY d.`{?order_select?}` {?order_mode?} LIMIT %s", array( $receiver ), __FUNCTION__, __LINE__); } else { // Include all - $result = SQL_QUERY_ESC("SELECT d.userid FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED'".$CAT_WHERE." ORDER BY d.{?order_select?} {?order_mode?} LIMIT %s", + $result = SQL_QUERY_ESC("SELECT d.`userid` FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED'".$CAT_WHERE." ORDER BY d.`{?order_select?}` {?order_mode?} LIMIT %s", array( $receiver ), __FUNCTION__, __LINE__); @@ -2017,5 +2011,65 @@ function updateLastActivity($userid) { ), __FUNCTION__, __LINE__); } +// Get points data for given extension's name +function getPointsDataArrayFromExtensionName ($ext_name) { + // If we have cache, shortcut it here + if (isset($GLOBALS['cache_array']['points_data'])) { + // Return it + return $GLOBALS['cache_array']['points_data']; + } // END - if + + // Now checkout the entry in database table + $result = SQL_QUERY_ESC("SELECT `id`, `ext_name`, `column_name`, `locked_mode`, `payment_method` FROM `{?_MYSQL_PREFIX?}_points_data` WHERE `ext_name`='%s' LIMIT 1", + array($ext_name), __FUNCTION__, __LINE__); + + // Do we have an entry? + if (SQL_NUMROWS($result) == 1) { + // Then load it + $pointsData = SQL_FETCHARRAY($result); + + // Add all remaining entries + foreach ($pointsData as $key=>$value) { + $GLOBALS['cache_array']['points_data'][$key][$ext_name][$isLocked] = $value; + } // END - foreach + } else { + /* + * Having no entry is not bad but it means that all points will go to + * the general account which the user can let payout. + */ + logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',isLocked=' . intval($isLocked) . ' - No entry found, switching to general points account.'); + } + + // Free result + SQL_FREERESULT($result); + + // Return it + return $GLOBALS['cache_array']['points_data']; +} + +// Determines the right points column name for given extension and 'locked' +function getPointsColumnNameFromExtensionNameLocked ($ext_name, $isLocked) { + // Extension sql_patches must be up-to-date + if (isExtensionInstalledAndOlder('sql_patches', '0.8.0')) { + // Please update ext-sql_patches + debug_report_bug(__FUNCTION__, __LINE__, 'sql_patches is out-dated. Please update to at least 0.8.0 to continue. ext_name=' . $ext_name . ',isLocked=' . intval($isLocked)); + } // END - if + + // Get the points_data entry + $pointsData = getPointsDataArrayFromExtensionName($ext_name); + + // Regular points by default + $columnName = $pointsData['columnName']; + + // Are the points locked? + if (($isLocked === true) && ($pointsData['locked_mode'] == 'LOCKED')) { + // Locked points, so prefix it + $columnName = 'locked_' . $pointsData['column_name']; + } // END - if + + // Return the result + return $columName; +} + // [EOF] ?> diff --git a/inc/session.php b/inc/session.php index b3f6f883ff..e9abd0e7a2 100644 --- a/inc/session.php +++ b/inc/session.php @@ -43,7 +43,7 @@ if (!defined('__SECURITY')) { // Is ext-sql_patches there and newer? if (isExtensionInstalledAndNewer('sql_patches', '0.5.3')) { // Set session save path if set - if (getConfig('session_save_path') != '') { + if ((isConfigEntrySet('session_save_path')) && (getConfig('session_save_path') != '')) { // Please make sure this valid! session_save_path(getConfig('session_save_path')); } // END - if diff --git a/inc/template-functions.php b/inc/template-functions.php index 0c10acd339..7d5e670a2c 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -448,7 +448,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0', $loadU fetchUserData($userid, 'nickname'); } else { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "NO-NICK!
"); - /// Load by userid + // Load by userid fetchUserData($userid); } diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index eb9419c94e..8a4387f00b 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -554,7 +554,7 @@ function isNicknameUsed ($userid) { // Is the cache there if (!isset($GLOBALS[__FUNCTION__][$userid])) { // Determine it - $GLOBALS[__FUNCTION__][$userid] = (('' . round($userid) . '') != $userid); + $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . round($userid) . '') != $userid)); } // END - if // Return the result diff --git a/mailid.php b/mailid.php index 7f1746bdfb..dfefdcac9f 100644 --- a/mailid.php +++ b/mailid.php @@ -106,7 +106,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr redirectOnUninstalledExtension('bonus'); // Bonus-Mails - $result = SQL_QUERY_ESC("SELECT id, url, subject FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id`, `url`, `subject` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1", array($bonusId), __FILE__, __LINE__); break; diff --git a/templates/de/html/admin/admin_config_coupon.tpl b/templates/de/html/admin/admin_config_coupon.tpl index 6d380bcbdc..014a32cf9c 100644 --- a/templates/de/html/admin/admin_config_coupon.tpl +++ b/templates/de/html/admin/admin_config_coupon.tpl @@ -25,51 +25,6 @@ ({?POINTS?}) - - - {--ADMIN_CONFIG_COUPON_SELECT_PAYMENT_METHOD--} - - - - - - {--ADMIN_CONFIG_PAYMENT_MODE_DIRECT--} - - - - {--ADMIN_CONFIG_PAYMENT_MODE_REF--} - - - - - {--ADMIN_CONFIG_COUPON_SELECT_POINTS_ACCOUNT--} - - - - - - {--ADMIN_CONFIG_POINTS_ACCOUNT_ORDER--} - - - - {--ADMIN_CONFIG_POINTS_ACCOUNT_GENERAL--} - - - - - {--ADMIN_CONFIG_COUPON_SELECT_LOCKED_POINTS_MODE--} - - - - - - {--ADMIN_CONFIG_LOCKED_POINTS_MODE_LOCKED--} - - - - {--ADMIN_CONFIG_LOCKED_POINTS_MODE_UNLOCKED--} - - {--ADMIN_CONFIG_COUPON_USERID--}: diff --git a/templates/de/html/admin/admin_config_order.tpl b/templates/de/html/admin/admin_config_order.tpl index 290d541de9..e07ebdff3e 100644 --- a/templates/de/html/admin/admin_config_order.tpl +++ b/templates/de/html/admin/admin_config_order.tpl @@ -3,7 +3,7 @@ diff --git a/templates/de/html/admin/admin_config_refid.tpl b/templates/de/html/admin/admin_config_refid.tpl index 45411ad55f..3ffbe185fd 100644 --- a/templates/de/html/admin/admin_config_refid.tpl +++ b/templates/de/html/admin/admin_config_refid.tpl @@ -41,7 +41,7 @@ - + -- 2.39.2
- {--ADMIN_ORDER_SETTINGS--}: + {--ADMIN_CONFIG_ORDER_TITLE--}:
{--ADMIN_RANDOM_MIN_CONFIRMED--}{--ADMIN_CONFIG_RANDOM_MIN_CONFIRMED--}