2 /************************************************************************
3 * MXChange v0.2.1 Start: 08/03/2004 *
4 * ================ Last change: 08/07/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-list_task.php *
8 * -------------------------------------------------------------------- *
9 * Short description : List all tasks *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alle Aufgaben auflisten *
12 * -------------------------------------------------------------------- *
14 * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. March 2009) $ *
15 * $Tag:: 0.2.1-FINAL $ *
16 * $Author:: stelzi $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2008 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
43 } elseif (!EXT_IS_ACTIVE("task")) {
44 addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "task");
48 // Add description as navigation point
49 ADD_DESCR("admin", __FILE__);
52 if (!REQUEST_ISSET_GET(('type'))) REQUEST_SET_GET('type', "your");
54 switch (REQUEST_GET('type'))
56 case "your": // List only your own open (new) tasks
57 $whereStatement = "assigned_admin='".GET_CURRENT_ADMIN_ID()."' AND `status`='NEW' AND task_type != 'EXTENSION_UPDATE'";
60 case "updates": // List only updates assigned to you
61 $whereStatement = "assigned_admin=".GET_CURRENT_ADMIN_ID()." AND `status`='NEW' AND task_type = 'EXTENSION_UPDATE'";
64 case "solved": // List only solved tasks assigned to you
65 $whereStatement = "assigned_admin=".GET_CURRENT_ADMIN_ID()." AND `status`='SOLVED'";
68 case "unassigned": // List unassigned (but not deleted) tasks
69 $whereStatement = "assigned_admin='0' AND status != 'DELETED'";
72 case "deleted": // List all deleted
73 $whereStatement = "`status`='DELETED'";
76 case "closed": // List all closed
77 $whereStatement = "assigned_admin=".GET_CURRENT_ADMIN_ID()." AND `status`='CLOSED'";
80 default: // Unknown type
81 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown task type %s detected.", REQUEST_GET('type')));
82 LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_TASK_UNKNOWN_MODE'), REQUEST_GET('type')));
86 if (!empty($whereStatement)) {
88 if (REQUEST_ISSET_POST(('task'))) $SEL = SELECTION_COUNT(REQUEST_POST('task'));
90 if ((REQUEST_ISSET_POST(('assign'))) && ($SEL > 0)) {
92 LOAD_INC_ONCE("inc/modules/admin/overview-inc.php");
93 if (empty($dmy)) $dmy = "";
94 OUTPUT_SELECTED_TASKS(REQUEST_POST_ARRAY(), $dmy);
96 // Start listing tasks matching selected filter
97 $result_tasks = SQL_QUERY("SELECT id, assigned_admin, userid, task_type, subject, text, task_created
98 FROM `{!_MYSQL_PREFIX!}_task_system`
99 WHERE ".$whereStatement."
100 ORDER BY userid DESC, task_type DESC, subject, task_created DESC", __FILE__, __LINE__);
101 if (($SEL > 0) && (!IS_DEMO())) {
102 // Only unassign / delete tasks when there are selected tasks posted
103 if (REQUEST_ISSET_POST(('unassign'))) {
104 // Unassign from tasks
105 foreach (REQUEST_POST('task') as $id => $sel) {
106 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_task_system` SET assigned_admin=0 WHERE id=%s AND assigned_admin=%s LIMIT 1",
107 array(bigintval($id), GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__);
109 } elseif (REQUEST_ISSET_POST('del')) {
111 foreach (REQUEST_POST('task') as $id => $sel) {
112 if (REQUEST_GET('type') == "deleted") {
113 // Delete task immediately
114 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE id=%s LIMIT 1",
115 array(bigintval($id)),__FILE__, __LINE__);
117 // Mark task as to be deleted (purged by autppurge extension)
118 ADMIN_DELETE_TASK($id);
124 $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__);
127 // There are uncompleted jobs!
128 $type = getMessage('ADMIN_OVERVIEW_TASK_'.strtoupper(REQUEST_GET('type')).'_TYPE');
129 // @TODO Rewrite these templates to one and add $OUT
130 LOAD_TEMPLATE("admin_overview_header_task", false, array(
132 'type' => REQUEST_GET('type')
135 while ($content = SQL_FETCHARRAY($result_tasks)) {
137 $content['infos'] = "---";
140 $content['assigned_admin'] = GENERATE_AID_LINK($content['assigned_admin']);
143 $content['task_type_msg'] = getMessage('ADMIN_TASK_IS_'.strtoupper($content['task_type']).'');
146 switch ($content['task_type'])
149 case "EXTENSION_UPDATE":
150 $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ":") - 1);
154 // Member assigned with task?
155 if ($content['userid'] > 0) {
156 // Member found otherwise it's a system task
157 $content['userid'] = ADMIN_USER_PROFILE_LINK($content['userid']);
160 $content['userid'] = "<em>{--ADMIN_IS_SYSTEM_TASK--}</em>";
164 // @TODO Rewritings: admin->assigned_admin,uid->userid,type->task_type_msg in template
165 $content = merge_array($content, array(
167 'admin' => $content['assigned_admin'],
168 'uid' => $content['userid'],
169 'type' => $content['task_type_msg'],
170 'created' => MAKE_DATETIME($content['task_created'], "2")
173 // Do we have an extension task?
174 if (($content['task_type'] == "EXTENSION") && (GET_EXT_VERSION($content['infos']) == "")) {
175 // Load extension row template
176 // @TODO Rewrite this to $OUT .= ..., true, ...
177 LOAD_TEMPLATE("admin_list_task_ext_rows", false, $content);
179 // Load default row template
180 // @TODO Rewrite this to $OUT .= ..., true, ...
181 LOAD_TEMPLATE("admin_list_task_rows", false, $content);
189 SQL_FREERESULT($result_tasks);
191 // Load footer template
192 if (REQUEST_GET('type') == "deleted") {
194 LOAD_TEMPLATE("admin_overview_footer_task");
197 LOAD_TEMPLATE("admin_overview_footer");