From: Roland Häder Date: Mon, 28 Jun 2010 19:25:00 +0000 (+0000) Subject: Task-create functions does now return a task id. We use that to help registering... X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=6b9595ec5034045297bb3461e715a28a4edbde60 Task-create functions does now return a task id. We use that to help registering a new extension which has no task entry yet while we update an already installed extension --- diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 48397e939e..80513f4db8 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -206,11 +206,17 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru // 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 @@ -910,7 +916,7 @@ 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 @@ -940,57 +946,78 @@ function createExtensionUpdateTask ($adminId, $ext_name, $ext_ver, $notes) { // 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 %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_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 diff --git a/inc/filters.php b/inc/filters.php index 658e0fb17b..260648a319 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -519,7 +519,7 @@ function FILTER_COMPILE_EXPRESSION_CODE ($code) { // Runs some generic filter update steps function FILTER_UPDATE_EXTENSION_DATA ($ext_name) { - // Create task + // Create task (we ignore the task id here) createExtensionUpdateTask(getCurrentAdminId(), $ext_name, $GLOBALS['update_ver'][$ext_name], SQL_ESCAPE(getExtensionNotes(getExtensionNotes()))); // Update extension's version diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index e4dff31d02..3ff1059c5a 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -551,7 +551,7 @@ function markReferalRallyesAsExpired ($result) { // Send mail to admin sendAdminNotification(getMaskedMessage('RALLYE_ADMIN_EXPIRED_SUBJ', $title), $templ, $cnt); - // Add task + // Add task (we ignore the task id here) createNewTask('{--RALLYE_ADMIN_EXPIRED--}: ' . $title, '{--RALLYE_ADMIN_EXPIRED_TEXT--}', 'RALLYE_EXPIRED'); } @@ -808,7 +808,7 @@ WHERE addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_users` WHERE `rallye_id`=%s LIMIT 1", array(bigintval($content['id'])), __FUNCTION__, __LINE__, false)); - // Add task + // Add task (we ignore the task id here createNewTask('{--RALLYE_ADMIN_PURGED--}: ' . $content['title'], '{--RALLYE_ADMIN_PURGED_TEXT--}', 'RALLYE_PURGED'); } // END - while diff --git a/inc/modules/admin/overview-inc.php b/inc/modules/admin/overview-inc.php index e5d3f0cdcb..022b93b7f1 100644 --- a/inc/modules/admin/overview-inc.php +++ b/inc/modules/admin/overview-inc.php @@ -71,13 +71,10 @@ function outputStandardOverview (&$result_tasks) { // Is the extension not yet installed? if ($extInstalled === false) { - // Generate subject line - $ext_subj = sprintf("[%s:]", $ext_name); - // We maybe want to install an extension so let's test-drive it... if (loadExtension($ext_name, getExtensionMode(), '', true)) { - // Create a task for newly installed extension - createNewExtensionTask(getCurrentAdminId(), $ext_subj, $ext_name); + // Create a task for newly installed extension (we ignore the task id here) + createNewExtensionTask($ext_name); } // END - if } else { // Test-drive extension in update mode diff --git a/inc/modules/member/what-holiday.php b/inc/modules/member/what-holiday.php index 18742ccd14..fc3b735786 100644 --- a/inc/modules/member/what-holiday.php +++ b/inc/modules/member/what-holiday.php @@ -150,7 +150,7 @@ LIMIT 1", // Send mail to all admins sendAdminNotification(getMessage('HOLIDAY_ADMIN_SUBJECT'), 'admin_holiday_request', $content, getMemberId()); - // Create task + // Create task (we ignore the task id here) createNewTask('{--HOLIDAY_ADMIN_SUBJECT--}', $message, 'HOLIDAY_REQUEST', getMemberId()); // Display message diff --git a/inc/modules/member/what-payout.php b/inc/modules/member/what-payout.php index 1fecd697b3..f1bf55152a 100644 --- a/inc/modules/member/what-payout.php +++ b/inc/modules/member/what-payout.php @@ -225,7 +225,7 @@ VALUES (%s,%s,%s,'%s',%s, UNIX_TIMESTAMP(), 'NEW','%s')", } // END - if } - // Generate task + // Generate task (we ignore the task id here) createNewTask('[payout:] {--ADMIN_PAYOUY_REQUEST_SUBJ--}', $message_adm, 'PAYOUT_REQUEST', getMemberId()); // Send out mails diff --git a/inc/modules/member/what-support.php b/inc/modules/member/what-support.php index 285dc0b1eb..a8ceb41050 100644 --- a/inc/modules/member/what-support.php +++ b/inc/modules/member/what-support.php @@ -88,7 +88,7 @@ if ((!isFormSent()) || (!isPostRequestParameterSet(('qsummary')))) { // Send mail to user sendEmail(getMemberId(), $subj_m, $message_m); - // Drop a message in the admin's area + // Drop a message in the admin's area (we ignore the task id here) createNewTask($subj_a, postRequestParameter('qsummary') . ' : ' . postRequestParameter('qdetails'), 'SUPPORT_MEMBER', getMemberId()); // Form sent diff --git a/inc/modules/order.php b/inc/modules/order.php index 3964d689f9..338a6530b6 100644 --- a/inc/modules/order.php +++ b/inc/modules/order.php @@ -106,7 +106,7 @@ if (empty($url)) { // Notify admins about this sendAdminNotification(getMessage('ADMIN_NEW_QUEUE'), 'order-admin', $content, getMemberId()); - // Create new task + // Create new task (we ignore the task id here) createNewTask( '{--ADMIN_NEW_QUEUE--}', '
'.loadEmailTemplate('order-admin', $content, getMemberId()).'
', diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 559361db92..16211103a2 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -2142,6 +2142,9 @@ function createNewTask ($subject, $notes, $taskType, $userid = '0', $adminId = ' $subject, $notes ), __FUNCTION__, __LINE__, true, $strip); + + // Return insert id which is the task id + return SQL_INSERTID(); } // Updates last module / online time