]> git.mxchange.org Git - mailer.git/commitdiff
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 48397e939e8c00c5a25ffdef1e6690ef9b6e9630..80513f4db8478e3085293586cfc3638ca45c0a5d 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 658e0fb17b3098989e5192ddd9cdff28e6abb19b..260648a31993ed55ca683d1887ebdd876aa77163 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 e4dff31d0279ebbfdcc2aef7a5053bafa1960232..3ff1059c5a7533e2f27081e5c9c018d4700531e3 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 e5d3f0cdcb582432029dad0c73e11306daa4b2ab..022b93b7f1045ea8f10e04114c89703047d1de22 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 18742ccd1467e6b5fa284d9b0106020523404d3d..fc3b735786cd1b1565ef6d766bbb3e059080a287 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 1fecd697b33fcc3e38350b3a60c62764d82ab1de..f1bf55152ab5b08e5417c2cea804120342648fe4 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 285dc0b1ebd560e0b21167fe8fcb7e19cd70bc2b..a8ceb41050dd02872d117e7c5654ab30f7ad501e 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 3964d689f937f069813fc85fcdc9bda2316d257f..338a6530b692843c21bc028b2f2c3565dba32c32 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 559361db9299319e28dc91a10fc0bf390e66ba3e..16211103a2763161acb911d6ab36d7007a48156b 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