From de318c2b4c5b20c8423144a14cf26d6b8694c128 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 28 Jan 2011 05:37:18 +0000 Subject: [PATCH] Some more fixes and dependency between bonus<->sql_patches --- inc/db/lib-mysql3.php | 17 +++++++++-------- inc/extensions-functions.php | 10 +++++----- inc/extensions/ext-autopurge.php | 8 ++++---- inc/extensions/ext-beg.php | 2 +- inc/extensions/ext-bonus.php | 26 ++++++++++++++++++++------ inc/extensions/ext-nickname.php | 4 ++-- inc/extensions/ext-register.php | 4 ++-- inc/extensions/ext-task.php | 4 ++-- 8 files changed, 45 insertions(+), 30 deletions(-) diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 7a33983a1e..ccf777eb42 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -451,7 +451,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { } // END - if // Shall we run it? - if (!isSqlTableIndexAdded($tableName, $tableArray[3])) { + if (!isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) { // Send it to the SQL_QUERY() function //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql); $result = SQL_QUERY($sql, $F, $L, $enableCodes); @@ -552,23 +552,24 @@ function SQL_PREPARE_SQL_STRING ($sqlString, $enableCodes = true) { } // Check if there is a SQL table created -function isSqlTableCreated ($table) { +function isSqlTableCreated ($tableName) { // Do we have cache? - if (!isset($GLOBALS[__FUNCTION__][$table])) { + if (!isset($GLOBALS[__FUNCTION__][$tableName])) { // Check if the table is there $result = SQL_QUERY_ESC("SHOW TABLES FROM `{?__DB_NAME?}` WHERE `Tables_in_{?__DB_NAME?}`='{?_MYSQL_PREFIX?}_%s'", - array($table), __FILE__, __LINE__); + array($tableName), __FILE__, __LINE__); // Is there an entry? - $GLOBALS[__FUNCTION__][$table] = (SQL_NUMROWS($result) == 1); + $GLOBALS[__FUNCTION__][$tableName] = (SQL_NUMROWS($result) == 1); + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',numRows=' . intval($GLOBALS[__FUNCTION__][$tableName])); } // END - if // Return cache - return $GLOBALS[__FUNCTION__][$table]; + return $GLOBALS[__FUNCTION__][$tableName]; } // Checks depending on the mode if the table is there -function isSqlTableIndexAdded ($tableName, $mode) { +function isSqlTableIndexAdded ($tableName, $mode, $keyName) { // Do we have cache? if (!isset($GLOBALS[__FUNCTION__][$tableName][$mode])) { // Show indexes @@ -580,8 +581,8 @@ function isSqlTableIndexAdded ($tableName, $mode) { // But should we DROP? if ($mode == 'DROP') { // Then skip if nothing found - $GLOBALS[__FUNCTION__][$tableName][$mode] = true; //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Going to drop key ' . $keyName); + $GLOBALS[__FUNCTION__][$tableName][$mode] = true; } // END - if // Walk through all diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index f40643935e..7b3ee31961 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -341,8 +341,8 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $logout = true if ($test === true) { // "Dry-run-mode" activated? if ((isExtensionDryRun() === false) && (!isExtensionOnRemovalList())) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName()); // Init SQLs and transfer ext->generic + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName()); initSqls(); setSqlsArray(getExtensionSqls()); @@ -352,8 +352,8 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $logout = true // Register extension //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'insert=' . getCurrentExtensionName() . '/' . getCurrentExtensionVersion() . ' - INSERT!'); if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',always_active=' . getExtensionAlwaysActive() . ', ext_ver=' . getCurrentExtensionVersion() . 'ext_css=' . getExtensionHasCss()); // New way, with CSS + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',always_active=' . getExtensionAlwaysActive() . ', ext_ver=' . getCurrentExtensionVersion() . 'ext_css=' . getExtensionHasCss()); SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_extensions` (`ext_name`, `ext_active`, `ext_version`,`ext_has_css`) VALUES ('%s','%s','%s','%s')", array( getCurrentExtensionName(), @@ -362,8 +362,8 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $logout = true getExtensionHasCss() ), __FUNCTION__, __LINE__); } else { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',always_active=' . getExtensionAlwaysActive() . ', ext_ver=' . getCurrentExtensionVersion()); // Old way, no CSS + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',always_active=' . getExtensionAlwaysActive() . ', ext_ver=' . getCurrentExtensionVersion()); SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_extensions` (`ext_name`, `ext_active`, `ext_version`) VALUES ('%s','%s','%s')", array( getCurrentExtensionName(), @@ -1006,14 +1006,14 @@ function createNewExtensionTask ($ext_name) { $message = getMaskedMessage('ADMIN_EXTENSION_TEXT_FILE_MISSING', $ext_name); // Template file - $tpl = sprintf("%stemplates/%s/html/ext/ext_%s.tpl", + $FQFN = sprintf("%stemplates/%s/html/ext/ext_%s.tpl", getPath(), getLanguage(), $ext_name ); // Load text for task if found - if (isFileReadable($tpl)) { + if (isFileReadable($FQFN)) { // Load extension's description template (but do not compile the code) $message = loadTemplate('ext_' . $ext_name, true, array(), false); } else { diff --git a/inc/extensions/ext-autopurge.php b/inc/extensions/ext-autopurge.php index 349de0346f..c2d8d5fc9a 100644 --- a/inc/extensions/ext-autopurge.php +++ b/inc/extensions/ext-autopurge.php @@ -56,15 +56,15 @@ switch (getExtensionMode()) { // 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?}_bonus` MODIFY `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` 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("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"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` DROP `ap_notified`"); break; case 'activate': // Do stuff when admin activates this extension diff --git a/inc/extensions/ext-beg.php b/inc/extensions/ext-beg.php index 86cf1b2f8d..6ab978bb00 100644 --- a/inc/extensions/ext-beg.php +++ b/inc/extensions/ext-beg.php @@ -227,7 +227,7 @@ PRIMARY KEY (`id`) break; case '0.2.2': // SQL queries for v0.2.2 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD beg_include_own ENUM('Y','N') NOT NULL DEFAULT 'N'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `beg_include_own` ENUM('Y','N') NOT NULL DEFAULT 'N'"); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Eigene Mitglieder-Ids sind von der Bettel-Rallye nun ausschliessbar."); diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index 3da3ec1cfe..c588e54c9e 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -54,7 +54,7 @@ switch (getExtensionMode()) { // SQL commands to run addAdminMenuSql('email','send_bonus','Bonusmail senden','Versenden Sie hier Bonus-Mails an alle Mitglieder oder nur an alle aus einer Kategorie. Es spielt keine Rolle, wie viele Mails bereits versendet worden, Sie können hier immer senden.', 5); addMemberMenuSql('main','bonus','Bonuspunkte','N','Y',7); - addDropTableSql('bonus`'); + addDropTableSql('bonus'); addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bonus` ( `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `cat_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, @@ -77,7 +77,9 @@ PRIMARY KEY (`id`) addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` ADD INDEX (`bonus_id`)"); // Run this SQL when html_mail extension is installed - if (isExtensionActive('html_mail')) addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus` ADD `html_msg` ENUM('Y','N') NOT NULL DEFAULT 'N'"); + if (isExtensionActive('html_mail')) { + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus` ADD `html_msg` ENUM('Y','N') NOT NULL DEFAULT 'N'"); + } // END - if break; case 'remove': // Do stuff when removing extension @@ -123,6 +125,9 @@ 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'); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `login_bonus` FLOAT(20,3) NOT NULL DEFAULT 10.000"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `turbo_bonus` FLOAT(20,3) NOT NULL DEFAULT 100.000"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `login_timeout` BIGINT(20) UNSIGNED NOT NULL DEFAULT {?ONE_DAY?}"); @@ -363,9 +368,18 @@ INDEX `userid` (`userid`) $mark = mktime(0, 0, 0, $curr, 1, getYear()); // Update accounts which are not active last months - addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_data` -SET `turbo_bonus`=0, `login_bonus`=0, `bonus_order`=0, `bonus_stats`=0, `bonus_ref`=0 -WHERE `last_online` < ".$mark." ORDER BY `userid` ASC"); + addExtensionSql("UPDATE + `{?_MYSQL_PREFIX?}_user_data` +SET + `turbo_bonus`=0, + `login_bonus`=0, + `bonus_order`=0, + `bonus_stats`=0, + `bonus_ref`=0 +WHERE + `last_online` < ".$mark." +ORDER BY + `userid` ASC"); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Ein weiterer Scriptfehler hat nur die Gewinner aus der Aktiv-Rallye genommen. Die anderen Mitglieder sind somit "nach oben gerutsch"."); @@ -498,7 +512,7 @@ WHERE `last_online` < ".$mark." ORDER BY `userid` ASC"); case '0.8.2': // SQL queries for v0.8.2 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD bonus_include_own ENUM('Y','N') NOT NULL DEFAULT 'N'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus` ADD is_notify ENUM('Y','N') NOT NULL DEFAULT 'N'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus` ADD `is_notify` ENUM('Y','N') NOT NULL DEFAULT 'N'"); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Eigene Mitglieder-Ids sind von der Aktiv-Rallye nun ausschliessbar. Benachrichtigungsmails sind von Aktiv-Rallye ausgeschlossen."); diff --git a/inc/extensions/ext-nickname.php b/inc/extensions/ext-nickname.php index 006f6c36ed..52aa5e12d2 100644 --- a/inc/extensions/ext-nickname.php +++ b/inc/extensions/ext-nickname.php @@ -74,11 +74,11 @@ switch (getExtensionMode()) { case 'update': // Update an extension switch (getCurrentExtensionVersion()) { case '0.0.1': // SQL queries for v0.0.1 - addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET ext_has_css='Y' WHERE `ext_name`='nickname' AND ext_has_css='N' LIMIT 1"); - // This update depends on sql_patches update! addExtensionDependency('sql_patches'); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_has_css`='Y' WHERE `ext_name`='nickname' AND `ext_has_css`='N' LIMIT 1"); + // Update notes (these will be set as task text!) setExtensionUpdateNotes("CSS-Datei kann per Adminbereich ein- und ausgeschaltet werden."); break; diff --git a/inc/extensions/ext-register.php b/inc/extensions/ext-register.php index e267db6437..3d6815ece5 100644 --- a/inc/extensions/ext-register.php +++ b/inc/extensions/ext-register.php @@ -98,11 +98,11 @@ PRIMARY KEY (`id`) break; case '0.1.1': // SQL queries for v0.1.1 - addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET ext_has_css='Y' WHERE `ext_name`='register' AND ext_has_css='N' LIMIT 1"); - // This update depends on sql_patches update! addExtensionDependency('sql_patches'); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_has_css`='Y' WHERE `ext_name`='register' AND `ext_has_css`='N' LIMIT 1"); + // Update notes (these will be set as task text!) setExtensionUpdateNotes("CSS-Datei kann per Admin-Bereich ein- und ausgeschaltet werden."); break; diff --git a/inc/extensions/ext-task.php b/inc/extensions/ext-task.php index 2b43107b56..f89b57d379 100644 --- a/inc/extensions/ext-task.php +++ b/inc/extensions/ext-task.php @@ -75,11 +75,11 @@ switch (getExtensionMode()) { case 'update': // Update an extension switch (getCurrentExtensionVersion()) { case '0.0.1': // SQL queries for v0.0.1 - addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET ext_has_css='Y' WHERE `ext_name`='task' AND ext_has_css='N' LIMIT 1"); - // This update depends on sql_patches update! addExtensionDependency('sql_patches'); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_has_css`='Y' WHERE `ext_name`='task' AND `ext_has_css`='N' LIMIT 1"); + // Update notes (these will be set as task text!) setExtensionUpdateNotes("CSS-Datei kann per Admin-Bereich ein- und ausgeschaltet werden."); break; -- 2.39.2