X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_task.php;h=6f9674c308e13119b966ea740f340b86483b7276;hb=eb301334eb0960dd060cc0d59e6021260a41f835;hp=7587438b1167d463bc03fa66f8c37b009946d246;hpb=25d58e2ed3974848680b5aaa7480f572e6fd8fa8;p=mailer.git diff --git a/inc/modules/admin/what-list_task.php b/inc/modules/admin/what-list_task.php index 7587438b11..6f9674c308 100644 --- a/inc/modules/admin/what-list_task.php +++ b/inc/modules/admin/what-list_task.php @@ -10,9 +10,14 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Alle Aufgaben auflisten * * -------------------------------------------------------------------- * - * * + * $Revision:: $ * + * $Date:: $ * + * $Tag:: 0.2.1-FINAL $ * + * $Author:: $ * + * Needs to be in all Files and every File needs "svn propset * + * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * - * Copyright (c) 2003 - 2008 by Roland Haeder * + * Copyright (c) 2003 - 2009 by Roland Haeder * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -32,163 +37,169 @@ ************************************************************************/ // Some security stuff... -if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) -{ - $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; - require($INC); -} +if ((!defined('__SECURITY')) || (!isAdmin())) { + die(); +} // END - if + // Add description as navigation point -ADD_DESCR("admin", basename(__FILE__)); +addMenuDescription('admin', __FILE__); -$whereStatement = ""; -if (empty($_GET['type'])) $_GET['type'] = "your"; +if (!isExtensionActive('task')) { + loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('task')); + return; +} // END - if -switch ($_GET['type']) -{ -case "your": // List only your own open (new) tasks - $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='NEW' AND task_type != 'EXTENSION_UPDATE'"; - break; +$whereStatement = ''; +if (!isGetRequestElementSet(('type'))) setRequestGetElement('type', 'your'); -case "updates": // List only updates assigned to you - $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='NEW' AND task_type = 'EXTENSION_UPDATE'"; - break; +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 "solved": // List only solved tasks assigned to you - $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='SOLVED'"; - break; + case 'updates': // List only updates assigned to you + $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type`='EXTENSION_UPDATE'"; + break; -case "unassigned": // List unassigned (but not deleted) tasks - $whereStatement = "assigned_admin='0' AND status != 'DELETED'"; - break; + case 'solved': // List only solved tasks assigned to you + $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='SOLVED'"; + break; -case "deleted": // List all deleted - $whereStatement = "status='DELETED'"; - break; + case 'unassigned': // List unassigned (but not deleted) tasks + $whereStatement = "`assigned_admin`=0 AND `status` != 'DELETED'"; + break; -case "closed": // List all closed - $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='CLOSED'"; - break; + case 'deleted': // List all deleted + $whereStatement = "`status`='DELETED'"; + break; -default: // Unknown type - LOAD_TEMPLATE("admin_settings_saved", false, TASK_ADMIN_UNKNOWN_MODE_1.$_GET['type'].TASK_ADMIN_UNKNOWN_MODE_2); - 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'))); + loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_TASK_UNKNOWN_MODE'), getRequestElement('type'))); + break; } -if (!empty($whereStatement)) -{ +if (!empty($whereStatement)) { $SEL = 0; - if (isset($_POST['task'])) $SEL = SELECTION_COUNT($_POST['task']); - if ((isset($_POST['assign'])) && ($SEL > 0)) - { + if (isPostRequestElementSet(('task'))) $SEL = countSelection(postRequestElement('task')); + + if ((isPostRequestElementSet(('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 - { + 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 (($SEL > 0) && (!isDemoModeActive())) { // Only unassign / delete tasks when there are selected tasks posted - if (isset($_POST['unassign'])) - { + if (isPostRequestElementSet('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=%d AND assigned_admin='%s' LIMIT 1", - array(bigintval($id), GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__); + foreach (postRequestElement('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), getCurrentAdminId()), __FILE__, __LINE__); } - } - elseif (isset($_POST['del'])) - { + } elseif (isPostRequestElementSet('del')) { // Delete tasks - foreach ($_POST['task'] as $id=>$sel) - { - if ($_GET['type'] == "deleted") - { + foreach (postRequestElement('task') as $id => $sel) { + if (getRequestElement('type') == 'deleted') { // Delete task immediately - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE id=%d LIMIT 1", - array(bigintval($id)),__FILE__, __LINE__); - } - 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=%d 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 autopurge extension) + adminDeleteTask($id); } } + } else { + // Unknown action performed + debug_report_bug(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! - $eval = "\$type = ADMIN_OVERVIEW_TASK_".strtoupper($_GET['type'])."_TYPE;"; - eval($eval); - LOAD_TEMPLATE("admin_overview_header_task", false, array( + $type = getMessage('ADMIN_OVERVIEW_TASK_'.strtoupper(getRequestElement('type')).'_TYPE'); + // @TODO Rewrite these templates to one and add $OUT + loadTemplate('admin_overview_header_task', false, array( 'message' => $type, - 'type' => $_GET['type'] + 'type' => getRequestElement('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.""; - } - } - $evl = "\$type_out = ADMIN_TASK_IS_".strtoupper($type).";"; - eval($evl); - $type2 = substr($text, 0, strpos($text, ":")); + $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 + $content['task_type_msg'] = getMessage('ADMIN_TASK_IS_'.strtoupper($content['task_type']).''); + // Generate infos - switch ($type) - { - case "EXTENSION": - case "EXTENSION_UPDATE": - $infos = substr($subj, 1, strpos($subj, ":") - 1); - break; - } - if ($uid > 0) - { + 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 ($content['userid'] > 0) { // Member found otherwise it's a system task - $uid = ADMIN_USER_PROFILE_LINK($uid); - } - else - { - $uid = "".ADMIN_IS_SYSTEM_TASK.""; + $content['userid'] = generateUserProfileLink($content['userid']); + } else { + // Is a system task! + $content['userid'] = '{--ADMIN_IS_SYSTEM_TASK--}'; } - $content = array( + + // Prepare content + // @TODO Rewritings: admin->assigned_admin,userid->userid,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") - ); - LOAD_TEMPLATE("admin_list_task_rows", false, $content); + '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 (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos']))) { + // Load extension row template + // @TODO Rewrite this to $OUT .= ..., true, ... + loadTemplate('admin_list_task_ext_rows', false, $content); + } else { + // Load default row template + // @TODO Rewrite this to $OUT .= ..., true, ... + loadTemplate('admin_list_task_rows', false, $content); + } + + // Switch colors $SW = 3 - $SW; } @@ -196,17 +207,15 @@ ORDER BY userid DESC, task_type DESC, subject, task_created DESC", __FILE__, __L SQL_FREERESULT($result_tasks); // Load footer template - if ($_GET['type'] == "deleted") - { + if (getRequestElement('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'); } } } -// + +// [EOF] ?>