// Still zero and not in dry-run?
if (($task_id == '0') && (!isExtensionDryRun())) {
- // Then request a bug report
- debug_report_bug(__FUNCTION__, __LINE__, sprintf("%s: task_id is still zero after determineExtensionTaskId(%s)",
- __FUNCTION__,
- getCurrentExtensionName()
- ));
+ // Now try to create a new task
+ $task_id = 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
// 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
// Create subject line
$subject = '[UPDATE-' . $ext_name . '-' . $ext_ver . ':] {--ADMIN_UPDATE_EXTENSION_SUBJ--}';
+ // 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(__FUNCTION__, __LINE__, sprintf("Extension <span class=\"data\">%s</span> 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_EXTENSION_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, '{--TASK_SUBJ_EXTENSION_DEACTIVATED--}');
+ $subject = sprintf("[%s:] %s", $ext_name, '{--TASK_SUBJ_EXTENSION_DEACTIVATED--}');
+
+ // 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_EXTENSION_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