From: Roland Häder Date: Tue, 9 Sep 2008 17:11:53 +0000 (+0000) Subject: Improvements to task extension X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=49654afc3fc819c4a9e65be2d870782f5e33e60d;p=mailer.git Improvements to task extension --- diff --git a/inc/databases.php b/inc/databases.php index 01d9d3ddd0..c4e612d78f 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -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); diff --git a/inc/extensions.php b/inc/extensions.php index f566d1dfc8..711a3d1639 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -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); diff --git a/inc/libs/admins_functions.php b/inc/libs/admins_functions.php index 8b017261f8..a2964387bb 100644 --- a/inc/libs/admins_functions.php +++ b/inc/libs/admins_functions.php @@ -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 diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 0534befa51..2fe4a3a1f0 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -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__); +} // ?> diff --git a/inc/modules/admin/overview-inc.php b/inc/modules/admin/overview-inc.php index 6fdcafcf56..aa2f8e7103 100644 --- a/inc/modules/admin/overview-inc.php +++ b/inc/modules/admin/overview-inc.php @@ -290,10 +290,8 @@ function OUTPUT_SELECTED_TASKS($_POST, $result_tasks) { $OUT .= "".ADMIN_EXT_ALREADY_REGISTERED."\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__); } diff --git a/inc/modules/admin/what-list_newsletter.php b/inc/modules/admin/what-list_newsletter.php index 93ec1c91a9..0c668e8387 100644 --- a/inc/modules/admin/what-list_newsletter.php +++ b/inc/modules/admin/what-list_newsletter.php @@ -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'])); diff --git a/inc/modules/admin/what-list_payouts.php b/inc/modules/admin/what-list_payouts.php index 737863132a..a4d1dc66bc 100644 --- a/inc/modules/admin/what-list_payouts.php +++ b/inc/modules/admin/what-list_payouts.php @@ -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 diff --git a/inc/modules/admin/what-list_task.php b/inc/modules/admin/what-list_task.php index 5ac8fff0b1..110dab5a88 100644 --- a/inc/modules/admin/what-list_task.php +++ b/inc/modules/admin/what-list_task.php @@ -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); } } }