Some more fixes and dependency between bonus<->sql_patches
authorRoland Häder <roland@mxchange.org>
Fri, 28 Jan 2011 05:37:18 +0000 (05:37 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 28 Jan 2011 05:37:18 +0000 (05:37 +0000)
inc/db/lib-mysql3.php
inc/extensions-functions.php
inc/extensions/ext-autopurge.php
inc/extensions/ext-beg.php
inc/extensions/ext-bonus.php
inc/extensions/ext-nickname.php
inc/extensions/ext-register.php
inc/extensions/ext-task.php

index 7a33983a1ec2d59cb71e9ae08a518dc84280d4c5..ccf777eb426e302cf4bd49168928ea2e649dbc2b 100644 (file)
@@ -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
index f40643935e8825193b1ec427ddb032413f1f89f6..7b3ee31961c1a0f3b1729da51c96639a504a7ddc 100644 (file)
@@ -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 {
index 349de0346f5044369af0f136683f824c7a8ae628..c2d8d5fc9a764e8e7f9c3610e905b459f695c637 100644 (file)
@@ -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
index 86cf1b2f8d329b989fc9b659f07795f210e57e82..6ab978bb00411099729da991c9c025ba58974c14 100644 (file)
@@ -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.");
index 3da3ec1cfe7d8ea4ea6eb37c61c2470a29336df6..c588e54c9e5bb00a5c4b9917f206b9ac3440f87a 100644 (file)
@@ -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&ouml;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 &quot;nach oben gerutsch&quot;.");
@@ -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.");
index 006f6c36ed75bb868e048fb077313b202d01be34..52aa5e12d29279639582353730452d637e1bdd4e 100644 (file)
@@ -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;
index e267db6437dd88a91b07d3e4fd86f5215285a580..3d6815ece544cf0a3d5e54fc2120d461cd0b0571 100644 (file)
@@ -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;
index 2b43107b561b38e108b3710b870a5393331629f3..f89b57d379c25068d2cdfc9f0b0105e3be6ce08c 100644 (file)
@@ -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;