X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=inc%2Fmodules%2Fadmin%2Fwhat-list_task.php;h=31389aa8adfb9c810beb521566b89d29a7c6058c;hb=a6aaa866eff075c408f58cc0bc24f08562d51b7c;hp=ff48e0d633ec6837c6445744a00db329141c7fb0;hpb=747c49b9f46a3d7d1d881c9e1c273ecf107f8d8b;p=mailer.git diff --git a/inc/modules/admin/what-list_task.php b/inc/modules/admin/what-list_task.php index ff48e0d633..31389aa8ad 100644 --- a/inc/modules/admin/what-list_task.php +++ b/inc/modules/admin/what-list_task.php @@ -1,7 +1,7 @@ 0)) { +addYouAreHereLink('admin', __FILE__); + +$whereStatement = ''; +if (!isGetRequestElementSet('type')) { + setGetRequestElement('type', 'your'); +} // END - if + +switch (getRequestElement('type')) { + case 'your': // List only your own open (new) tasks + $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type` != 'EXTENSION_UPDATE'"; + break; + + case 'updates': // List only updates assigned to you + $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type`='EXTENSION_UPDATE'"; + break; + + case 'solved': // List only solved tasks assigned to you + $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='SOLVED'"; + break; + + case 'unassigned': // List unassigned (but not deleted) tasks + $whereStatement = "(`assigned_admin`=0 OR `assigned_admin` IS NULL) AND `status` != 'DELETED'"; + break; + + case 'deleted': // List all deleted + $whereStatement = "`status`='DELETED'"; + break; + + case 'closed': // List all closed + $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='CLOSED'"; + break; + + default: // Unknown type + logDebugMessage(__FILE__, __LINE__, sprintf("Unknown task type %s detected.", getRequestElement('type'))); + displayMessage('{%message,ADMIN_TASK_UNKNOWN_MODE' . getRequestElement('type') . '%}'); + break; +} // END - switch + +if (!empty($whereStatement)) { + if ((isPostRequestElementSet('assign')) && (ifPostContainsSelections())) { // Assign / do tasks - require_once(PATH."inc/modules/admin/overview-inc.php"); - if (empty($dmy)) $dmy = ""; - OUTPUT_SELECTED_TASKS($_POST, $dmy); + loadIncludeOnce('inc/modules/admin/overview-inc.php'); + if (empty($dmy)) $dmy = ''; + outputSeletectedTasks(postRequestArray(), $dmy); } 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())) { + $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` ASC, + `task_created` DESC', + __FILE__, __LINE__); + if ((ifPostContainsSelections()) && (!isDemoModeActive())) { // Only unassign / delete tasks when there are selected tasks posted - if (isset($_POST['unassign'])) { + if (isFormSent('unassign')) { // Unassign from tasks - foreach ($_POST['task'] as $id => $sel) { - 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_CURRENT_ADMIN_ID()), __FILE__, __LINE__); - } - } elseif (isset($_POST['del'])) { + foreach (postRequestElement('sel') as $id => $sel) { + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=NULL WHERE `id`=%s AND `assigned_admin`=%s LIMIT 1", + array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__); + } // END - foreach + } elseif (isFormSent('delete')) { // Delete tasks - foreach ($_POST['task'] as $id => $sel) { - if ($_GET['type'] == "deleted") { + foreach (postRequestElement('sel') as $id => $sel) { + if (getRequestElement('type') == 'deleted') { // Delete task immediately - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!MYSQL_PREFIX!}_task_system` WHERE id=%s LIMIT 1", + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s LIMIT 1", array(bigintval($id)),__FILE__, __LINE__); } else { - // Mark task as to be deleted (purged by autppurge extension) - ADMIN_DELETE_TASK($id); + // Mark task as to be deleted (purged by autopurge extension) + adminDeleteTask($id); } - } + } // END - foreach + } else { + // Unknown action performed + reportBug(__FILE__, __LINE__, sprintf("Unknown task action performed. data=
%s", print_r(postRequestArray(), TRUE))); } // Update query - $result_tasks = SQL_QUERY("SELECT id, assigned_admin, userid, task_type, subject, text, task_created FROM `{!MYSQL_PREFIX!}_task_system` WHERE ".$whereStatement." ORDER BY subject, task_created DESC", __FILE__, __LINE__); + $result_tasks = SQL_QUERY('SELECT + `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created` +FROM + `{?_MYSQL_PREFIX?}_task_system` +WHERE + '.$whereStatement.' +ORDER BY + `subject` ASC, + `task_created` DESC', __FILE__, __LINE__); } // There are uncompleted jobs! - $type = constant('ADMIN_OVERVIEW_TASK_'.strtoupper($_GET['type']).'_TYPE'); - LOAD_TEMPLATE("admin_overview_header_task", false, array( - 'message' => $type, - 'type' => $_GET['type'] - )); - $SW = 2; - while (list($id, $admin, $uid, $type, $subj, $text, $created) = SQL_FETCHROW($result_tasks)) - { - $infos = "---"; - if ($admin == "0") - { - // No admin currently is assigned - $admin = "