} // END - if
// Load extension's own language file if not in test mode
- if ((getExtensionMode() != 'test') && (ifExtensionHasLanguageFile($ext_name))) {
+ if ((getExtensionMode() != 'test') && (isExtensionLanguageFileReadable($ext_name))) {
// Load it
loadLanguageFile($ext_name);
} // END - if
setSqlsArray(getExtensionSqls());
// Run installation pre-installation filters
- runFilterChain('pre_extension_installed', array('dry_run' => isExtensionDryRun(), 'enable_codes' => FALSE));
+ runFilterChain('pre_extension_installed', array('dry_run' => isExtensionDryRun(), 'ext_installing' => TRUE, 'enable_codes' => FALSE));
+
+ // Copy current name to save calls
+ $currentName = getCurrentExtensionName();
// Register extension
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'insert=' . getCurrentExtensionName() . '/' . getCurrentExtensionVersion() . ' - INSERT!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'insert=' . $currentName . '/' . getCurrentExtensionVersion() . ' - INSERT!');
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
// New way, with CSS
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',always_active=' . getThisExtensionAlwaysActive() . ', ext_ver=' . getCurrentExtensionVersion() . 'ext_css=' . getExtensionHasCss());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $currentName . ',always_active=' . getThisExtensionAlwaysActive() . ', 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(),
+ $currentName,
getThisExtensionAlwaysActive(),
getCurrentExtensionVersion(),
getExtensionHasCss()
), __FUNCTION__, __LINE__);
} else {
// Old way, no CSS
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',always_active=' . getThisExtensionAlwaysActive() . ', ext_ver=' . getCurrentExtensionVersion());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $currentName . ',always_active=' . getThisExtensionAlwaysActive() . ', ext_ver=' . getCurrentExtensionVersion());
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_extensions` (`ext_name`, `ext_active`, `ext_version`) VALUES ('%s','%s','%s')",
array(
- getCurrentExtensionName(),
+ $currentName,
getThisExtensionAlwaysActive(),
getCurrentExtensionVersion()
), __FUNCTION__, __LINE__);
}
- // Use the insert id as extension id and cache it for early usage
- $GLOBALS['cache_array']['extension']['ext_id'][getCurrentExtensionName()] = SQL_INSERTID();
- $GLOBALS['cache_array']['extension']['ext_name'][SQL_INSERTID()] = getCurrentExtensionName();
+ /*
+ * Use the insert id as extension id and "cache" all data for
+ * this extension for early usage.
+ */
+ copyCurrentExtensionDataToCacheArray($ext_name, SQL_INSERTID());
// Mark it as installed
- $GLOBALS['ext_is_installed'][getCurrentExtensionName()] = TRUE;
+ $GLOBALS['ext_is_installed'][$currentName] = TRUE;
// Remove cache file(s) if extension is active
runFilterChain('post_extension_installed', array(
'pool' => 'extension',
- 'ext_name' => getCurrentExtensionName(),
+ 'ext_name' => $currentName,
'task_id' => $taskId
));
setSqlsArray(getExtensionSqls());
// Run SQLs
- runFilterChain('run_sqls', array('dry_run' => isExtensionDryRun(), 'enable_codes' => FALSE));
+ runFilterChain('run_sqls', array('dry_run' => isExtensionDryRun(), 'ext_installing' => TRUE, 'enable_codes' => FALSE));
if (isExtensionDryRun() === FALSE) {
// Run filters on success extension update
);
}
-// Checks whether the extension is older than given
-function isExtensionOlder ($ext_name, $ext_ver) {
- // Get current extension version
- $currVersion = getExtensionVersion($ext_name);
-
- // Remove all dots from both versions
- $currVersion = str_replace('.', '', $currVersion);
- $ext_ver = str_replace('.', '', $ext_ver);
-
- // Now compare both and return the result
- return ($currVersion < $ext_ver);
-}
-
// Creates a new task for updated extension
function createExtensionUpdateTask ($adminId, $ext_name, $ext_ver, $notes) {
// Create subject line
// Initial release
$content = array(
'ver' => $ext_ver,
- 'notes' => '{--INITIAL_RELEASE--}'
+ 'notes' => '{--ADMIN_EXTENSION_INITIAL_RELEASE--}'
);
} else {
// Not productive
$content = array(
'ver' => $ext_ver,
- 'notes' => '{--DEVELOPER_RELEASE--}'
+ 'notes' => '{--ADMIN_EXTENSION_DEVELOPER_RELEASE--}'
);
}
} else {
// No update notes found
$content = array(
'ver' => $ext_ver,
- 'notes' => '{--NO_UPDATE_NOTICES--}'
+ 'notes' => '{--ADMIN_EXTENSION_UPDATE_NOTICES_404--}'
);
}
// Adds SQLs to the SQLs array but "assigns" it with current extension name
function addExtensionSql ($sql) {
+ // Copy current name/version to local variable
+ $currentName = getCurrentExtensionName();
+ $currentVersion = getCurrentExtensionVersion();
+
// Is is the array there?
- if ((!isset($GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()])) || (!is_array($GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()]))) {
+ if ((!isset($GLOBALS['ext_sqls'][$currentName][$currentVersion])) || (!is_array($GLOBALS['ext_sqls'][$currentName][$currentVersion]))) {
// Init array
- $GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()] = array();
+ $GLOBALS['ext_sqls'][$currentName][$currentVersion] = array();
} // END - if
// Is the SQL statement empty?
} // END - if
// Add it
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',ext_version=' . getCurrentExtensionVersion() . ',sql=' . $sql);
- array_push($GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()], $sql);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $currentName . ',ext_version=' . $currentVersion . ',sql=' . $sql);
+ array_push($GLOBALS['ext_sqls'][$currentName][$currentVersion], $sql);
}
// Getter for SQLs array for current extension
return $GLOBALS[__FUNCTION__][getCurrentExtensionName()][getCurrentTheme()];
}
-// Checks whether the given extension has a language file
-function ifExtensionHasLanguageFile ($ext_name) {
+// Checks whether the given extension's language file is readable
+function isExtensionLanguageFileReadable ($ext_name) {
// Is there cache?
if (isset($GLOBALS['cache_array']['extension']['ext_lang'][$ext_name])) {
// Count cache hits
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, isInstallationPhase())) {
// 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, isInstallationPhase())) {
+ // 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, isInstallationPhase())) {
+ // 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 and MyISAM engine? (InnoDB doesn't support FULLTEXT)
+ if ((getTableType() == 'MyISAM') && (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName, isInstallationPhase()))) {
+ // 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, isInstallationPhase())))) {
// 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, isInstallationPhase())) {
// 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, isInstallationPhase())) {
+ // 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()) {
return ((isset($GLOBALS['ext_loaded']['library'][$ext_name])) && ($GLOBALS['ext_loaded']['library'][$ext_name] === TRUE));
}
+// Copies the given extension's data to cache_array (USE THIS ONLY IN REGISTRATION PHASE!)
+function copyExtensionDataToCacheArray ($ext_name, $ext_id) {
+ // Copy all data
+ $GLOBALS['cache_array']['extension']['ext_id'][$currentName] = $ext_id;
+ $GLOBALS['cache_array']['extension']['ext_name'][$ext_id] = $currentName;
+ $GLOBALS['cache_array']['extension']['ext_version'][$currentName] = getCurrentExtensionVersion();
+ $GLOBALS['cache_array']['extension']['ext_active'][$currentName] = getThisExtensionAlwaysActive();
+ $GLOBALS['cache_array']['extension']['ext_lang'][$currentName] = convertBooleanToYesNo(isExtensionLanguageFileReadable($currentName));
+ $GLOBALS['cache_array']['extension']['ext_func'][$currentName] = convertBooleanToYesNo(isExtensionFunctionFileReadable($currentName));
+ $GLOBALS['cache_array']['extension']['ext_menu'][$currentName] = convertBooleanToYesNo(ifModuleHasMenu($currentName));
+ $GLOBALS['cache_array']['extension']['ext_css'][$currentName] = convertBooleanToYesNo(getExtensionHasCss());
+ $GLOBALS['cache_array']['extension']['ext_deprecated'][$currentName] = 'N';
+}
+
// [EOF]
?>