$columnName = $tableArray[$idx];
// Debug log
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',idx=' . $idx . ',sql=' . $sql . ',hasZeroNums=' . intval(ifSqlColumnExists($tableName, $columnName)));
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',idx=' . $idx . ',sql=' . $sql . ',hasZeroNums=' . intval(ifSqlTableColumnExists($tableName, $columnName)));
// Is there no entry on ADD or an entry on DROP/CHANGE?
- if (((!ifSqlColumnExists($tableName, $columnName)) && (isInString('ADD', $sql))) || ((ifSqlColumnExists($tableName, $columnName)) && ((isInString('DROP', $sql)) || ((isInString('CHANGE', $sql)) && ($idx == 4) && ((!ifSqlColumnExists($tableName, $tableArray[5])) || ($columnName == $tableArray[5])))))) {
+ if (((!ifSqlTableColumnExists($tableName, $columnName)) && (isInString('ADD', $sql))) || ((ifSqlTableColumnExists($tableName, $columnName)) && ((isInString('DROP', $sql)) || ((isInString('CHANGE', $sql)) && ($idx == 4) && ((!ifSqlTableColumnExists($tableName, $tableArray[5])) || ($columnName == $tableArray[5])))))) {
// Do the query
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Executing: ' . $sql);
$result = SQL_QUERY($sql, $F, $L, FALSE);
// Skip further attempt(s)
break;
- } elseif ((((ifSqlColumnExists($tableName, $columnName)) && (isInString('ADD', $sql))) || ((!ifSqlColumnExists($tableName, $columnName)) && ((isInString('DROP', $sql))) || (isInString('CHANGE', $sql)))) && ($columnName != 'KEY')) {
+ } elseif ((((ifSqlTableColumnExists($tableName, $columnName)) && (isInString('ADD', $sql))) || ((!ifSqlTableColumnExists($tableName, $columnName)) && ((isInString('DROP', $sql))) || (isInString('CHANGE', $sql)))) && ($columnName != 'KEY')) {
// Abort here because it is alreay there
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: sql=' . $sql . ',columnName=' . $columnName . ',idx=' . $idx);
break;
- } elseif ((!ifSqlColumnExists($tableName, $columnName)) && (isInString('DROP', $sql))) {
+ } elseif ((!ifSqlTableColumnExists($tableName, $columnName)) && (isInString('DROP', $sql))) {
// Abort here because we tried to drop a column which is not there (never created maybe)
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'No drop: ' . $sql);
break;
} elseif ($columnName != 'KEY') {
// Something didn't fit, we better log it
- logDebugMessage(__FUNCTION__, __LINE__, 'Possible problem: ' . $sql . ',hasZeroNums=' . intval(ifSqlColumnExists($tableName, $columnName)) . '');
+ logDebugMessage(__FUNCTION__, __LINE__, 'Possible problem: ' . $sql . ',hasZeroNums=' . intval(ifSqlTableColumnExists($tableName, $columnName)) . '');
}
} // END - foreach
} elseif ((getTableType() == 'InnoDB') && (isInString('FULLTEXT', $sql))) {
// 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 : ifSqlColumnExists($columnName)), $F, $L));
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,tableName=%s,hasZeroNums=%d,file=%s,line=%s", $sql, $tableName, intval((is_bool($result)) ? 0 : ifSqlTableColumnExists($columnName)), $F, $L));
} elseif ($isAlterIndex === TRUE) {
// And column name as well without backticks
$keyName = str_replace('`', '', $tableArray[5]);
// Check if there is a SQL table created
function ifSqlTableExists ($tableName) {
+ // Make sure double-prefixes are being removed
+ $tableName = str_replace('{?_MYSQL_PREFIX?}_', '', $tableName);
+
+ // Log message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ' - ENTERED!');
+
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$tableName])) {
// Check if the table is there
}
// Is a table column there?
-function ifSqlColumnExists ($tableName, $columnName) {
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columnName . ' - ENTERED!');
- // Is there cache?
- if (!isset($GLOBALS[__FUNCTION__][$tableName][$columnName])) {
- // And column name as well
- $columnName = str_replace('`', '', $columnName);
+function ifSqlTableColumnExists ($tableName, $columnName) {
+ // Remove back-ticks
+ $columnName = str_replace('`', '', $columnName);
- // If the table is not there, it is okay
- if (!ifSqlTableExists($tableName)) {
- // Then abort here
- return FALSE;
- } // END - if
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columnName . ' - ENTERED!');
- // Get column information
- $result = SQL_QUERY_ESC("SHOW COLUMNS FROM `%s` LIKE '%s'",
- array(
- $tableName,
- $columnName
- ), __FUNCTION__, __LINE__);
+ // If the table is not there, it is okay
+ if (!ifSqlTableExists($tableName)) {
+ // Then abort here
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Table ' . $tableName . ' does not exist.');
+ return FALSE;
+ } // END - if
- // Is a link there?
- if (!is_resource($result)) {
- // Is installation phase?
- if (isInstallationPhase()) {
- // Then silently abort here
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(SQL_IS_LINK_UP()) . ',tableName=' . $tableName . ',columnName=' . $columnName . ' - Returning FALSE ...');
- return FALSE;
- } else {
- // Please report this
- reportBug(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ' is not a resource.');
- }
- } // END - if
+ // Get column information
+ $result = SQL_QUERY_ESC("SHOW COLUMNS FROM `%s` LIKE '%s'",
+ array(
+ $tableName,
+ $columnName
+ ), __FUNCTION__, __LINE__);
+
+ // Is a link there?
+ if (!is_resource($result)) {
+ // Is installation phase?
+ if (isInstallationPhase()) {
+ // Then silently abort here
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(SQL_IS_LINK_UP()) . ',tableName=' . $tableName . ',columnName=' . $columnName . ' - Returning FALSE ...');
+ return FALSE;
+ } else {
+ // Please report this
+ reportBug(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ' is not a resource.');
+ }
+ } // END - if
- // Determine it
- $GLOBALS[__FUNCTION__][$tableName][$columnName] = (!SQL_HASZERONUMS($result));
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columnName . ',hasZeroNums=' . intval(SQL_HASZERONUMS($result)) . ',numRows=' . intval($GLOBALS[__FUNCTION__][$tableName][$columnName]));
+ // Determine it
+ $doesExist = (!SQL_HASZERONUMS($result));
- // Free result
- SQL_FREERESULT($result);
- } // END - if
+ // Free result
+ SQL_FREERESULT($result);
// Return cache
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columnName . ',result=' . intval($GLOBALS[__FUNCTION__][$tableName][$columnName]) . ' - EXIT!');
- return $GLOBALS[__FUNCTION__][$tableName][$columnName];
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columnName . ',doesExist=' . intval($doesExist) . ' - EXIT!');
+ return $doesExist;
}
// Checks depending on the mode if the index is there
function ifSqlTableIndexExist ($tableName, $keyName) {
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $keyName . ' - ENTERED!');
- // Is there cache?
- if (!isset($GLOBALS[__FUNCTION__][$tableName][$keyName])) {
- // If the table is not there, it is okay
- if (!ifSqlTableExists($tableName)) {
- // Then abort here
- return FALSE;
- } // END - if
+ // Remove back-ticks
+ $keyName = str_replace('`', '', $keyName);
- // Show indexes
- $result = SQL_QUERY_ESC("SHOW INDEX FROM `%s`", array($tableName), __FUNCTION__, __LINE__);
-
- // Is a link there?
- if (!is_resource($result)) {
- // Is installation phase?
- if (isInstallationPhase()) {
- // Then silently abort here
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(SQL_IS_LINK_UP()) . ',tableName=' . $tableName . ',keyName=' . $keyName . ' - Returning FALSE ...');
- return FALSE;
- } else {
- // Please report this
- reportBug(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ' is not a resource.');
- }
- } // END - if
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',keyName=' . $keyName . ' - ENTERED!');
- // The column is not found by default
- $GLOBALS[__FUNCTION__][$tableName][$keyName] = FALSE;
+ // If the table is not there, it is okay
+ if (!ifSqlTableExists($tableName)) {
+ // Then abort here
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Table ' . $tableName . ' does not exist.');
+ return FALSE;
+ } // END - if
- // Walk through all
- while ($content = SQL_FETCHARRAY($result)) {
- // Add all entries for better caching behavior
- $GLOBALS[__FUNCTION__][$tableName][$content['Key_name']] = TRUE;
- } // END - while
+ // Show indexes
+ $result = SQL_QUERY_ESC("SHOW INDEX FROM `%s`", array($tableName), __FUNCTION__, __LINE__);
- // Free result
- SQL_FREERESULT($result);
- } else {
- // Cache used
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $keyName . ',result=' . intval($GLOBALS[__FUNCTION__][$tableName][$keyName]) . ' - CACHE!');
+ // Is a link there?
+ if (!is_resource($result)) {
+ // Is installation phase?
+ if (isInstallationPhase()) {
+ // Then silently abort here
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(SQL_IS_LINK_UP()) . ',tableName=' . $tableName . ',keyName=' . $keyName . ' - Returning FALSE ...');
+ return FALSE;
+ } else {
+ // Please report this
+ reportBug(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ' is not a resource.');
+ }
} // END - if
+ // The column is not found by default
+ $doesExist = FALSE;
+
+ // Walk through all
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Is it the requested one?
+ if ($content['Key_name'] == $keyName) {
+ // Then it is found and exit
+ $doesExist = TRUE;
+ break;
+ } // END - if
+ } // END - while
+
+ // Free result
+ SQL_FREERESULT($result);
+
// Return cache
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $keyName . ',result=' . intval($GLOBALS[__FUNCTION__][$tableName][$keyName]) . ' - EXIT!');
- return $GLOBALS[__FUNCTION__][$tableName][$keyName];
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',keyName=' . $keyName . ',doesExist=' . intval($doesExist) . ' - EXIT!');
+ return $doesExist;
}
// Init database layer
COLLATE utf8_general_ci
COMMENT ' . chr(39) . $comment . chr(39));
} else {
- // Is already there, which should not happen
- reportBug(__FUNCTION__, __LINE__, 'The table ' . $tableName . ' is already created which should not happen.');
+ // Is already there
+ logDebugMessage(__FUNCTION__, __LINE__, 'The table ' . $tableName . ' is already created.');
}
}
function addDropTableSql ($tableName) {
// Is the table there?
if (ifSqlTableExists($tableName)) {
- // Then add it, non-existing tables can be ignored because it will
- // happen with every newly installed extension.
+ /*
+ * Then add it, non-existing tables can be ignored because it will
+ * happen with every newly installed extension.
+ */
addExtensionSql('DROP TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '`');
// Mark it as gone
// Adds a RENAME TABLE stament if 'from' table exist and 'to' table not
function addRenameTableSql ($fromTable, $toTable) {
+ // Make sure both are not the same
+ assert($fromTable != $toTable);
+
// Is renaming required?
if ((ifSqlTableExists($fromTable)) && (!ifSqlTableExists($toTable))) {
// Add it
// Add ALTER TABLE `foo` ADD sql if not found
function addExtensionAddTableColumnSql ($tableName, $columnName, $columnSql) {
// Is the column there?
- if (!ifSqlColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $columnName)) {
+ if (!ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $columnName)) {
// Then add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD `' . $columnName . '` ' . $columnSql);
} elseif (isDebugModeEnabled()) {
}
}
+// Add ALTER TABLE `foo` ADD INDEX sql if not found
+function addExtensionAddTableIndexSql ($tableName, $indexName, $columnSql) {
+ // Is the column there?
+ if (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName)) {
+ // Then add it
+ addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD INDEX `' . $indexName . '` ' . $columnSql);
+ } elseif (isDebugModeEnabled()) {
+ // Add debug line
+ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',indexName=' . $indexName . ',columnSql=' . $columnSql . ': does already exist.');
+ }
+}
+
+// Add ALTER TABLE `foo` ADD UNIQUE INDEX sql if not found
+function addExtensionAddTableUniqueSql ($tableName, $indexName, $columnSql) {
+ // Is the column there?
+ if (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName)) {
+ // Then add it
+ addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD UNIQUE INDEX `' . $indexName . '` ' . $columnSql);
+ } elseif (isDebugModeEnabled()) {
+ // Add debug line
+ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',indexName=' . $indexName . ',columnSql=' . $columnSql . ': does already exist.');
+ }
+}
+
+// Add ALTER TABLE `foo` ADD FULLTEXT sql if not found
+function addExtensionAddTableFulltextSql ($tableName, $indexName, $columnSql) {
+ // Is the column there?
+ if (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName)) {
+ // Then add it
+ addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD FULLTEXT `' . $indexName . '` ' . $columnSql);
+ } elseif (isDebugModeEnabled()) {
+ // Add debug line
+ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',indexName=' . $indexName . ',columnSql=' . $columnSql . ': does already exist.');
+ }
+}
+
// Add ALTER TABLE `foo` CHANGE sql if not found
function addExtensionChangeTableColumnSql ($tableName, $fromColumnName, $toColumnName, $columnSql) {
// Is the column there?
- if ((ifSqlColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $fromColumnName)) && (($fromColumnName == $toColumnName) || (!ifSqlColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $toColumnName)))) {
+ if ((ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $fromColumnName)) && (($fromColumnName == $toColumnName) || (!ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $toColumnName)))) {
// Then add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` CHANGE `' . $fromColumnName . '` `' . $toColumnName . '` ' . $columnSql);
} elseif (isDebugModeEnabled()) {
// Add ALTER TABLE `foo` DROP sql if not found
function addExtensionDropTableColumnSql ($tableName, $columnName) {
// Is the column there?
- if (ifSqlColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $columnName)) {
+ if (ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $columnName)) {
// Then add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` DROP `' . $columnName . '`');
} elseif (isDebugModeEnabled()) {
}
}
+// Add ALTER TABLE `foo` DROP INDEX sql if not found
+function addExtensionDropTableIndexSql ($tableName, $indexName) {
+ // Is the column there?
+ if (ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $indexName)) {
+ // Then add it
+ addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` DROP INDEX `' . $indexName . '`');
+ } elseif (isDebugModeEnabled()) {
+ // Add debug line
+ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',indexName=' . $indexName . ': does not exist.');
+ }
+}
+
// Add configuration entry if not found for actual extension
function addConfigAddSql ($columnName, $columnSql) {
// Is the column there?
- if (!ifSqlColumnExists('{?_MYSQL_PREFIX?}_config', $columnName)) {
+ if (!ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_config', $columnName)) {
// Not found, so add it
addExtensionAddTableColumnSql('config', $columnName, $columnSql);
} elseif (isDebugModeEnabled()) {
// Drop configuration entry if found for actual extension
function addConfigDropSql ($columnName) {
// Is the column there?
- if (ifSqlColumnExists('{?_MYSQL_PREFIX?}_config', $columnName)) {
+ if (ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_config', $columnName)) {
// Found, so add it
addExtensionDropTableColumnSql('config', $columnName);
} elseif (isDebugModeEnabled()) {
'Bonus mails');
addExtensionAddTableColumnSql('user_links', 'bonus_id', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` ADD INDEX (`bonus_id`)");
+ addExtensionAddTableIndexSql('user_links', 'bonus_id', '(`bonus_id`)');
addExtensionAddTableColumnSql('bonus', 'html_msg', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
break;
addConfigAddSql('bonus_new_mem_notify', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
addConfigAddSql('bonus_notify_points', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
addConfigAddSql('bonus_notify_wait', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 30');
- addExtensionAddTableColumnSql('online', 'bonus_ral_en_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
- addExtensionAddTableColumnSql('online', 'bonus_ral_di_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
- addExtensionAddTableColumnSql('online', 'bonus_ral_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+ addExtensionAddTableColumnSql('user_data', 'bonus_ral_en_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+ addExtensionAddTableColumnSql('user_data', 'bonus_ral_di_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+ addExtensionAddTableColumnSql('user_data', 'bonus_ral_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Optionale automatische Benachrichtigung über aktivierte und/oder deaktivierte Aktiv-Rallye einstellbar.");
break;
case '0.9.2': // SQL queries for v0.9.2
- addExtensionChangeTableColumnSql('user_data', 'bonus_ral_en_notify', 'bonus_ralley_enable_notify` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
- addExtensionChangeTableColumnSql('user_data', 'bonus_ral_di_notify', 'bonus_ralley_disable_notify` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
- addExtensionChangeTableColumnSql('user_data', 'bonus_ral_notify', 'bonus_rallley_notify` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+ addExtensionChangeTableColumnSql('user_data', 'bonus_ral_en_notify', 'bonus_ralley_enable_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+ addExtensionChangeTableColumnSql('user_data', 'bonus_ral_di_notify', 'bonus_ralley_disable_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+ addExtensionChangeTableColumnSql('user_data', 'bonus_ral_notify', 'bonus_rallley_notify` BIGINT(20)', 'UNSIGNED NOT NULL DEFAULT 0');
// Update notes
setExtensionUpdateNotes("Umbenannt nach neuer Konvention (bitte Einstellungen kontrollieren).");
break;
case '0.3.1': // SQL queries for v0.3.1
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_extensions` ADD UNIQUE INDEX `ext_name` (`ext_name`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD UNIQUE INDEX `login` (`login`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_refbanner` ADD INDEX `visible` (`visible`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_refdepths` ADD UNIQUE INDEX `level` (`level`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` ADD INDEX `level` (`level`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_pool` ADD INDEX `data_type` (`data_type`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_mod_reg` ADD UNIQUE INDEX `module` (`module`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admin_menu` ADD INDEX `action` (`action`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admin_menu` ADD INDEX `what` (`what`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_task_system` ADD INDEX `task_type` (`task_type`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_task_system` ADD INDEX `status` (`status`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_task_system` ADD INDEX `task_created` (`task_created`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_task_system` ADD FULLTEXT `subject` (`subject`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_task_system` ADD INDEX `subject` (`subject`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_extensions` ADD INDEX `ext_active` (`ext_active`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_guest_menu` ADD INDEX `action` (`action`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_guest_menu` ADD INDEX `what` (`what`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_guest_menu` ADD INDEX `sort` (`sort`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_guest_menu` ADD INDEX `visible` (`visible`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_guest_menu` ADD INDEX `locked` (`locked`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_member_menu` ADD INDEX `what` (`what`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_member_menu` ADD INDEX `sort` (`sort`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_member_menu` ADD INDEX `visible` (`visible`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_member_menu` ADD INDEX `locked` (`locked`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_cats` ADD INDEX `visible` (`visible`)");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_cats` ADD INDEX `sort` (`sort`)");
+ addExtensionAddTableUniqueSql('extensions', 'ext_name', '(`ext_name`)');
+ addExtensionAddTableUniqueSql('admins', 'login', '(`login`)');
+ addExtensionAddTableIndexSql('refbanner', 'visible', '(`visible`)');
+ addExtensionAddTableUniqueSql('refdepths', 'level', '(`level`)');
+ addExtensionAddTableIndexSql('refsystem', 'level', '(`level`)');
+ addExtensionAddTableIndexSql('pool', 'data_type', '(`data_type`)');
+ addExtensionAddTableUniqueSql('mod_reg', 'module', '(`module`)');
+ addExtensionAddTableIndexSql('admin_menu', 'action', '(`action`)');
+ addExtensionAddTableIndexSql('admin_menu', 'what', '(`what`)');
+ addExtensionAddTableIndexSql('task_system', 'task_type', '(`task_type`)');
+ addExtensionAddTableIndexSql('task_system', 'status', '(`status`)');
+ addExtensionAddTableIndexSql('task_system', 'task_created', '(`task_created`)');
+ addExtensionAddTableFulltextSql('task_system', 'subject', '(`subject`)');
+ addExtensionAddTableIndexSql('task_system', 'subject', '(`subject`)');
+ addExtensionAddTableIndexSql('extensions', 'ext_active', '(`ext_active`)');
+ addExtensionAddTableIndexSql('guest_menu', 'action', '(`action`)');
+ addExtensionAddTableIndexSql('guest_menu', 'what', '(`what`)');
+ addExtensionAddTableIndexSql('guest_menu', 'sort', '(`sort`)');
+ addExtensionAddTableIndexSql('guest_menu', 'visible', '(`visible`)');
+ addExtensionAddTableIndexSql('guest_menu', 'locked', '(`locked`)');
+ addExtensionAddTableIndexSql('member_menu', 'what', '(`what`)');
+ addExtensionAddTableIndexSql('member_menu', 'sort', '(`sort`)');
+ addExtensionAddTableIndexSql('member_menu', 'visible', '(`visible`)');
+ addExtensionAddTableIndexSql('member_menu', 'locked', '(`locked`)');
+ addExtensionAddTableIndexSql('cats', 'visible', '(`visible`)');
+ addExtensionAddTableIndexSql('cats', 'sort', '(`sort`)');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Eindeutige Schlüssel (UNIQUE) und normale Schlüssel (INDEX) gesetzt.");
break;
case '0.4.8': // SQL queries for v0.4.8
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_task_system` ADD INDEX (`subject`)');
+ addExtensionAddTableIndexSql('task_system', 'subject', '(`subject`)');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Index für Betreff eingefügt.");
break;
case '0.5.0': // SQL queries for v0.5.0
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` DROP INDEX `level`');
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` DROP INDEX `userid`');
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` ADD UNIQUE INDEX `userid_level` (`userid`, `level`)');
+ addExtensionDropTableIndexSql('refsystem', 'level`');
+ addExtensionDropTableIndexSql('refsystem', 'userid`');
+ addExtensionAddTableIndexSql('refsystem', 'userid_level', '(`userid`, `level`)');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Referral-System unterstützt nun detailierte Referral-Übersicht und vieles mehr.");
break;
case '0.5.8': // SQL queries for v0.5.8
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_extensions` DROP `ext_lang_file`');
+ addExtensionDropTableColumnSql('extensions` DROP `ext_lang_file`');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Sprachdateinamen werden nicht mehr in der Datenbank behalten.");
break;
case '0.8.2': // SQL queries for v0.8.2
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_points_data` DROP INDEX `ext_name`");
+ addExtensionDropTableIndexSql('points_data', 'ext_name');
addExtensionChangeTableColumnSql('points_data', 'ext_name', 'subject', "VARCHAR(255) NOT NULL DEFAULT ''");
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_points_data` ADD INDEX `subject` (`subject`)");
addExtensionAddTableColumnSql('points_data', 'notify_recipient', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
// Register points data
break;
case '0.8.8': // SQL queries for v0.8.8
- addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_points_data` DROP INDEX `subject`, ADD UNIQUE `subject` (`subject`)");
+ addExtensionDropTableIndexSql('points_data', 'subject');
+ addExtensionAddTableUniqueSql('points_data', 'subject', '(`subject`)');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Der Wert in der Spalte <strong>subject</strong> sollte nur einmal vorkommen, damit eventuell nichts mehrfach durchfl&auuml;ft.");
break;
case '0.3.6': // SQL queries for v0.3.6
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` DROP INDEX `userid`');
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` ADD UNIQUE `userid_catid` (`userid`, `cat_id`)');
+ addExtensionDropTableIndexSql('user_cats', 'userid`');
+ addExtensionAddTableUniqueSql('user_cats', 'userid_catid', '(`userid`, `cat_id`)');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Der Sperrgrund wird nun mit abgespeichert und beim Löschen des Users mit ausgesendet.");
addDropTableSql('subid_log');
addCreateTableSql('subid_log', "
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-`refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`refid` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
`subid` VARCHAR(255) NOT NULL DEFAULT '',
`referral_url` TINYTEXT NOT NULL,
`remote_address` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
// For saving used subid in user_data table
addExtensionAddTableColumnSql('user_data', 'subid', 'VARCHAR(255) NULL DEFAULT NULL');
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD INDEX (`subid`)');
+ addExtensionAddTableIndexSql('user_data', 'subid', '(`subid`)');
// Configuration entry for purging old subid logs (7 days default)
addConfigAddSql('user_subid_purge', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 7));
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Bereinigung von Sub-Ids und deren Einstellungen hinzugefügt.");
break;
+
+ case '0.5.9': // SQL queries for v0.5.9
+ addExtensionChangeTableColumnSql('subid_log', 'refid', 'refid', 'BIGINT(20) UNSIGNED NULL DEFAULT NULL');
+ addExtensionChangeTableColumnSql('user_stats', 'cat_id', 'cat_id', 'BIGINT(20) UNSIGNED NULL DEFAULT NULL');
+ addExtensionChangeTableColumnSql('user_stats', 'payment_id', 'payment_id', 'BIGINT(20) UNSIGNED NULL DEFAULT NULL');
+ addExtensionChangeTableColumnSql('user_stats', 'pool_id', 'pool_id', 'BIGINT(20) UNSIGNED NULL DEFAULT NULL');
+ addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_subid_log` SET `refid`=NULL WHERE `refid`=0');
+ addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `cat_id`=NULL WHERE `cat_id`=0');
+ addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `payment_id`=NULL WHERE `payment_id`=0');
+ addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `pool_id`=NULL WHERE `pool_id`=0');
+
+ // Update notes (these will be set as task text!)
+ setExtensionUpdateNotes("Besser NULL anstelle 0.");
+ break;
} // END - switch
break;
// Is this filter loaded?
//* DEBUG: */ debugOutput('FOUND:'.$filterName.'/'.$filterFunction.'='.$active);
if (((!isset($GLOBALS['cache_array']['filter']['loaded'][$filterName][$filterFunction])) && ($active != 'R')) || ($active == 'A')) {
- // Add this filter (all filters are active by default)
- //* DEBUG: */ debugOutput('ADD:'.$filterName.'/'.$filterFunction);
- $insertSQL .= sprintf("('%s','%s','Y'),", $filterName, $filterFunction);
- $inserted++;
+ // Is this filter already in database?
+ if (countSumTotalData($filterFunction, 'filters', 'filter_name', 'filter_function', TRUE, sprintf(" AND `filter_name`='%s'", SQL_ESCAPE($filterName))) == 0) {
+ // Add this filter (all filters are active by default)
+ //* DEBUG: */ debugOutput('ADD:'.$filterName.'/'.$filterFunction);
+ $insertSQL .= sprintf("('%s','%s','Y'),", $filterName, $filterFunction);
+ $inserted++;
+ } elseif (isDebugModeEnabled()) {
+ // Log already registered filters
+ logDebugMessage(__FUNCTION__, __LINE__, 'Already registered: filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',active=' . $active);
+ }
} elseif ($active == 'R') {
// Remove this filter
//* DEBUG: */ debugOutput('REMOVE:'.$filterName.'/'.$filterFunction);