X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fextensions-functions.php;h=9228cf4f42c2b7fd99bd6040ac28d6f4a09e4cb2;hb=3b7adf43576db24e516716bb13a2bd0bac677c8c;hp=cd3f0d068a935afb9ce71d30a737ef2f94fe3557;hpb=b8e38719844932afed4b1ac23755a4c05b72eb99;p=mailer.git diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index cd3f0d068a..9228cf4f42 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -1741,13 +1741,28 @@ function isExtensionFunctionFileReadable ($ext_name) { return ($GLOBALS['cache_array']['extension']['ext_func'][$ext_name] == 'Y'); } +// Adds a CREATE TABLE statement if the requested table is not there +function addCreateTableSql ($tableName, $sql) { + // Is the table not there? + if (!isSqlTableCreated($tableName)) { + // Is not found, so add it + addExtensionSql('CREATE TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ' . $sql); + } else { + // Is already there, which should not happen + debug_report_bug(__FUNCTION__, __LINE__, 'The table ' . $tableName . ' is already created which should not happen.'); + } +} + // Adds a DROP TABLE statement if the requested tabled is there -function addDropTableSql ($table) { +function addDropTableSql ($tableName) { // Is the table there? - if (isSqlTableCreated($table)) { + if (isSqlTableCreated($tableName)) { // Then add it, non-existing tables can be ignored because it will // happen with every newly installed extension. - addExtensionSql('DROP TABLE `{?_MYSQL_PREFIX?}_' . $table . '`'); + addExtensionSql('DROP TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '`'); + + // Mark it as gone + $GLOBALS['isSqlTableCreated'][$tableName] = false; } // END - if } @@ -1888,15 +1903,40 @@ function addConfigAddSql ($columnName, $columnSql) { // Is the column there? if (!isSqlTableColumnFound('{?_MYSQL_PREFIX?}_config', $columnName)) { // Not found, so add it - addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `' . $columName . '` ' . $columnSql); + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `' . $columnName . '` ' . $columnSql); } else { // Add debug line logDebugMessage(__FUNCTION__, __LINE__, 'Configuration entry ' . $columnName . ' already created. columnSql=' . $columnSql); } } +// Drop configuration entry if found for actual extension +function addConfigDropSql ($columnName) { + // Is the column there? + if (isSqlTableColumnFound('{?_MYSQL_PREFIX?}_config', $columnName)) { + // Found, so add it + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `' . $columnName . '`'); + } else { + // Add debug line, debug_report_bug() would cause some extenion updates fail + logDebugMessage(__FUNCTION__, __LINE__, 'Configuration entry ' . $columnName . ' not found.'); + } +} + +// Change configuration entry for actual extension +function addConfigChangeSql ($oldColumnName, $newColumnName, $columnSql) { + // Is the old column there? + if (isSqlTableColumnFound('{?_MYSQL_PREFIX?}_config', $oldColumnName)) { + // Found so add it + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_config` CHANGE `' . $oldColumnName . '` `' . $newColumnName . '` ' . $columnSql); + } else { + // Add debug line, debug_report_bug() would cause some extenion updates fail + logDebugMessage(__FUNCTION__, __LINE__, 'Configuration entry ' . $oldColumnName . ' not found.'); + } +} + // Enables/disables productive mode for current extension (used only while // registration). +// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' function enableExtensionProductive ($isProductive = true) { // Log debug message //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("ext_name=%s,isProductive=%d", getCurrentExtensionName(), intval($isProductive)));