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://www.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__);
46 if (!isExtensionActive('task')) {
47 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('task'));
52 if (!isGetRequestParameterSet('type')) setGetRequestParameter('type', 'your');
54 switch (getRequestParameter('type')) {
55 case 'your': // List only your own open (new) tasks
56 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type` != 'EXTENSION_UPDATE'";
59 case 'updates': // List only updates assigned to you
60 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type`='EXTENSION_UPDATE'";
63 case 'solved': // List only solved tasks assigned to you
64 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='SOLVED'";
67 case 'unassigned': // List unassigned (but not deleted) tasks
68 $whereStatement = "(`assigned_admin`=0 OR `assigned_admin` IS NULL) AND `status` != 'DELETED'";
71 case 'deleted': // List all deleted
72 $whereStatement = "`status`='DELETED'";
75 case 'closed': // List all closed
76 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='CLOSED'";
79 default: // Unknown type
80 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown task type %s detected.", getRequestParameter('type')));
81 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_TASK_UNKNOWN_MODE', getRequestParameter('type')));
85 if (!empty($whereStatement)) {
86 if ((isPostRequestParameterSet('assign')) && (ifPostContainsSelections())) {
88 loadIncludeOnce('inc/modules/admin/overview-inc.php');
89 if (empty($dmy)) $dmy = '';
90 outputSeletectedTasks(postRequestArray(), $dmy);
92 // Start listing tasks matching selected filter
93 $result_tasks = SQL_QUERY('SELECT
94 `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
96 `{?_MYSQL_PREFIX?}_task_system`
103 `task_created` DESC',
105 if ((ifPostContainsSelections()) && (!isDemoModeActive())) {
106 // Only unassign / delete tasks when there are selected tasks posted
107 if (isPostRequestParameterSet('unassign')) {
108 // Unassign from tasks
109 foreach (postRequestParameter('sel') as $id => $sel) {
110 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=NULL WHERE `id`=%s AND `assigned_admin`=%s LIMIT 1",
111 array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
113 } elseif (isFormSent('delete')) {
115 foreach (postRequestParameter('sel') as $id => $sel) {
116 if (getRequestParameter('type') == 'deleted') {
117 // Delete task immediately
118 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s LIMIT 1",
119 array(bigintval($id)),__FILE__, __LINE__);
121 // Mark task as to be deleted (purged by autopurge extension)
122 adminDeleteTask($id);
126 // Unknown action performed
127 debug_report_bug(__FILE__, __LINE__, sprintf("Unknown task action performed. data=<pre>%s</pre>", print_r(postRequestArray(), true)));
131 $result_tasks = SQL_QUERY('SELECT
132 `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
134 `{?_MYSQL_PREFIX?}_task_system`
139 `task_created` DESC', __FILE__, __LINE__);
142 // There are uncompleted jobs!
144 while ($content = SQL_FETCHARRAY($result_tasks)) {
146 $content['infos'] = '';
149 $content['task_type_msg'] = '{--ADMIN_TASK_IS_' . strtoupper($content['task_type']) . '--}';
152 switch ($content['task_type']) {
154 case 'EXTENSION_UPDATE':
155 $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ':') - 1);
159 // Member assigned with task?
160 if (isValidUserId($content['userid'])) {
161 // Member found otherwise it's a system task
162 $content['userid'] = generateUserProfileLink($content['userid']);
165 $content['userid'] = '<em>{--ADMIN_IS_SYSTEM_TASK--}</em>';
169 $content = merge_array($content, array(
170 'assign_admin' => $content['assigned_admin'],
171 'userid' => $content['userid'],
172 'task_type_msg' => $content['task_type_msg'],
173 'task_created' => generateDateTime($content['task_created'], 2)
176 // Do we have an extension task?
177 if (isExtensionTask($content)) {
178 // Load extension row template
179 $OUT .= loadTemplate('admin_list_task_ext_rows', true, $content);
181 // Load default row template
182 $OUT .= loadTemplate('admin_list_task_rows', true, $content);
187 SQL_FREERESULT($result_tasks);
191 'message' => '{--ADMIN_OVERVIEW_TASK_' . strtoupper(getRequestParameter('type')) . '_TYPE--}',
192 'type' => getRequestParameter('type'),
196 // Load footer template
197 if (getRequestParameter('type') == 'deleted') {
199 loadTemplate('admin_list_task_delete', false, $content);
202 loadTemplate('admin_list_task', false, $content);