]> git.mxchange.org Git - mailer.git/commitdiff
Improvements to task extension
authorRoland Häder <roland@mxchange.org>
Tue, 9 Sep 2008 17:11:53 +0000 (17:11 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 9 Sep 2008 17:11:53 +0000 (17:11 +0000)
inc/databases.php
inc/extensions.php
inc/libs/admins_functions.php
inc/modules/admin/admin-inc.php
inc/modules/admin/overview-inc.php
inc/modules/admin/what-list_newsletter.php
inc/modules/admin/what-list_payouts.php
inc/modules/admin/what-list_task.php

index 01d9d3ddd0019cc0bdc3c2b83e636dd8bf678e3f..c4e612d78fbca7700fefe8a01ea2933037898320 100644 (file)
@@ -114,7 +114,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "283");
+define('CURR_SVN_REVISION', "284");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index f566d1dfc898094ba60466c84369bc458d620ca5..711a3d163966b7e40f4f43ed01e9d723bec4b04a 100644 (file)
@@ -198,8 +198,7 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
                                 array($ext_name, $EXT_LANG_PREFIX, $EXT_ALWAYS_ACTIVE, $EXT_VERSION), __FILE__, __LINE__);
 
                                // Update task management
-                               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET status='SOLVED' WHERE id=%s LIMIT 1",
-                                array(bigintval($id)), __FILE__, __LINE__);
+                               ADMIN_SOLVE_TASK($id);
 
                                // In normal mode return a true on success
                                $ret = true; unset($SQLs);
index 8b017261f81a614e696687ec01c20875ac24683b..a2964387bbe1ef9de9a0c6f81f7f3f7c8d9851d9 100644 (file)
@@ -370,7 +370,7 @@ function ADMINS_REMOVE_ADMIN_ACCOUNTS ($POST) {
                // Delete only when it's not your own account!
                if (($del == 1) && (GET_ADMIN_ID(get_session('admin_login')) != $id)) {
                        // Rewrite his tasks to all admins
-                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin='0' WHERE assigned_admin='%s'",
+                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin=0 WHERE assigned_admin=%s",
                         array($id), __FILE__, __LINE__);
 
                        // Remove account
index 0534befa518cde1010f7375536ab3012f14cb605..2fe4a3a1f04ac40114ae029949576ff63f4b264c 100644 (file)
@@ -1002,5 +1002,21 @@ function ADMIN_RESET_PASSWORD ($login, $password) {
        // Return output
        return ADMIN_PASSWORD_RESET_DONE;
 }
+// Solves a task by given id number
+function ADMIN_SOLVE_TASK ($id) {
+       // Update the task data
+       ADMIN_UPDATE_TASK_DATA($id, "status", "SOLVED");
+}
+// Marks a given task as deleted
+function ADMIN_DELETE_TASK ($id) {
+       // Update the task data
+       ADMIN_UPDATE_TASK_DATA($id, "status", "DELETED");
+}
+// Function to update task data
+function ADMIN_UPDATE_TASK_DATA ($id, $row, $data) {
+       // Update the task
+       SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET %s='%s' WHERE id=%s LIMIT 1",
+               array($row, $data, bigintval($id)), __FILE__, __LINE__);
+}
 //
 ?>
index 6fdcafcf5676fbf3118d78782da0a6f2acfdf847..aa2f8e7103a4af865071b84c869b4130680c60aa 100644 (file)
@@ -290,10 +290,8 @@ function OUTPUT_SELECTED_TASKS($_POST, $result_tasks) {
                                                $OUT .= "<FONT class=\"admin_failed\">".ADMIN_EXT_ALREADY_REGISTERED."</FONT>\n";
 
                                                // Close task but not already closes or deleted or update tasks
-                                               if (($status != "CLOSED") && ($status != "DELETED") && ($type != "EXTENSION_UPDATE"))
-                                               {
-                                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET status='SOLVED' WHERE id=%s LIMIT 1",
-                                                        array(bigintval($tid)), __FILE__, __LINE__);
+                                               if (($status != "CLOSED") && ($status != "DELETED") && ($type != "EXTENSION_UPDATE")) {
+                                                       ADMIN_SOLVE_TASK($tid);
                                                }
                                        }
                                        break;
@@ -304,8 +302,8 @@ function OUTPUT_SELECTED_TASKS($_POST, $result_tasks) {
 
                                        // Close task
                                        if (($status != "CLOSED") && ($status != "DELETED")) {
-                                               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET status='SOLVED' WHERE id=%s LIMIT 1",
-                                                array(bigintval($tid)), __FILE__, __LINE__);
+                                               // Solve the task
+                                               ADMIN_SOLVE_TASK($tid);
                                        }
                                        break;
 
