X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_task.php;h=18749aaa981560b649dc6997ca3779f285de233e;hp=9c5d2c2ecf04f2fe633b4685ce4e401a88427759;hb=f2aeaab0cd313b2eeb151642455ed558f6b186dc;hpb=7ce379f8009cb988e0af74c5e5bf6f8ddb6de37b diff --git a/inc/modules/admin/what-list_task.php b/inc/modules/admin/what-list_task.php index 9c5d2c2ecf..18749aaa98 100644 --- a/inc/modules/admin/what-list_task.php +++ b/inc/modules/admin/what-list_task.php @@ -1,7 +1,7 @@ 0)) { +addMenuDescription('admin', __FILE__); + +if (!isExtensionActive('task')) { + loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('task')); + return; +} // END - if + +$whereStatement = ''; +if (!isGetRequestParameterSet('type')) setGetRequestParameter('type', 'your'); + +switch (getRequestParameter('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 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.", getRequestParameter('type'))); + loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_TASK_UNKNOWN_MODE', getRequestParameter('type'))); + break; +} // END - switch + +if (!empty($whereStatement)) { + if ((isPostRequestParameterSet('assign')) && (countPostSelection() > 0)) { // 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 ((countPostSelection() > 0) && (!isDemoModeActive())) { // Only unassign / delete tasks when there are selected tasks posted - if (isset($_POST['unassign'])) { + if (isPostRequestParameterSet('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", - array(bigintval($id), GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__); - } - } elseif (isset($_POST['del'])) { + foreach (postRequestParameter('sel') 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), getCurrentAdminId()), __FILE__, __LINE__); + } // END - foreach + } elseif (isFormSent('del')) { // Delete tasks - foreach ($_POST['task'] as $id => $sel) { - if ($_GET['type'] == "deleted") { + foreach (postRequestParameter('sel') as $id => $sel) { + if (getRequestParameter('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__); + 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 + debug_report_bug(__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( + $type = '{--ADMIN_OVERVIEW_TASK_' . strtoupper(getRequestParameter('type')) . '_TYPE--}'; + // @TODO Rewrite these templates to one and add $OUT + loadTemplate('admin_overview_header_task', false, array( 'message' => $type, - 'type' => $_GET['type'] + 'type' => getRequestParameter('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 = "".ADMIN_NO_ADMIN_ASSIGNED.""; - } - else - { - // Load admin's data - $login = GET_ADMIN_LOGIN($admin); - if ($login != "***") - { - // Admin found - $admin = "".$login.""; - } - else - { - // Maybe deleted? - $admin = "".ADMIN_ID_404_1.$admin.ADMIN_ID_404_2.""; - } - } + $OUT = ''; $SW = 2; + while ($content = SQL_FETCHARRAY($result_tasks)) { + // Init infos + $content['infos'] = '---'; + + // Generate link + $content['assigned_admin'] = generateAdminLink($content['assigned_admin']); // Get admin task - $type_out = constant('ADMIN_TASK_IS_'.strtoupper($type).''); + $content['task_type_msg'] = '{--ADMIN_TASK_IS_' . strtoupper($content['task_type']) . '--}'; - $type2 = substr($text, 0, strpos($text, ":")); // Generate infos - switch ($type) - { - case "EXTENSION": - case "EXTENSION_UPDATE": - $infos = substr($subj, 1, strpos($subj, ":") - 1); - break; - } + switch ($content['task_type']) { + case 'EXTENSION': + case 'EXTENSION_UPDATE': + $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ':') - 1); + break; + } // END - switch // Member assigned with task? - if ($uid > 0) { + if (isValidUserId($content['userid'])) { // Member found otherwise it's a system task - $uid = ADMIN_USER_PROFILE_LINK($uid); + $content['userid'] = generateUserProfileLink($content['userid']); } else { // Is a system task! - $uid = "".ADMIN_IS_SYSTEM_TASK.""; + $content['userid'] = '{--ADMIN_IS_SYSTEM_TASK--}'; } // Prepare content - $content = array( + // @TODO Rewritings: admin->assigned_admin,type->task_type_msg in template + $content = merge_array($content, array( 'sw' => $SW, - 'id' => $id, - 'admin' => $admin, - 'infos' => $infos, - 'uid' => $uid, - 'type' => $type_out, - 'created' => MAKE_DATETIME($created, "2") - ); + 'admin' => $content['assigned_admin'], + 'userid' => $content['userid'], + 'type' => $content['task_type_msg'], + 'created' => generateDateTime($content['task_created'], 2) + )); // Do we have an extension task? - if (($type == "EXTENSION") && (GET_EXT_VERSION($infos) == "")) { + if (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos']))) { // Load extension row template - LOAD_TEMPLATE("admin_list_task_ext_rows", false, $content); + // @TODO Rewrite this to $OUT .= ..., true, ... + loadTemplate('admin_list_task_ext_rows', false, $content); } else { // Load default row template - LOAD_TEMPLATE("admin_list_task_rows", false, $content); + // @TODO Rewrite this to $OUT .= ..., true, ... + loadTemplate('admin_list_task_rows', false, $content); } // Switch colors $SW = 3 - $SW; - } + } // END - while // Free memory SQL_FREERESULT($result_tasks); // Load footer template - if ($_GET['type'] == "deleted") - { + if (getRequestParameter('type') == 'deleted') { // Delete now button - LOAD_TEMPLATE("admin_overview_footer_task"); - } - else - { + loadTemplate('admin_overview_footer_task'); + } else { // Normal footer - LOAD_TEMPLATE("admin_overview_footer"); + loadTemplate('admin_overview_footer'); } } -} -// +} // END - if + +// [EOF] ?>