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 * -------------------------------------------------------------------- *
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 * 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')) || (!isAdmin())) {
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
47 if (!isExtensionActive('task')) {
48 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('task'));
53 if (!isGetRequestElementSet(('type'))) setRequestGetElement('type', 'your');
55 switch (getRequestElement('type')) {
56 case 'your': // List only your own open (new) tasks
57 $whereStatement = "`assigned_admin`='".getCurrentAdminId()."' AND `status`='NEW' AND `task_type` != 'EXTENSION_UPDATE'";
60 case 'updates': // List only updates assigned to you
61 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type`='EXTENSION_UPDATE'";
64 case 'solved': // List only solved tasks assigned to you
65 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." 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`=".getCurrentAdminId()." AND `status`='CLOSED'";
80 default: // Unknown type
81 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown task type %s detected.", getRequestElement('type')));
82 loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_TASK_UNKNOWN_MODE'), getRequestElement('type')));
86 if (!empty($whereStatement)) {
87 if ((isPostRequestElementSet(('assign'))) && (countPostSelection() > 0)) {
89 loadIncludeOnce("inc/modules/admin/overview-inc.php");
90 if (empty($dmy)) $dmy = '';
91 outputSeletectedTasks(postRequestArray(), $dmy);
93 // Start listing tasks matching selected filter
94 $result_tasks = SQL_QUERY('SELECT
95 `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
97 `{?_MYSQL_PREFIX?}_task_system`
104 `task_created` DESC',
106 if ((countPostSelection() > 0) && (!isDemoModeActive())) {
107 // Only unassign / delete tasks when there are selected tasks posted
108 if (isPostRequestElementSet('unassign')) {
109 // Unassign from tasks
110 foreach (postRequestElement('task') as $id => $sel) {
111 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=0 WHERE `id`=%s AND `assigned_admin`=%s LIMIT 1",
112 array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
114 } elseif (isPostRequestElementSet('del')) {
116 foreach (postRequestElement('task') as $id => $sel) {
117 if (getRequestElement('type') == 'deleted') {
118 // Delete task immediately
119 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s LIMIT 1",
120 array(bigintval($id)),__FILE__, __LINE__);
122 // Mark task as to be deleted (purged by autopurge extension)
123 adminDeleteTask($id);
127 // Unknown action performed
128 debug_report_bug(sprintf("Unknown task action performed. data=<pre>%s</pre>", print_r(postRequestArray(), true)));
132 $result_tasks = SQL_QUERY('SELECT
133 `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
135 `{?_MYSQL_PREFIX?}_task_system`
140 `task_created` DESC', __FILE__, __LINE__);
143 // There are uncompleted jobs!
144 $type = getMessage('ADMIN_OVERVIEW_TASK_'.strtoupper(getRequestElement('type')).'_TYPE');
145 // @TODO Rewrite these templates to one and add $OUT
146 loadTemplate('admin_overview_header_task', false, array(
148 'type' => getRequestElement('type')
151 while ($content = SQL_FETCHARRAY($result_tasks)) {
153 $content['infos'] = '---';
156 $content['assigned_admin'] = generateAdminLink($content['assigned_admin']);
159 $content['task_type_msg'] = getMessage('ADMIN_TASK_IS_'.strtoupper($content['task_type']).'');
162 switch ($content['task_type']) {
164 case 'EXTENSION_UPDATE':
165 $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ':') - 1);
169 // Member assigned with task?
170 if ($content['userid'] > 0) {
171 // Member found otherwise it's a system task
172 $content['userid'] = generateUserProfileLink($content['userid']);
175 $content['userid'] = '<em>{--ADMIN_IS_SYSTEM_TASK--}</em>';
179 // @TODO Rewritings: admin->assigned_admin,userid->userid,type->task_type_msg in template
180 $content = merge_array($content, array(
182 'admin' => $content['assigned_admin'],
183 'userid' => $content['userid'],
184 'type' => $content['task_type_msg'],
185 'created' => generateDateTime($content['task_created'], 2)
188 // Do we have an extension task?
189 if (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos']))) {
190 // Load extension row template
191 // @TODO Rewrite this to $OUT .= ..., true, ...
192 loadTemplate('admin_list_task_ext_rows', false, $content);
194 // Load default row template
195 // @TODO Rewrite this to $OUT .= ..., true, ...
196 loadTemplate('admin_list_task_rows', false, $content);
204 SQL_FREERESULT($result_tasks);
206 // Load footer template
207 if (getRequestElement('type') == 'deleted') {
209 loadTemplate('admin_overview_footer_task');
212 loadTemplate('admin_overview_footer');