@@ -431,7 +429,7 @@ function OUTPUT_SELECTED_TASKS($_POST, $result_tasks) {
                                // Unassign from tasks
                                foreach ($_POST['task'] as $id=>$sel)
                                {
-                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin='0' WHERE id=%s AND assigned_admin='%s' LIMIT 1",
+                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin=0 WHERE id=%s AND assigned_admin=%s LIMIT 1",
                                         array(bigintval($id), GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
                                }
                        }
@@ -440,13 +438,13 @@ function OUTPUT_SELECTED_TASKS($_POST, $result_tasks) {
                                // Delete tasks
                                foreach ($_POST['task'] as $id=>$sel)
                                {
-                                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE id=%s AND (assigned_admin='%s' OR assigned_admin='0') LIMIT 1",
+                                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE id=%s AND assigned_admin IN (%s,0) LIMIT 1",
                                         array(bigintval($id), GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
                                }
                        }
 
                        // Update query
-                       $result_tasks = SQL_QUERY_ESC("SELECT id, assigned_admin, userid, task_type, subject, text, task_created FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='%s' OR (assigned_admin='0' AND status='NEW') ORDER BY task_created DESC",
+                       $result_tasks = SQL_QUERY_ESC("SELECT id, assigned_admin, userid, task_type, subject, text, task_created FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin=%s OR (assigned_admin=0 AND status='NEW') ORDER BY task_created DESC",
                         array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
                }
 
index 93ec1c91a9d47f9f852f97cd26c0dcbd34308466..0c668e838763926eb28023c9770f2a43085ac728 100644 (file)
@@ -49,8 +49,7 @@ if ((!empty($_POST['uid'])) && (!empty($_POST['id'])))
         array(bigintval($_POST['uid'])), __FILE__, __LINE__);
 
        // Next the task system...
-       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET status='SOLVED' WHERE id=%s LIMIT 1",
-        array(bigintval($_POST['id'])), __FILE__, __LINE__);
+       ADMIN_SOLVE_TASK($_POST['id']);
 
        // Send mail to user
        $msg = LOAD_EMAIL_TEMPLATE("member_newsletter_done", true, bigintval($_POST['uid']));
index 737863132ab7aceaa04cf934894190ff6f74b906..a4d1dc66bc80401040c21bfbf636cdc126ed89b8 100644 (file)
@@ -134,10 +134,8 @@ if (!empty($_GET['pid']))
                                        if ($ret[0] == $eok)
                                        {
                                                // Clear task
-                                               if ($task > 0)
-                                               {
-                                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET status='SOLVED' WHERE id=%s LIMIT 1",
-                                                        array(bigintval($task)),__FILE__, __LINE__);
+                                               if ($task > 0) {
+                                                       ADMIN_SOLVE_TASK($task);
                                                }
 
                                                // Clear payout request
@@ -186,11 +184,9 @@ if (!empty($_GET['pid']))
                        // Ok, now we can output the form or execute rejecting
                        if (isset($_POST['ok']))
                        {
-                               if ($task > 0)
-                               {
+                               if ($task > 0) {
                                        // Clear task
-                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET status='SOLVED' WHERE id=%s LIMIT 1",
-                                        array(bigintval($task)), __FILE__, __LINE__);
+                                       ADMIN_SOLVE_TASK($task);
                                }
 
                                // Clear payout request
index 5ac8fff0b1f45e0df1878483ad575b3524eda804..110dab5a88b3d825e791312444a6c3b74a40f6a9 100644 (file)
@@ -81,48 +81,35 @@ if (!empty($whereStatement))
 {
        $SEL = 0;
        if (isset($_POST['task'])) $SEL = SELECTION_COUNT($_POST['task']);
-       if ((isset($_POST['assign'])) && ($SEL > 0))
-       {
+       if ((isset($_POST['assign'])) && ($SEL > 0)) {
                // Assign / do tasks
                require_once(PATH."inc/modules/admin/overview-inc.php");
                if (empty($dmy)) $dmy = "";
                OUTPUT_SELECTED_TASKS($_POST, $dmy);
-       }
-        else
-       {
+       } else {
                // Start listing tasks matching selected filter
                $result_tasks = SQL_QUERY("SELECT id, assigned_admin, userid, task_type, subject, text, task_created
 FROM "._MYSQL_PREFIX."_task_system
 WHERE ".$whereStatement."
 ORDER BY userid DESC, task_type DESC, subject, task_created DESC", __FILE__, __LINE__);
-               if (($SEL > 0) && (!IS_DEMO()))
-               {
+               if (($SEL > 0) && (!IS_DEMO())) {
                        // Only unassign / delete tasks when there are selected tasks posted
-                       if (isset($_POST['unassign']))
-                       {
+                       if (isset($_POST['unassign'])) {
                                // Unassign from tasks
-                               foreach ($_POST['task'] as $id=>$sel)
-                               {
-                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin='0' WHERE id=%s AND assigned_admin='%s' LIMIT 1",
+                               foreach ($_POST['task'] as $id => $sel) {
+                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin=0 WHERE id=%s AND assigned_admin=%s LIMIT 1",
                                         array(bigintval($id), GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
                                }
-                       }
-                        elseif (isset($_POST['del']))
-                       {
+                       } elseif (isset($_POST['del'])) {
                                // Delete tasks
-                               foreach ($_POST['task'] as $id=>$sel)
-                               {
-                                       if ($_GET['type'] == "deleted")
-                                       {
+                               foreach ($_POST['task'] as $id => $sel) {
+                                       if ($_GET['type'] == "deleted") {
                                                // Delete task immediately
                                                $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE id=%s LIMIT 1",
                                                 array(bigintval($id)),__FILE__, __LINE__);
-                                       }
-                                        else
-                                       {
+                                       } else {
                                                // Mark task as to be deleted (purged by autppurge extension)
-                                               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET status='DELETED' WHERE id=%s LIMIT 1",
-                                                array(bigintval($id)), __FILE__, __LINE__);
+                                               ADMIN_DELETE_TASK($id);
                                        }
                                }
                        }