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 * 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 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
48 if (!isExtensionActive('task')) {
49 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('task'));
54 if (!isGetRequestParameterSet('type')) setGetRequestParameter('type', 'your');
56 switch (getRequestParameter('type')) {
57 case 'your': // List only your own open (new) tasks
58 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type` != 'EXTENSION_UPDATE'";
61 case 'updates': // List only updates assigned to you
62 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type`='EXTENSION_UPDATE'";
65 case 'solved': // List only solved tasks assigned to you
66 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='SOLVED'";
69 case 'unassigned': // List unassigned (but not deleted) tasks
70 $whereStatement = "`assigned_admin`=0 AND `status` != 'DELETED'";
73 case 'deleted': // List all deleted
74 $whereStatement = "`status`='DELETED'";
77 case 'closed': // List all closed
78 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='CLOSED'";
81 default: // Unknown type
82 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown task type %s detected.", getRequestParameter('type')));
83 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_TASK_UNKNOWN_MODE', getRequestParameter('type')));
87 if (!empty($whereStatement)) {
88 if ((isPostRequestParameterSet('assign')) && (ifPostContainsSelections())) {
90 loadIncludeOnce('inc/modules/admin/overview-inc.php');
91 if (empty($dmy)) $dmy = '';
92 outputSeletectedTasks(postRequestArray(), $dmy);
94 // Start listing tasks matching selected filter
95 $result_tasks = SQL_QUERY('SELECT
96 `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
98 `{?_MYSQL_PREFIX?}_task_system`
105 `task_created` DESC',
107 if ((ifPostContainsSelections()) && (!isDemoModeActive())) {
108 // Only unassign / delete tasks when there are selected tasks posted
109 if (isPostRequestParameterSet('unassign')) {
110 // Unassign from tasks
111 foreach (postRequestParameter('sel') as $id => $sel) {
112 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=0 WHERE `id`=%s AND `assigned_admin`=%s LIMIT 1",
113 array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
115 } elseif (isFormSent('delete')) {
117 foreach (postRequestParameter('sel') as $id => $sel) {
118 if (getRequestParameter('type') == 'deleted') {
119 // Delete task immediately
120 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s LIMIT 1",
121 array(bigintval($id)),__FILE__, __LINE__);
123 // Mark task as to be deleted (purged by autopurge extension)
124 adminDeleteTask($id);
128 // Unknown action performed
129 debug_report_bug(__FILE__, __LINE__, sprintf("Unknown task action performed. data=<pre>%s</pre>", print_r(postRequestArray(), true)));
133 $result_tasks = SQL_QUERY('SELECT
134 `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
136 `{?_MYSQL_PREFIX?}_task_system`
141 `task_created` DESC', __FILE__, __LINE__);
144 // There are uncompleted jobs!
146 while ($content = SQL_FETCHARRAY($result_tasks)) {
148 $content['infos'] = '';
151 $content['task_type_msg'] = '{--ADMIN_TASK_IS_' . strtoupper($content['task_type']) . '--}';
154 switch ($content['task_type']) {
156 case 'EXTENSION_UPDATE':
157 $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ':') - 1);
161 // Member assigned with task?
162 if (isValidUserId($content['userid'])) {
163 // Member found otherwise it's a system task
164 $content['userid'] = generateUserProfileLink($content['userid']);
167 $content['userid'] = '<em>{--ADMIN_IS_SYSTEM_TASK--}</em>';
171 $content = merge_array($content, array(
172 'assign_admin' => $content['assigned_admin'],
173 'userid' => $content['userid'],
174 'task_type_msg' => $content['task_type_msg'],
175 'task_created' => generateDateTime($content['task_created'], 2)
178 // Do we have an extension task?
179 if (isExtensionTask($content)) {
180 // Load extension row template
181 $OUT .= loadTemplate('admin_list_task_ext_rows', true, $content);
183 // Load default row template
184 $OUT .= loadTemplate('admin_list_task_rows', true, $content);
189 SQL_FREERESULT($result_tasks);
193 'message' => '{--ADMIN_OVERVIEW_TASK_' . strtoupper(getRequestParameter('type')) . '_TYPE--}',
194 'type' => getRequestParameter('type'),
198 // Load footer template
199 if (getRequestParameter('type') == 'deleted') {
201 loadTemplate('admin_list_task_delete', false, $content);
204 loadTemplate('admin_list_task', false, $content);