X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fextensions-functions.php;h=af6f615564a4c64766b55fc337f9023e12d8386b;hb=9bc2a494fae1a98f0873a6f3bd8c878b09124b9f;hp=14c1e82b4f7e95562045638403c4e63915d04389;hpb=8cd3d68a23aa285f2fe149698a46cf8b4e3ac0ca;p=mailer.git
diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php
index 14c1e82b4f..af6f615564 100644
--- a/inc/extensions-functions.php
+++ b/inc/extensions-functions.php
@@ -46,7 +46,7 @@ if (!defined('__SECURITY')) {
function loadExtension ($ext_name, $ext_mode = 'init', $ext_ver = '', $dry_run = false) {
// If this happens twice, we need the bug report from you, except for updates/tests
if ((isset($GLOBALS['loaded_extension'][$ext_name][$ext_mode])) && (!in_array($ext_mode, array('update', 'test')))) {
- debug_report_bug(__FUNCTION__ . '() is called twice: ext_name=' . $ext_name . ', ext_mode='. $ext_mode . ',ext_sqls=' . print_r(getExtensionSqls(), true) . ', ext_register_running=' . print_r($GLOBALS['ext_register_running'], true) . ', ext_running_updates=' . print_r($GLOBALS['ext_running_updates'], true));
+ debug_report_bug(__FUNCTION__, __LINE__, '() is called twice: ext_name=' . $ext_name . ', ext_mode='. $ext_mode . ',ext_sqls=' . print_r(getExtensionSqls(), true) . ', ext_register_running=' . print_r($GLOBALS['ext_register_running'], true) . ', ext_running_updates=' . print_r($GLOBALS['ext_running_updates'], true));
} // END - if
// Make sure this situation can only happen once
@@ -166,9 +166,9 @@ function loadExtension ($ext_name, $ext_mode = 'init', $ext_ver = '', $dry_run =
}
// Registeres an extension and possible update depencies
-function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = true) {
+function registerExtension ($ext_name, $taskId, $dry_run = false, $logout = true) {
// Set current extension name
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',task_id=' . $task_id . ',dry_run=' . intval($dry_run) . ',logout=' . intval($logout) . ' - ENTERED!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',task_id=' . $taskId . ',dry_run=' . intval($dry_run) . ',logout=' . intval($logout) . ' - ENTERED!');
setCurrentExtensionName($ext_name);
// Enable dry-run
@@ -200,17 +200,23 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
} // END - if
// Is the task id zero? Then we need to auto-fix it here
- if ($task_id == '0') {
+ if ($taskId == '0') {
// Try to find the task
- $task_id = determineExtensionTaskId(getCurrentExtensionName());
+ $taskId = determineExtensionTaskId(getCurrentExtensionName());
// Still zero and not in dry-run?
- if (($task_id == '0') && (!getExtensionDryRun())) {
- // Then request a bug report
- debug_report_bug(sprintf("%s: task_id is still zero after determineExtensionTaskId(%s)",
- __FUNCTION__,
- getCurrentExtensionName()
- ));
+ if (($taskId == '0') && (!isExtensionDryRun())) {
+ // Now try to create a new task
+ $taskId = createNewExtensionTask(getCurrentExtensionName());
+
+ // Is it still zero?
+ if ($taskId == '0') {
+ // Then request a bug report
+ debug_report_bug(__FUNCTION__, __LINE__, sprintf("%s: task_id is still zero after determineExtensionTaskId(%s)",
+ __FUNCTION__,
+ getCurrentExtensionName()
+ ));
+ } // END - if
} // END - if
} // END - if
@@ -228,7 +234,7 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
// Does this extension exists?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName());
- if (loadExtension(getCurrentExtensionName(), 'register', '', getExtensionDryRun())) {
+ if (loadExtension(getCurrentExtensionName(), 'register', '', isExtensionDryRun())) {
// Set current extension name again
setCurrentExtensionName($ext_name);
@@ -238,7 +244,7 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
foreach ($history as $ver) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ', ext_ver=' . $ver);
// Load extension in update mode
- loadExtension(getCurrentExtensionName(), 'update', $ver, getExtensionDryRun());
+ loadExtension(getCurrentExtensionName(), 'update', $ver, isExtensionDryRun());
// Add update notes to our output
addExtensionNotes($ver);
@@ -254,7 +260,7 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
// Check if extension is not installed and not already in registration procedure and if loading it wents finally fine...
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',isExtensionRegistrationRunning(' . $ext_update . ')=' . intval(isExtensionRegistrationRunning($ext_update)));
- if ((!isExtensionInstalled($ext_update)) && (!isExtensionRegistrationRunning($ext_update)) && (loadExtension($ext_update, 'test', '', getExtensionDryRun()))) {
+ if ((!isExtensionInstalled($ext_update)) && (!isExtensionRegistrationRunning($ext_update)) && (loadExtension($ext_update, 'test', '', isExtensionDryRun()))) {
// Set current extension name again
setCurrentExtensionName($ext_name);
@@ -274,19 +280,19 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
if ($task > 0) {
// Try to register the extension
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ':ext_update=' . $ext_update . ',taskId=' . $task);
- $test = registerExtension($ext_update, $task, getExtensionDryRun(), false);
+ $test = registerExtension($ext_update, $task, isExtensionDryRun(), false);
// Reset extension name
setCurrentExtensionName($ext_name);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName());
- //* DEBUG: */ print getCurrentExtensionName().':
' . print_r($test, true) . '
';
+ //* DEBUG: */ debugOutput(getCurrentExtensionName().':' . print_r($test, true) . '
');
} // END - if
} elseif ($ext_ver != getCurrentExtensionVersion()) {
// Ok, update this extension now
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',currVer=' . getCurrentExtensionVersion());
$GLOBALS['ext_backup_name'][$ext_update][$ext_ver] = getCurrentExtensionName();
$GLOBALS['ext_backup_ver'][$ext_update][$ext_ver] = getCurrentExtensionVersion();
- updateExtension($ext_update, $ext_ver, getExtensionDryRun());
+ updateExtension($ext_update, $ext_ver, isExtensionDryRun());
setCurrentExtensionName($GLOBALS['ext_backup_name'][$ext_update][$ext_ver]);
setCurrentExtensionVersion($GLOBALS['ext_backup_ver'][$ext_update][$ext_ver]);
unset($GLOBALS['ext_backup_name'][$ext_update][$ext_ver]);
@@ -320,22 +326,22 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
// Remains true if extension registration reports no failures
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName());
- //* DEBUG: */ print getCurrentExtensionName().':' . print_r($test, true) . '
';
+ //* DEBUG: */ debugOutput(getCurrentExtensionName().':' . print_r($test, true) . '
');
$test = (($test === true) && (getExtensionReportsFailure() === false));
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName());
- //* DEBUG: */ print getCurrentExtensionName().':' . print_r($test, true) . '
';
+ //* DEBUG: */ debugOutput(getCurrentExtensionName().':' . print_r($test, true) . '
');
// Does everthing before wents ok?
if ($test === true) {
// "Dry-run-mode" activated?
- if ((getExtensionDryRun() === false) && (!isExtensionOnRemovalList())) {
+ if ((isExtensionDryRun() === false) && (!isExtensionOnRemovalList())) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName());
// Init SQLs and transfer ext->generic
initSqls();
setSqlsArray(getExtensionSqls());
// Run installation pre-installation filters
- runFilterChain('pre_extension_installed', array('dry_run' => getExtensionDryRun()));
+ runFilterChain('pre_extension_installed', array('dry_run' => isExtensionDryRun()));
// Register extension
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'insert=' . getCurrentExtensionName() . '/' . getCurrentExtensionVersion() . ' - INSERT!');
@@ -364,7 +370,7 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
runFilterChain('post_extension_installed', array(
'pool' => 'extension',
'ext_name' => getCurrentExtensionName(),
- 'task_id' => $task_id
+ 'task_id' => $taskId
));
// Re-init queries and notes
@@ -376,12 +382,11 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
// In normal mode return a true on success
$ret = true;
- } elseif (getExtensionDryRun() === true) {
- // In "dry-run" mode return array with all SQL commands
- $ret = getExtensionSqls();
+ } elseif (isExtensionDryRun() === true) {
+ // In "dry-run" mode do always return a true
+ $ret = true;
// Re-init queries and notes
- initExtensionSqls(true);
initExtensionNotes();
} else {
// Extension has been removed for updates, so all is fine!
@@ -392,16 +397,16 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName());
$ret = false;
}
- } elseif (($task_id > 0) && (getCurrentExtensionName() != '')) {
+ } elseif (($taskId > 0) && (getCurrentExtensionName() != '')) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName());
// Remove task from system when id and extension's name is valid
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
- array(bigintval($task_id)), __FUNCTION__, __LINE__);
+ array(bigintval($taskId)), __FUNCTION__, __LINE__);
}
// Is this the sql_patches?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName() . '/' . getExtensionMode());
- if ((getCurrentExtensionName() == 'sql_patches') && ((getExtensionMode() == 'register') || (getExtensionMode() == 'remove')) && (!getExtensionDryRun()) && ($test)) {
+ if ((getCurrentExtensionName() == 'sql_patches') && ((getExtensionMode() == 'register') || (getExtensionMode() == 'remove')) && (!isExtensionDryRun()) && ($test)) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName() . ': LOAD!');
if ($logout === true) {
// Then redirect to logout
@@ -415,7 +420,7 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
// Return status code
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ' - EXIT!');
- //* DEBUG: */ print getCurrentExtensionName().':'.print_r($ret, true).'
';
+ //* DEBUG: */ debugOutput(getCurrentExtensionName().':'.print_r($ret, true).'
');
return $ret;
}
@@ -537,7 +542,7 @@ function isExtensionActive ($ext_name) {
incrementStatsEntry('cache_hits');
} elseif (isset($GLOBALS['ext_loaded'][$ext_name])) {
// @TODO Extension is loaded, what next?
- app_die(__FUNCTION__, __LINE__, 'LOADED:' . $ext_name);
+ debug_report_bug(__FUNCTION__, __LINE__, 'LOADED:' . $ext_name);
} elseif (($ext_name == 'cache') || (!isExtensionInstalled('cache'))) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "DB! ext_name={$ext_name}");
// Load from database
@@ -577,7 +582,7 @@ function getExtensionVersion ($ext_name, $force = false) {
// Empty extension name should be fixed!
if (empty($ext_name)) {
// Please report this bug!
- debug_report_bug(__FUNCTION__ . ': ext_name is empty which is not allowed here.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'ext_name is empty which is not allowed here.');
} // END - if
// Extensions are all inactive during installation
@@ -604,7 +609,7 @@ function getExtensionVersion ($ext_name, $force = false) {
$data = SQL_FETCHARRAY($result);
} elseif (isDebugModeEnabled()) {
// Not found, please report all
- debug_report_bug(sprintf(": Cannot find extension %s in database!", $ext_name));
+ debug_report_bug(__FUNCTION__, __LINE__, sprintf(": Cannot find extension %s in database!", $ext_name));
}
// Free result
@@ -617,7 +622,7 @@ function getExtensionVersion ($ext_name, $force = false) {
// Extension version should not be invalid
if (($data['ext_version'] == 'false') && ($force === false)) {
// Please report this trouble
- debug_report_bug(sprintf("Extension %s has empty version!", $ext_name));
+ debug_report_bug(__FUNCTION__, __LINE__, sprintf("Extension %s has empty version!", $ext_name));
} // END - if
// Return result
@@ -639,7 +644,7 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
initIncludePool('extension');
// Load extension in test mode
- loadExtension($ext_name, 'test', $ext_ver, getExtensionDryRun());
+ loadExtension($ext_name, 'test', $ext_ver, isExtensionDryRun());
// Save version history
$history = getExtensionVersionHistory();
@@ -648,8 +653,8 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
initExtensionSqls();
// Check if version is updated
- //* DEBUG: */ print getCurrentExtensionName().'/'.$ext_name.':'.getThisExtensionVersion().'/'.$ext_ver.'/'.intval(is_array($history)).'
';
- if (((getThisExtensionVersion() != $ext_ver) || (getExtensionDryRun())) && (is_array($history))) {
+ //* DEBUG: */ debugOutput(getCurrentExtensionName().'/'.$ext_name.':'.getThisExtensionVersion().'/'.$ext_ver.'/'.intval(is_array($history)));
+ if (((getThisExtensionVersion() != $ext_ver) || (isExtensionDryRun())) && (is_array($history))) {
// Search for starting point
$start = array_search($ext_ver, $history);
@@ -659,7 +664,7 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
$GLOBALS['update_ver'][getCurrentExtensionName()] = $history[$idx];
// Load again...
- loadExtension(getCurrentExtensionName(), 'update', $GLOBALS['update_ver'][getCurrentExtensionName()], getExtensionDryRun());
+ loadExtension(getCurrentExtensionName(), 'update', $GLOBALS['update_ver'][getCurrentExtensionName()], isExtensionDryRun());
// Get all depencies
$depencies = getExtensionUpdateDependencies();
@@ -679,10 +684,10 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
// Is the extension there?
if (isExtensionInstalled($ext_depend)) {
// Update another extension first!
- $test = updateExtension($ext_depend, getExtensionVersion($ext_depend), getExtensionDryRun());
+ $test = updateExtension($ext_depend, getExtensionVersion($ext_depend), isExtensionDryRun());
} else {
// Register new extension
- $test = registerExtension($ext_depend, 0, getExtensionDryRun(), false);
+ $test = registerExtension($ext_depend, 0, isExtensionDryRun(), false);
}
} // END - if
} // END - foreach
@@ -699,7 +704,7 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
} // END - for
// In real-mode execute any existing includes
- if (getExtensionDryRun() === false) {
+ if (isExtensionDryRun() === false) {
$GLOBALS['ext_inc_pool'][getCurrentExtensionName()] = getIncludePool('extension');
runFilterChain('load_includes', 'extension');
setIncludePool('extension', $GLOBALS['ext_inc_pool'][getCurrentExtensionName()]);
@@ -711,9 +716,9 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
setSqlsArray(getExtensionSqls());
// Run SQLs
- runFilterChain('run_sqls', array('dry_run' => getExtensionDryRun()));
+ runFilterChain('run_sqls', array('dry_run' => isExtensionDryRun()));
- if (getExtensionDryRun() === false) {
+ if (isExtensionDryRun() === false) {
// Run filters on success extension update
runFilterChain('extension_update', getCurrentExtensionName());
} // END - if
@@ -725,7 +730,7 @@ function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false
// Empty title?
if (empty($title)) {
// Then fix it to default
- $title = getMessage('ADMIN_SQLS_EXECUTED_ON_REMOVAL');
+ $title = '{--ADMIN_SQLS_EXECUTED_ON_REMOVAL--}';
} // END - if
// Init variables
@@ -733,9 +738,6 @@ function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false
// Do we have queries?
if ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y')) {
- // Init switch color
- $SW = 2;
-
// Get all SQLs
foreach (getExtensionSqls() as $sqls) {
// New array format is recursive
@@ -747,16 +749,12 @@ function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false
if (!empty($sql)) {
// Prepare output for template
$content = array(
- 'sw' => $SW,
'i' => ($idx+1),
'sql' => $sql
);
// Load row template
$OUT .= loadTemplate('admin_ext_sql_row', true, $content);
-
- // Switch color
- $SW = 3 - $SW;
} // END - if
} // END - foreach
} // END - foreach
@@ -773,7 +771,7 @@ function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false
$OUT = loadTemplate('admin_ext_sql_table', true, $content);
} elseif ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y')) {
// No addional SQL commands to run
- $OUT = loadTemplate('admin_settings_saved', true, getMessage('ADMIN_NO_ADDITIONAL_SQLS'));
+ $OUT = loadTemplate('admin_settings_saved', true, '{--ADMIN_NO_ADDITIONAL_SQLS--}');
} // END - if
// Return output
@@ -810,7 +808,7 @@ function getExtensionName ($ext_id) {
// Did we find some extension?
if (empty($data['ext_name'])) {
// We should fix these all!
- debug_report_bug(__FUNCTION__ . ': ext_name is empty. ext_id=' . $ext_id);
+ debug_report_bug(__FUNCTION__, __LINE__, 'ext_name is empty. ext_id=' . $ext_id);
} // END - if
// Return the extension name
@@ -911,12 +909,12 @@ function doDeactivateExtension($ext_name) {
// Then run all queries
doExtensionSqls(getExtensionId($ext_name), 'deactivate');
- // Create new task
+ // Create new task (we ignore the task id here)
createExtensionDeactivationTask($ext_name);
// Notify the admin
sendAdminNotification(
- getMessage('ADMIN_SUBJECT_EXTENSION_DEACTIVATED'),
+ '{--ADMIN_EXTENSION_DEACTIVATED_SUBJECT--}',
'admin_ext_deactivated',
array('ext_name' => $ext_name)
);
@@ -939,59 +937,80 @@ function isExtensionOlder ($ext_name, $ext_ver) {
// Creates a new task for updated extension
function createExtensionUpdateTask ($adminId, $ext_name, $ext_ver, $notes) {
// Create subject line
- $subject = '[UPDATE-' . $ext_name . '-' . $ext_ver . ':] {--ADMIN_UPDATE_EXT_SUBJ--}';
+ $subject = '[UPDATE-' . $ext_name . '-' . $ext_ver . ':] {--ADMIN_UPDATE_EXTENSION_SUBJECT--}';
+
+ // Get task id
+ $taskId = determineTaskIdBySubject($subject);
// Is the extension there?
if (isExtensionInstalled($ext_name)) {
// Check if task is not there
- if (determineTaskIdBySubject($subject) == '0') {
+ if ($taskId == '0') {
// Create extension update-task
- createNewTask($subject, $notes, 'EXTENSION_UPDATE', 0, $adminId);
+ $taskId = createNewTask($subject, $notes, 'EXTENSION_UPDATE', 0, $adminId);
} // END - if
} else {
// Extension not there! :-(
- debug_report_bug(sprintf("Extension %s not found but should be updated?", $ext_name));
+ debug_report_bug(__FUNCTION__, __LINE__, sprintf("Extension %s not found but should be updated?", $ext_name));
}
+
+ // Return task id
+ return $taskId;
}
// Creates a new task for newly installed extension
-function createNewExtensionTask ($adminId, $subject, $ext) {
+function createNewExtensionTask ($ext_name) {
+ // Generate subject line
+ $subject = sprintf("[%s:]", $ext_name);
+
+ // Get task id
+ $taskId = determineTaskIdBySubject($subject);
+
// Not installed and do we have created a task for the admin?
- if ((determineTaskIdBySubject($subject) == '0') && (!isExtensionInstalled($ext))) {
+ if (($taskId == '0') && (!isExtensionInstalled($ext_name))) {
// Set default message if ext-foo is missing
- $message = getMaskedMessage('ADMIN_EXT_TEXT_FILE_MISSING', $ext);
+ $message = getMaskedMessage('ADMIN_EXTENSION_TEXT_FILE_MISSING', $ext_name);
// Template file
$tpl = sprintf("%stemplates/%s/html/ext/ext_%s.tpl",
getConfig('PATH'),
getLanguage(),
- $ext
+ $ext_name
);
// Load text for task if found
if (isFileReadable($tpl)) {
// Load extension's own text template (HTML!)
- $message = loadTemplate('ext_' . $ext, true);
+ $message = loadTemplate('ext_' . $ext_name, true);
} else {
// Write this in debug.log as well
logDebugMessage(__FUNCTION__, __LINE__, $message);
}
// Task not created so it's a brand-new extension which we need to register and create a task for!
- createNewTask($subject, $message, 'EXTENSION', 0, $adminId, false);
+ $taskId = createNewTask($subject, $message, 'EXTENSION', 0, getCurrentAdminId(), false);
} // END - if
+
+ // Return task id
+ return $taskId;
}
// Creates a task for automatically deactivated (deprecated) extension
-function createExtensionDeactivationTask ($ext) {
+function createExtensionDeactivationTask ($ext_name) {
// Create subject line
- $subject = sprintf("[%s:] %s", $ext, getMessage('TASK_SUBJ_EXTENSION_DEACTIVATED'));
+ $subject = sprintf("[%s:] %s", $ext_name, '{--ADMIN_TASK_EXTENSION_DEACTIVATED_SUBJECT--}');
+
+ // Get task id
+ $taskId = determineTaskIdBySubject($subject);
// Not installed and do we have created a task for the admin?
- if ((determineTaskIdBySubject($subject) == '0') && (isExtensionInstalled($ext))) {
+ if (($taskId == '0') && (isExtensionInstalled($ext_name))) {
// Task not created so add it
- createNewTask($subject, SQL_ESCAPE(loadTemplate('task_ext_deactivated', true, $ext)), 'EXTENSION_DEACTIVATION');
+ $taskId = createNewTask($subject, SQL_ESCAPE(loadTemplate('task_EXTENSION_deactivated', true, $ext_name)), 'EXTENSION_DEACTIVATION');
} // END - if
+
+ // Return task id
+ return $taskId;
}
// Checks if the module has a menu
@@ -1110,18 +1129,18 @@ function addExtensionNotes ($ver) {
// Initial release
$content = array(
'ver' => $ver,
- 'notes' => getMessage('INITIAL_RELEASE')
+ 'notes' => '{--INITIAL_RELEASE--}'
);
} else {
// No update notes found!
$content = array(
'ver' => $ver,
- 'notes' => getMessage('NO_UPDATE_NOTES')
+ 'notes' => '{--NO_UPDATE_NOTES--}'
);
}
// Load template
- $out = loadTemplate('admin_ext_notes', true, $content);
+ $out = loadTemplate('admin_EXTENSION_notes', true, $content);
} // END - if
// Add the notes
@@ -1202,14 +1221,14 @@ function addExtensionUpdateDependency ($updateDepends) {
// Is the update depency empty? (NEED TO BE FIXED!)
if (empty($updateDepends)) {
// Please report this bug!
- debug_report_bug('updateDepends is empty: currentExtension=' . getCurrentExtensionName());
+ debug_report_bug(__FUNCTION__, __LINE__, 'updateDepends is empty: currentExtension=' . getCurrentExtensionName());
} // END - if
// Is it not yet added?
/* DEBUG:
if ((isset($updateDepends, $GLOBALS['ext_running_updates'][getCurrentExtensionName()])) && (in_array($updateDepends, getExtensionUpdatesRunning()))) {
// Double-adding isn't fine, too
- debug_report_bug(__FUNCTION__ . '() called twice: updateDepends=' . $updateDepends . ',currentExtension=' . getCurrentExtensionName());
+ debug_report_bug(__FUNCTION__, __LINE__, '() called twice: updateDepends=' . $updateDepends . ',currentExtension=' . getCurrentExtensionName());
} // END - if
*/
@@ -1243,7 +1262,7 @@ function initExtensionUpdateDependencies () {
// Init update depency map automatically if not found
if (isExtensionUpdateDependenciesInitialized()) {
// We need these bug reports as well...
- debug_report_bug(__FUNCTION__ . '() is called twice: currName=' . getCurrentExtensionName());
+ debug_report_bug(__FUNCTION__, __LINE__, '() is called twice: currName=' . getCurrentExtensionName());
} // END - if
$GLOBALS['ext_update_depends'][getCurrentExtensionName()] = array();
@@ -1260,7 +1279,7 @@ function addExtensionRunningRegistration ($ext_name) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Registration in progress: ext_name=' . $ext_name . ' - ENTERED!');
if (isExtensionRegistrationRunning($ext_name)) {
// This is really bad and should not be quietly ignored
- debug_report_bug(__FUNCTION__ . '() already called! ext_name=' . $ext_name);
+ debug_report_bug(__FUNCTION__, __LINE__, '() already called! ext_name=' . $ext_name);
} // END - if
// Then add it!
@@ -1427,17 +1446,17 @@ function getExtensionNotes () {
// Setter for current extension name
function setCurrentExtensionName ($ext_name) {
- $GLOBALS['curr_ext_name'] = (string) trim($ext_name);
+ $GLOBALS['curr_EXTENSION_name'] = (string) trim($ext_name);
}
// Getter for current extension name
function getCurrentExtensionName () {
- if (isset($GLOBALS['curr_ext_name'])) {
- return $GLOBALS['curr_ext_name'];
+ if (isset($GLOBALS['curr_EXTENSION_name'])) {
+ return $GLOBALS['curr_EXTENSION_name'];
} // END - if
// Not set!
- debug_report_bug(__FUNCTION__.": curr_ext_name not initialized. Please execute initExtensionSqls() before calling this function.");
+ debug_report_bug(__FUNCTION__.": curr_EXTENSION_name not initialized. Please execute initExtensionSqls() before calling this function.");
}
// Init SQLs array for current extension
@@ -1463,7 +1482,7 @@ function getExtensionSqls () {
// Output debug backtrace if not found (SHOULD NOT HAPPEN!)
if (!isset($GLOBALS['ext_sqls'][getCurrentExtensionName()])) {
// Not found, should not happen
- debug_report_bug(sprintf("ext_sqls is empty, current extension: %s",
+ debug_report_bug(__FUNCTION__, __LINE__, sprintf("ext_sqls is empty, current extension: %s",
getCurrentExtensionName()
));
} // END - if
@@ -1546,12 +1565,12 @@ function getExtensionMode () {
// Setter for dry-run
function enableExtensionDryRun ($dry_run = true) {
- //* DEBUG: */ print __FUNCTION__.': '.getCurrentExtensionName().'='.intval($dry_run).'
';
+ //* DEBUG: */ debugOutput(__FUNCTION__.': '.getCurrentExtensionName().'='.intval($dry_run));
$GLOBALS['ext_dry_run'] = (bool) $dry_run;
}
// Getter for dry-run
-function getExtensionDryRun () {
+function isExtensionDryRun () {
return $GLOBALS['ext_dry_run'];
}
@@ -1560,7 +1579,7 @@ function setCurrentExtensionVersion ($ext_ver) {
// ext_ver should never be empty in other modes than 'test'
if ((empty($ext_ver)) && (getExtensionMode() != 'test')) {
// Please report all these messages
- debug_report_bug('ext_ver is empty. Current extension name: ' . getCurrentExtensionName() . ', mode=' . getExtensionMode());
+ debug_report_bug(__FUNCTION__, __LINE__, 'ext_ver is empty. Current extension name: ' . getCurrentExtensionName() . ', mode=' . getExtensionMode());
} // END - if
// Add version
@@ -1657,7 +1676,7 @@ function loadExtensionInclude () {
// Is it readable?
if (!isExtensionIncludeReadable()) {
// Not readable
- debug_report_bug('Extension ' . getCurrentExtensionName() . ' should be loaded, but is not readable.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Extension ' . getCurrentExtensionName() . ' should be loaded, but is not readable.');
} // END - if
// Generate INC name