2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
47 if (!isGetRequestElementSet('type')) {
48 setGetRequestElement('type', 'your');
51 switch (getRequestElement('type')) {
52 case 'your': // List only your own open (new) tasks
53 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type` != 'EXTENSION_UPDATE'";
56 case 'updates': // List only updates assigned to you
57 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type`='EXTENSION_UPDATE'";
60 case 'solved': // List only solved tasks assigned to you
61 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='SOLVED'";
64 case 'unassigned': // List unassigned (but not deleted) tasks
65 $whereStatement = "(`assigned_admin`=0 OR `assigned_admin` IS NULL) AND `status` != 'DELETED'";
68 case 'deleted': // List all deleted
69 $whereStatement = "`status`='DELETED'";
72 case 'closed': // List all closed
73 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='CLOSED'";
76 default: // Unknown type
77 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown task type %s detected.", getRequestElement('type')));
78 displayMessage('{%message,ADMIN_TASK_UNKNOWN_MODE' . getRequestElement('type') . '%}');
82 if (!empty($whereStatement)) {
83 if ((isPostRequestElementSet('assign')) && (ifPostContainsSelections())) {
85 loadIncludeOnce('inc/modules/admin/overview-inc.php');
86 if (empty($dmy)) $dmy = '';
87 outputSeletectedTasks(postRequestArray(), $dmy);
89 // Start listing tasks matching selected filter
90 $result_tasks = SQL_QUERY('SELECT
91 `id`,`assigned_admin`,`userid`,`task_type`,`subject`,`text`,`task_created`
93 `{?_MYSQL_PREFIX?}_task_system`
100 `task_created` DESC',
102 if ((ifPostContainsSelections()) && (!isDemoModeActive())) {
103 // Only unassign / delete tasks when there are selected tasks posted
104 if (isPostRequestElementSet('unassign')) {
105 // Unassign from tasks
106 foreach (postRequestElement('sel') as $id => $sel) {
107 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=NULL WHERE `id`=%s AND `assigned_admin`=%s LIMIT 1",
108 array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
110 } elseif (isFormSent('delete')) {
112 foreach (postRequestElement('sel') as $id => $sel) {
113 if (getRequestElement('type') == 'deleted') {
114 // Delete task immediately
115 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s LIMIT 1",
116 array(bigintval($id)),__FILE__, __LINE__);
118 // Mark task as to be deleted (purged by autopurge extension)
119 adminDeleteTask($id);
123 // Unknown action performed
124 debug_report_bug(__FILE__, __LINE__, sprintf("Unknown task action performed. data=<pre>%s</pre>", print_r(postRequestArray(), true)));
128 $result_tasks = SQL_QUERY('SELECT
129 `id`,`assigned_admin`,`userid`,`task_type`,`subject`,`text`,`task_created`
131 `{?_MYSQL_PREFIX?}_task_system`
136 `task_created` DESC', __FILE__, __LINE__);
139 // There are uncompleted jobs!
141 while ($content = SQL_FETCHARRAY($result_tasks)) {
143 $content['infos'] = '';
146 switch ($content['task_type']) {
148 case 'EXTENSION_UPDATE':
149 $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ':') - 1);
153 // Member assigned with task?
154 if (isValidUserId($content['userid'])) {
155 // Member found otherwise it's a system task
156 $content['userid'] = generateUserProfileLink($content['userid']);
159 $content['userid'] = '<em>{--ADMIN_IS_SYSTEM_TASK--}</em>';
163 $content = merge_array($content, array(
164 'task_created' => generateDateTime($content['task_created'], 2)
167 // Do we have an extension task?
168 if (isExtensionTask($content)) {
169 // Load extension row template
170 $OUT .= loadTemplate('admin_list_task_ext_rows', true, $content);
172 // Load default row template
173 $OUT .= loadTemplate('admin_list_task_rows', true, $content);
178 SQL_FREERESULT($result_tasks);
182 'message' => '{--ADMIN_OVERVIEW_TASK_' . strtoupper(getRequestElement('type')) . '_TYPE--}',
183 'type' => getRequestElement('type'),
187 // Load footer template
188 if (getRequestElement('type') == 'deleted') {
190 loadTemplate('admin_list_task_delete', false, $content);
193 loadTemplate('admin_list_task', false, $content);