Task-create functions does now return a task id. We use that to help registering...
authorRoland Häder <roland@mxchange.org>
Mon, 28 Jun 2010 19:25:00 +0000 (19:25 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 28 Jun 2010 19:25:00 +0000 (19:25 +0000)
inc/extensions-functions.php
inc/filters.php
inc/libs/rallye_functions.php
inc/modules/admin/overview-inc.php
inc/modules/member/what-holiday.php
inc/modules/member/what-payout.php
inc/modules/member/what-support.php
inc/modules/order.php
inc/mysql-manager.php

index 48397e9..80513f4 100644 (file)
@@ -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 <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
index 658e0fb..260648a 100644 (file)
@@ -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
index e4dff31..3ff1059 100644 (file)
@@ -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
 
index e5d3f0c..022b93b 100644 (file)
@@ -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
index 18742cc..fc3b735 100644 (file)
@@ -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
index 1fecd69..f1bf551 100644 (file)
@@ -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
index 285dc0b..a8ceb41 100644 (file)
@@ -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
index 3964d68..338a653 100644 (file)
@@ -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--}',
                        '<pre>'.loadEmailTemplate('order-admin', $content, getMemberId()).'</pre>',
index 559361d..1621110 100644 (file)
@@ -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