} // 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);
}
// 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
// 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
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());
// 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(),
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(),
$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 {
// 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
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.");
// 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,
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
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?}");
$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".");
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.");
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;
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;
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;