A lot CSS classes rewritten, please update all your themes.
[mailer.git] / inc / modules / admin / what-list_task.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 08/03/2004 *
4  * ===================                          Last change: 08/07/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_task.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : List all tasks                                   *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alle Aufgaben auflisten                          *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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                  *
23  *                                                                      *
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.                                  *
28  *                                                                      *
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.                         *
33  *                                                                      *
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,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (!isExtensionActive('task')) {
49         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('task'));
50         return;
51 } // END - if
52
53 $whereStatement = '';
54 if (!isGetRequestParameterSet('type')) setGetRequestParameter('type', 'your');
55
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'";
59                 break;
60
61         case 'updates': // List only updates assigned to you
62                 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='NEW' AND `task_type`='EXTENSION_UPDATE'";
63                 break;
64
65         case 'solved': // List only solved tasks assigned to you
66                 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='SOLVED'";
67                 break;
68
69         case 'unassigned': // List unassigned (but not deleted) tasks
70                 $whereStatement = "`assigned_admin`=0 AND `status` != 'DELETED'";
71                 break;
72
73         case 'deleted': // List all deleted
74                 $whereStatement = "`status`='DELETED'";
75                 break;
76
77         case 'closed': // List all closed
78                 $whereStatement = "`assigned_admin`=".getCurrentAdminId()." AND `status`='CLOSED'";
79                 break;
80
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')));
84                 break;
85 } // END - switch
86
87 if (!empty($whereStatement)) {
88         if ((isPostRequestParameterSet('assign')) && (ifPostContainsSelections())) {
89                 // Assign / do tasks
90                 loadIncludeOnce('inc/modules/admin/overview-inc.php');
91                 if (empty($dmy)) $dmy = '';
92                 outputSeletectedTasks(postRequestArray(), $dmy);
93         } else {
94                 // Start listing tasks matching selected filter
95                 $result_tasks = SQL_QUERY('SELECT
96         `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
97 FROM
98         `{?_MYSQL_PREFIX?}_task_system`
99 WHERE
100         '.$whereStatement.'
101 ORDER BY
102         `userid` DESC,
103         `task_type` DESC,
104         `subject` ASC,
105         `task_created` DESC',
106                         __FILE__, __LINE__);
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__);
114                                 } // END - foreach
115                         } elseif (isFormSent('del')) {
116                                 // Delete tasks
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__);
122                                         } else {
123                                                 // Mark task as to be deleted (purged by autopurge extension)
124                                                 adminDeleteTask($id);
125                                         }
126                                 } // END - foreach
127                         } else {
128                                 // Unknown action performed
129                                 debug_report_bug(__FILE__, __LINE__, sprintf("Unknown task action performed. data=<pre>%s</pre>", print_r(postRequestArray(), true)));
130                         }
131
132                         // Update query
133                         $result_tasks = SQL_QUERY('SELECT
134         `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
135 FROM
136         `{?_MYSQL_PREFIX?}_task_system`
137 WHERE
138         '.$whereStatement.'
139 ORDER BY
140         `subject` ASC,
141         `task_created` DESC', __FILE__, __LINE__);
142                 }
143
144                 // There are uncompleted jobs!
145                 $OUT = '';
146                 while ($content = SQL_FETCHARRAY($result_tasks)) {
147                         // Init infos
148                         $content['infos'] = '';
149
150                         // Get admin task
151                         $content['task_type_msg'] = '{--ADMIN_TASK_IS_' . strtoupper($content['task_type']) . '--}';
152
153                         // Generate infos
154                         switch ($content['task_type']) {
155                                 case 'EXTENSION':
156                                 case 'EXTENSION_UPDATE':
157                                         $content['infos'] = substr($content['subject'], 1, strpos($content['subject'], ':') - 1);
158                                         break;
159                         } // END - switch
160
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']);
165                         } else {
166                                 // Is a system task!
167                                 $content['userid'] = '<em>{--ADMIN_IS_SYSTEM_TASK--}</em>';
168                         }
169
170                         // Prepare content
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)
176                         ));
177
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);
182                         } else {
183                                 // Load default row template
184                                 $OUT .= loadTemplate('admin_list_task_rows', true, $content);
185                         }
186                 } // END - while
187
188                 // Free memory
189                 SQL_FREERESULT($result_tasks);
190
191                 // Prepare content
192                 $content = array(
193                         'message' => '{--ADMIN_OVERVIEW_TASK_' . strtoupper(getRequestParameter('type')) . '_TYPE--}',
194                         'type'    => getRequestParameter('type'),
195                         'rows'    => $OUT
196                 );
197
198                 // Load footer template
199                 if (getRequestParameter('type') == 'deleted') {
200                         // Delete now button
201                         loadTemplate('admin_list_task_delete', false, $content);
202                 } else {
203                         // Normal footer
204                         loadTemplate('admin_list_task', false, $content);
205                 }
206         }
207 } // END - if
208
209 // [EOF]
210 ?>