./inc/extensions/ext-rallye.php:94: // @TODO Fix config_rallye_prices to list_rallye_prices
./inc/extensions/ext-yoomedia.php:123: // @TODO Can this be moved into a database table?
./inc/extensions/ext-yoomedia.php:56:// @TODO Only deprecated when 'ext-network' is ready! setExtensionDeprecated('Y');
-./inc/extensions-functions.php:146: // @TODO Do we still need this? setExtensionUpdateNotes('');
-./inc/extensions-functions.php:427:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
-./inc/extensions-functions.php:551: // @TODO Extension is loaded, what next?
+./inc/extensions-functions.php:152: // @TODO Do we still need this? setExtensionUpdateNotes('');
+./inc/extensions-functions.php:434:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
+./inc/extensions-functions.php:564: // @TODO Extension is loaded, what next?
./inc/functions.php:115: // @TODO Extension 'msg' does not exist
./inc/functions.php:1486: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ?
./inc/functions.php:1509: // @TODO Rewrite this old lost code to a template
./inc/modules/admin/what-del_email.php:61: // @TODO Unused: cat_id, payment_id
./inc/modules/admin/what-edit_user.php:20: * @TODO Add support for ext-country *
./inc/modules/admin/what-email_stats.php:48:// @TODO Unused at the moment
-./inc/modules/admin/what-extensions.php:368: // @TODO Rewrite this to a filter
+./inc/modules/admin/what-extensions.php:369: // @TODO Rewrite this to a filter
./inc/modules/admin/what-guest_add.php:131: // @TODO This can be somehow rewritten to a function
./inc/modules/admin/what-guest_add.php:69: // @TODO Cant this be rewritten?
./inc/modules/admin/what-guest_add.php:82: // @TODO This can be somehow rewritten to a function
// Set current extension version
setCurrentExtensionVersion($ext_ver);
} else {
- // Set it to 0.0
+ // Set it to 0.0 by default
setCurrentExtensionVersion('0.0');
+ // Is the extension installed?
+ if ((isExtensionInstalled($ext_name)) && ($ext_mode != 'register')) {
+ // Get extension's version
+ setCurrentExtensionVersion(getExtensionVersion($ext_name));
+ } // END - if
+
// In all but test-mode we need these messages to debug! Please report all (together, e.g.)
- if ($ext_mode != 'test') {
+ if (($ext_mode != 'test') && (getCurrentExtensionVersion() == '0.0')) {
// Log empty versions not in test-mode, but maybe it is fine...
logDebugMessage(__FUNCTION__, __LINE__, 'Extension version is empty, setting to 0.0. ext_name=' . $ext_name . ', ext_mode=' . $ext_mode . ', dry_run=' . intval($dry_run));
} // END - if
// 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();
+
+ // Mark it as installed
+ $GLOBALS['ext_is_installed'][getCurrentExtensionName()] = true;
// Remove cache file(s) if extension is active
runFilterChain('post_extension_installed', array(
initExtensionSqls(true);
initExtensionNotes(true);
- // Mark it as installed
- $GLOBALS['ext_is_installed'][getCurrentExtensionName()] = true;
-
// In normal mode return a true on success
$ret = true;
} elseif (isExtensionDryRun() === true) {
} // END - if
// Init array
- initExtensionSqls();
+ initExtensionSqls(true);
// By default no SQL has been executed
$sqlRan = false;
// Load extension in detected mode
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name[' . $ext_id . ']=' . getCurrentExtensionName());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name[' . $ext_id . ']=' . getCurrentExtensionName() . ',load_mode=' . $load_mode);
loadExtension(getCurrentExtensionName(), $load_mode, '', false);
// Init these SQLs
initSqls();
setSqlsArray(getExtensionSqls());
+ // Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SQLs::count=' . countSqls());
+
+ // Do we have entries?
if (isSqlsValid()) {
// Run SQL commands...
runFilterChain('run_sqls');
// Look in database
$ext_id = getExtensionId($ext_name);
+ // Log debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Extension ' . $ext_name . ' has ext_id=' . $ext_id);
+
// Do we have a record?
$isInstalled = ($ext_id > 0);
// Activate given extension
function doActivateExtension ($ext_name) {
+ // Is the extension installed?
+ if (!isExtensionInstalled($ext_name)) {
+ // Non-installed extensions cannot be activated
+ debug_report_bug(__FUNCTION__, __LINE__, 'Tried to activate non-installed extension ' . $ext_name);
+ } // END - if
+
// Activate the extension
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='Y' WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
- // Extension has been activated?
- if (SQL_AFFECTEDROWS() == 1) {
- // Then run all queries
- doExtensionSqls(getExtensionId($ext_name), 'activate');
- } // END - if
+ // Then run all queries
+ doExtensionSqls(getExtensionId($ext_name), 'activate');
}
// Deactivate given extension
-function doDeactivateExtension($ext_name) {
+function doDeactivateExtension ($ext_name) {
+ // Is the extension installed?
+ if (!isExtensionInstalled($ext_name)) {
+ // Non-installed extensions cannot be activated
+ debug_report_bug(__FUNCTION__, __LINE__, 'Tried to deactivate non-installed extension ' . $ext_name);
+ } // END - if
+
// Activate the extension
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='N' WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
- // Extension has been activated?
- if (SQL_AFFECTEDROWS() == 1) {
- // Then run all queries
- doExtensionSqls(getExtensionId($ext_name), 'deactivate');
+ // Then run all queries
+ doExtensionSqls(getExtensionId($ext_name), 'deactivate');
- // Create new task (we ignore the task id here)
- createExtensionDeactivationTask($ext_name);
+ // Create new task (we ignore the task id here)
+ createExtensionDeactivationTask($ext_name);
- // Notify the admin
- sendAdminNotification(
- '{--ADMIN_EXTENSION_DEACTIVATED_SUBJECT--}',
- 'admin_extension_deactivated',
- array('ext_name' => $ext_name)
- );
- } // END - if
+ // Notify the admin
+ sendAdminNotification(
+ '{--ADMIN_EXTENSION_DEACTIVATED_SUBJECT--}',
+ 'admin_extension_deactivated',
+ array('ext_name' => $ext_name)
+ );
}
// Checks wether the extension is older than given
// Adds SQLs to the SQLs array but "assigns" it with current extension name
function addExtensionSql ($sql) {
// Add it
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',ext_version=' . getCurrentExtensionVersion() . ',sql=' . $sql);
$GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()][] = $sql;
}
// Filter for auto-activation of a extension
function FILTER_AUTO_ACTIVATE_EXTENSION ($data) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $data['ext_name'] . ',isExtensionAlwaysActive()=' . intval(isExtensionAlwaysActive()));
+
// Is this extension always activated?
if (isExtensionAlwaysActive()) {
// Then activate the extension
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "ext_name={$data['ext_name']}<br />");
doActivateExtension($data['ext_name']);
} // END - if
// Filter for running SQL commands
function FILTER_RUN_SQLS ($data) {
// Debug message
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "- Entered!");
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Entered!');
// Is the array there?
if ((isSqlsValid()) && ((!isset($data['dry_run'])) || ($data['dry_run'] == false))) {
// Run SQL commands
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "- Found ".countSqls()." queries to run.");
- foreach (getSqls() as $sqls) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Found ' . countSqls() . ' queries to run.');
+ foreach (getSqls() as $mode=>$sqls) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mode=' . $mode . ',count()=' . count($sqls));
+
// New cache format...
foreach ($sqls as $sql) {
// Trim spaces away
SQL_ALTER_TABLE($sql, __FUNCTION__, __LINE__, $data['enable_codes']);
} else {
// Run regular SQL command
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Running regular query: ' . $sql . ',enable_codes=' . intval($data['enable_codes']);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Running regular query: ' . $sql . ',enable_codes=' . intval($data['enable_codes']));
SQL_QUERY($sql, __FUNCTION__, __LINE__, $data['enable_codes']);
}
} // END - if
} // END - if
// Debug message
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "- Left!");
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Left!');
}
// Filter for updating/validating login data
// The id comes from task management and it is - of course - *not* the extension's name!
} elseif ((isFormSent('change')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
// De-/activate extensions
- foreach (postRequestParameter('sel') as $taskId => $ext_active) {
+ foreach (postRequestParameter('sel') as $ext_id => $ext_active) {
// Shall we keep the extension always active?
- if ((isset($GLOBALS['cache_array']['always_active'][getExtensionName($taskId)])) && ($GLOBALS['cache_array']['always_active'][getExtensionName($taskId)] == 'Y') && ($ext_active == 'Y')) {
+ if ((isset($GLOBALS['cache_array']['always_active'][getExtensionName($ext_id)])) && ($GLOBALS['cache_array']['always_active'][getExtensionName($ext_id)] == 'Y') && ($ext_active == 'Y')) {
// Keep this extension active!
- loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_EXTENSION_ALWAYS_ACTIVE', getExtensionName($taskId)));
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_EXTENSION_ALWAYS_ACTIVE', getExtensionName($ext_id)));
} else {
// Deactivation is default
$active = 'N';
// Update database
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='%s' WHERE `id`=%s AND `ext_active`='%s' LIMIT 1",
- array($active, bigintval($taskId), $ext_active), __FILE__, __LINE__);
+ array($active, bigintval($ext_id), $ext_active), __FILE__, __LINE__);
// Run embeded SQL commands
- doExtensionSqls($taskId, getExtensionMode());
+ doExtensionSqls($ext_id, getExtensionMode());
}
} // END - foreach
if (isPostRequestParameterSet('modify')) {
// Change entries
$cache_update = '0';
- foreach (postRequestParameter('sel') as $taskId => $sel) {
+ foreach (postRequestParameter('sel') as $ext_id => $sel) {
// Secure id
- $taskId = bigintval($taskId);
+ $ext_id = bigintval($ext_id);
// Change this extension?
if ($sel == 1) {
setExtensionMode('modify');
// Get entry for 'active'
- $active = postRequestParameter('active', $taskId);
+ $active = postRequestParameter('active', $ext_id);
// Update extension's record
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
// Update also CSS column when extensions sql_patches is newer or exact v0.0.6
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_has_css`='%s', `ext_active`='%s' WHERE `id`=%s LIMIT 1",
- array(postRequestParameter('css', $taskId), $active, $taskId), __FILE__, __LINE__);
+ array(postRequestParameter('css', $ext_id), $active, $ext_id), __FILE__, __LINE__);
} else {
// When extension is older than v0.0.6 there is no column for the CSS information
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='%s' WHERE `id`=%s LIMIT 1",
- array($active, $taskId), __FILE__, __LINE__);
+ array($active, $ext_id), __FILE__, __LINE__);
}
// Run SQLs on activation / deactivation
} // END - if
// Run embeded SQL commands
- doExtensionSqls($taskId, getExtensionMode());
- }
- }
+ doExtensionSqls($ext_id, getExtensionMode());
+ } // END - if
+ } // END - foreach
// Redirect to prevent missing cache in js.php
redirectToUrl('modules.php?module=admin&what=extensions&edited=' . countPostSelection());
} else {
// Edit selected entries
$OUT = '';
- foreach (postRequestParameter('sel') as $taskId => $sel) {
+ foreach (postRequestParameter('sel') as $ext_id => $sel) {
// Edit this extension?
if (($sel == 'Y') || ($sel != 'Y')) {
// Default is no CSS for non-updated mailers
// Load required data
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
$result = SQL_QUERY_ESC("SELECT ext_has_css, ext_active FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1",
- array(bigintval($taskId)), __FILE__, __LINE__);
+ array(bigintval($ext_id)), __FILE__, __LINE__);
list($css, $active) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
} else {
$result = SQL_QUERY_ESC("SELECT ext_active FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1",
- array(bigintval($taskId)), __FILE__, __LINE__);
+ array(bigintval($ext_id)), __FILE__, __LINE__);
list($active) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
$css = 'X';
// Prepare CSS column
$cssSelection = '---';
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
- $cssSelection = addSelectionBox('yn', $css, 'css', $taskId);
+ $cssSelection = addSelectionBox('yn', $css, 'css', $ext_id);
} // END - if
// Prepare data for the row template
$content = array(
- 'id' => $taskId,
- 'name' => getExtensionName($taskId),
- 'active' => addSelectionBox('yn', $active, 'active', $taskId),
+ 'id' => $ext_id,
+ 'name' => getExtensionName($ext_id),
+ 'active' => addSelectionBox('yn', $active, 'active', $ext_id),
'css' => $cssSelection,
);
} elseif ((isPostRequestParameterSet('delete')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
// List extensions and when verbose is enabled SQL statements which will be executed
$OUT = '';
- foreach (postRequestParameter('sel') as $taskId => $sel) {
+ foreach (postRequestParameter('sel') as $ext_id => $sel) {
// Init variables
$VERBOSE_OUT = '';
initSqls();
// Secure id number
- $taskId = bigintval($taskId);
+ $ext_id = bigintval($ext_id);
// Is the id valid?
- if (isExtensionIdValid($taskId)) {
+ if (isExtensionIdValid($ext_id)) {
// Get extension name
- $ext_name = getExtensionName($taskId);
+ $ext_name = getExtensionName($ext_id);
+ // Listing of SQLs enabled?
if (isVerboseSqlEnabled()) {
// Load SQL commands in remove mode
if (loadExtension($ext_name, 'remove', '', true)) {
// Prepare data for the row template
$content = array(
- 'id' => $taskId,
+ 'id' => $ext_id,
'ext_name' => $ext_name,
'ext_ver' => getExtensionVersion($ext_name),
'verbose' => $VERBOSE_OUT
} else {
// Prepare data for the row template
$content = array(
- 'id' => $taskId
+ 'id' => $ext_id
);
// Not valid!
} elseif ((isFormSent('remove')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
// Remove extensions from DB (you have to delete all files manually!)
$cache_update = '0';
- foreach (postRequestParameter('sel') as $taskId => $active) {
+ foreach (postRequestParameter('sel') as $ext_id => $active) {
// Secure id number
- $taskId = bigintval($taskId);
+ $ext_id = bigintval($ext_id);
// Is this extension selected and id valid?
- if (($active == 1) && (isExtensionIdValid($taskId))) {
+ if (($active == 1) && (isExtensionIdValid($ext_id))) {
// Run embeded SQL commands
- doExtensionSqls($taskId, 'remove');
+ doExtensionSqls($ext_id, 'remove');
} // END - if
} // END - foreach
// Setter for SQLs array
function setSqlsArray ($SQLs) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count()='.count($SQLs));
$GLOBALS['sqls'] = (array) $SQLs;
}