source: trunk/gm_system/tasks/task_show.php@ 638

Last change on this file since 638 was 638, checked in by barny, 16 years ago
File size: 13.3 KB
Line 
1<?php
2/*
3 $Id: task_show.php 2263 2009-08-01 02:39:44Z andrewsimpson $
4
5 (c) 2002 - 2009 Andrew Simpson <andrew.simpson at paradise.net.nz>
6
7 WebCollab
8 ---------------------------------------
9
10 This program is free software; you can redistribute it and/or modify it under the
11 terms of the GNU General Public License as published by the Free Software Foundation;
12 either version 2 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
16 PARTICULAR PURPOSE. See the GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License along with this
19 program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
20 Cambridge, MA 02139, USA.
21
22 Function:
23 ---------
24
25 Show a task
26
27*/
28
29//security check
30if(! defined('UID' ) ) {
31 die('Direct file access not permitted' );
32}
33
34//includes
35require_once(BASE.'includes/usergroup_security.php');
36include_once(BASE.'includes/details.php' );
37include_once(BASE.'tasks/task_common.php' );
38include_once(BASE.'includes/time.php' );
39
40//secure variables
41$content = '';
42
43//is there an id ?
44if(! @safe_integer($_GET['taskid']) || $_GET['taskid'] == 0 ) {
45 error('Task show', 'Not a valid value for taskid' );
46}
47
48$taskid = $_GET['taskid'];
49
50//check usergroup security
51$taskid = usergroup_check($taskid );
52
53$q = db_query('SELECT '.PRE.'tasks.created AS created,
54 '.PRE.'tasks.finished_time AS finished,
55 '.PRE.'tasks.completion_time AS completion,
56 '.PRE.'users.fullname AS fullname,
57 '.PRE.'taskgroups.name AS taskgroup_name,
58 '.PRE.'usergroups.name AS usergroup_name,
59 '.$epoch.' '.PRE.'seen.time) AS last_seen
60 FROM '.PRE.'tasks
61 LEFT JOIN '.PRE.'users ON ('.PRE.'users.id='.PRE.'tasks.owner)
62 LEFT JOIN '.PRE.'taskgroups ON ('.PRE.'taskgroups.id='.PRE.'tasks.taskgroupid)
63 LEFT JOIN '.PRE.'usergroups ON ('.PRE.'usergroups.id='.PRE.'tasks.usergroupid)
64 LEFT JOIN '.PRE.'seen ON ('.PRE.'tasks.id='.PRE.'seen.taskid AND '.PRE.'seen.userid='.UID.')
65 WHERE '.PRE.'tasks.id='.$taskid.' LIMIT 1' );
66
67//get the data
68if( ! ($row = db_fetch_array($q, 0 ) ) ) {
69 error('Task show', 'The requested item has either been deleted, or is now invalid.');
70}
71
72//mark this as seen in seen ;)
73if($row['last_seen'] ) {
74 db_query('UPDATE '.PRE.'seen SET time=now() WHERE taskid='.$taskid.' AND userid='.UID );
75}
76else {
77 db_query('INSERT INTO '.PRE.'seen(userid, taskid, time) VALUES ('.UID.', '.$taskid.', now() )' );
78}
79
80//text link for 'printer friendly' page
81if(isset($_GET['action']) && $_GET['action'] === "show_print" ) {
82 $content .= "<p><span class=\"textlink\">[<a href=\"tasks.php?x=".X."&amp;action=show&amp;taskid=".$taskid."\">".$lang['normal_version']."</a>]</span></p>";
83}
84else {
85 //show print tag
86 $content .= "<div style=\"text-align : right\">".
87 "<a href=\"icalendar.php?x=".X."&amp;action=project&amp;taskid=".$taskid."\" title=\"".$lang['icalendar']."\">".
88 "<img src=\"images/calendar_link.png\" alt=\"".$lang['icalendar']."\" width=\"16\" height=\"16\" /></a>&nbsp;&nbsp;&nbsp;".
89 "<a href=\"tasks.php?x=".X."&amp;action=show_print&amp;taskid=".$taskid."\" title= \"".$lang['print_version']."\">".
90 "<img src=\"images/printer.png\" alt=\"".$lang['print_version']."\" width=\"16\" height=\"16\" /></a></div>\n";
91 //show 'project jump' select box
92 $content .= project_jump($taskid);
93}
94
95//start of header table
96$content .= "<table width=\"98%\">\n";
97
98//percentage_completed gauge if this is a project
99if( $TASKID_ROW['parent'] == 0 ) {
100 $content .= "<tr><td>".sprintf( $lang['percent_project_sprt'], $TASKID_ROW['completed'] )."</td></tr>\n";
101 $content .= "<tr><td>".show_percent( $TASKID_ROW['completed'] )."</td></tr>\n";
102}
103
104//project/task name
105$content .= "<tr><td><b>".$TASKID_ROW['name']."</b><br /><br /></td></tr>\n";
106
107//show text
108$content .= "<tr><td class=\"textbackground\" style=\"width: 95%\">\n";
109
110$content .= nl2br(bbcode($TASKID_ROW['text'] ) );
111$content .= "</td></tr></table>\n";
112
113//start of info table
114$content .= "<table class=\"celldata\">\n";
115
116//get owner information
117if( $TASKID_ROW['owner'] == 0 ) {
118 $content .= "<tr><td>".$lang['owned_by'].":</td><td>".$lang['nobody']."</td></tr>\n";
119} else {
120 $content .= "<tr><td>".$lang['owned_by'].": </td><td><a href=\"users.php?x=".X."&amp;action=show&amp;userid=".$TASKID_ROW['owner']."\">".$row['fullname']."</a></td></tr>\n";
121}
122
123//get creator information (null if creator has been deleted!)
124$creator = @db_result(db_query("SELECT fullname FROM ".PRE."users WHERE id=".$TASKID_ROW['creator'] ), 0, 0 );
125$content .= "<tr><td>".$lang['created_on'].": </td><td>";
126if($creator == NULL ) {
127 $content .= nicedate($TASKID_ROW['created']);
128}
129else {
130 $content .= sprintf($lang['by_sprt'], nicedate($row['created']), "<a href=\"users.php?x=".X."&amp;action=show&amp;userid=".$TASKID_ROW['creator']."\">".$creator."</a>");
131}
132$content .= "</td></tr>\n";
133
134//get deadline
135$content .= "<tr><td>".$lang['deadline'].": </td><td>".nicedate($TASKID_ROW['deadline'])."</td></tr>\n";
136
137//get priority
138$content .= "<tr><td>".$lang['priority'].": </td><td>";
139switch($TASKID_ROW['priority'] ) {
140
141 case 0:
142 $content .= $task_state['dontdo'];
143 break;
144 case 1:
145 $content .= $task_state['low'];
146 break;
147 case 2:
148 $content .= $task_state['normal'];
149 break;
150 case 3:
151 $content .= "<b>".$task_state['high']."</b>";
152 break;
153 case 4:
154 $content .= "<b><span class=\"red\">".$task_state['yesterday']."</span></b>";
155 break;
156}
157$content .= "</td></tr>\n";
158
159//status info and task completion date
160switch($TASKID_ROW['parent'] ) {
161 case 0:
162 //project - show the finish date and status
163 $title = $lang['project_details'];
164 switch($TASKID_ROW['status'] ) {
165 case 'cantcomplete':
166 $content .= "<tr><td>".$lang['status'].": </td><td><b>".$lang['project_on_hold']."</b></td></tr>\n";
167 $content .= "<tr><td>".$lang['modified_on'].": </td><td>".nicedate($row['finished'])."</td></tr>\n";
168 break;
169
170 case 'notactive':
171 $content .= "<tr><td>".$lang['status'].": </td><td>".$lang['project_planned']."</td></tr>\n";
172 break;
173
174 case 'nolimit':
175 $content .= "<tr><td>".$lang['status'].": </td><td>".$lang['project_no_deadline']."</td></tr>\n";
176 break;
177
178 case 'done':
179 default:
180 if($TASKID_ROW['completed'] == 100 ) {
181 $content .= "<tr><td>".$lang['completed_on'].": </td><td>".nicedate($row['completion'] )."</td></tr>\n";
182 }
183 break;
184 }
185 break;
186
187 default:
188 //task
189 $title = $lang['task_info'];
190 $content .= "<tr><td>".$lang['status'].": </td><td>";
191 switch($TASKID_ROW['status'] ) {
192 case 'created':
193 $content .= $task_state['new'];
194 break;
195 case 'notactive':
196 $content .= $task_state['planned'];
197 break;
198 case 'active':
199 $content .= $task_state['active'];
200 break;
201 case 'cantcomplete':
202 $content .= "<b>".$task_state['cantcomplete']."</b>";
203 break;
204 case 'done':
205 $content .= $task_state['done'];
206 break;
207 default:
208 $content .= $TASKID_ROW['status'];
209 break;
210 }
211 $content .= "</td></tr>\n";
212
213 //is there a finished date ?
214 switch($TASKID_ROW['status'] ) {
215 case 'done':
216 $content .= "<tr><td>".$lang['completed_on'].": </td><td>".nicedate($row['finished'])."</td></tr>\n";
217 break;
218
219 case 'cantcomplete':
220 $content .= "<tr><td>".$lang['modified_on'].": </td><td>".nicedate($row['finished'])."</td></tr>\n";
221 break;
222
223 default:
224 break;
225 }
226 break;
227}
228
229//task group
230if($TASKID_ROW['parent'] != 0 ) {
231
232 switch($TASKID_ROW['taskgroupid'] ){
233 case 0:
234 $content .= "<tr><td><a href=\"help/help_language.php?item=taskgroup&amp;type=help&amp;lang=".LOCALE_USER."\" onclick=\"window.open('help/help_language.php?item=taskgroup&amp;type=help&amp;lang=".LOCALE_USER."'); return false\">".$lang['taskgroup']."</a>: </td><td>".$lang['none']."</td></tr>\n";
235 break;
236
237 default:
238 $content .= "<tr><td><a href=\"help/help_language.php?item=taskgroup&amp;type=help&amp;lang=".LOCALE_USER."\" onclick=\"window.open('help/help_language.php?item=taskgroup&amp;type=help&amp;lang=".LOCALE_USER."'); return false\">".$lang['taskgroup']."</a>: </td><td>".$row['taskgroup_name']."</td></tr>\n";
239 break;
240 }
241}
242
243//show the usergroupid
244if( $TASKID_ROW['usergroupid'] != 0 ) {
245 $content .= "<tr><td><a href=\"help/help_language.php?item=usergroup&amp;type=help&amp;lang=".LOCALE_USER."\" onclick=\"window.open('help/help_language.php?item=usergroup&amp;type=help&amp;lang=".LOCALE_USER."'); return false\">".$lang['usergroup']."</a>: </td><td>".$row['usergroup_name']." ";
246
247 switch($TASKID_ROW['globalaccess'] ){
248 case 't':
249 $content .= $lang[$TYPE."_accessible"]."</td></tr>\n";
250 break;
251
252 case 'f':
253 default:
254 $content .= "<b>".$lang[$TYPE."_not_accessible"]."</b></td></tr>\n";
255 break;
256 }
257
258 if($TASKID_ROW['groupaccess'] == 't' ) {
259 $content .= "<tr><td>&nbsp;</td><td><i>".$lang["usergroup_can_edit_".$TYPE]."</i></td></tr>\n";
260 }
261}
262else {
263 $content .= "<tr><td><a href=\"help/help_language.php?item=usergroup&amp;type=help&amp;lang=".LOCALE_USER."\" onclick=\"window.open('help/help_language.php?item=usergroup&amp;type=help&amp;lang=".LOCALE_USER."'); return false\">".$lang['usergroup']."</a>: </td><td>".$lang[$TYPE."_not_in_usergroup"]."</td></tr>\n";
264}
265
266$content .= "</table>\n";
267
268//if this is an archived task, or you are a GUEST user, then no user functions are available
269if(($TASKID_ROW['archive'] == 0 ) && (! GUEST ) ) {
270
271 $form1 = "<form id=\"meown\" method=\"post\" action=\"tasks.php\">\n".
272 "<fieldset><input type=\"hidden\" name=\"x\" value=\"".X."\" />\n".
273 "<input type=\"hidden\" name=\"action\" value=\"meown\" />\n".
274 "<input type=\"hidden\" name=\"taskid\" value=\"".$taskid."\" />\n".
275 "<input type=\"hidden\" name=\"token\" value=\"".TOKEN."\" /></fieldset>\n".
276 "</form>\n";
277
278 $form2 = "<form id=\"done\" method=\"post\" action=\"tasks.php\">\n".
279 "<fieldset><input type=\"hidden\" name=\"x\" value=\"".X."\" />\n".
280 "<input type=\"hidden\" name=\"action\" value=\"done\" />\n".
281 "<input type=\"hidden\" name=\"taskid\" value=\"".$taskid."\" />\n".
282 "<input type=\"hidden\" name=\"token\" value=\"".TOKEN."\" /></fieldset>\n".
283 "</form>\n";
284
285 $form3 = "<form id=\"deown\" method=\"post\" action=\"tasks.php\">\n".
286 "<fieldset><input type=\"hidden\" name=\"x\" value=\"".X."\" />\n".
287 "<input type=\"hidden\" name=\"action\" value=\"deown\" />\n".
288 "<input type=\"hidden\" name=\"taskid\" value=\"".$taskid."\" />\n".
289 "<input type=\"hidden\" name=\"token\" value=\"".TOKEN."\" /></fieldset>\n".
290 "</form>\n";
291
292 $this_form = '';
293
294 $content .= "<div style=\"text-align : center\"><span class=\"textlink\">\n";
295
296 //set add function
297 switch($TYPE){
298 case 'project':
299 $content .= "[<a href=\"tasks.php?x=".X."&amp;action=add&amp;parentid=".$taskid."\">".$lang['add_task']."</a>]&nbsp;\n";
300 break;
301
302 case 'task':
303 $content .= "[<a href=\"tasks.php?x=".X."&amp;action=add&amp;parentid=".$taskid."\">".$lang['add_subtask']."</a>]&nbsp;\n";
304 break;
305 }
306
307 //unowned task ==> [I'll take it!] button
308 if($TASKID_ROW['owner'] == 0 ) {
309 $content .= "[<a href=\"javascript:void(document.getElementById('meown').submit())\">".sprintf($lang['i_take_it'] )."</a>]\n";
310 $this_form .= $form1;
311 }
312
313 //check for owner or group access
314 if((UID == $TASKID_ROW['owner'] ) ||
315 ($TASKID_ROW['groupaccess'] == "t") && (isset($GID[($TASKID_ROW['usergroupid'])] ) ) ) {
316 $access = true;
317 }
318 else {
319 $access = false;
320 }
321
322 //admin - owner - groupaccess ==> [edit] button
323 if((ADMIN ) || ($access ) ) {
324 $content .= "<span class=\"textlink\">".
325 "[<a href=\"tasks.php?x=".X."&amp;action=edit&amp;taskid=".$taskid."\">".$lang['edit']."</a>]&nbsp;\n".
326 "</span>\n";
327 }
328
329 //(owner - groupaccess) & (uncompleted task) ==> [I finished it] button
330 if(($access ) && ($TASKID_ROW['status'] != 'done' ) && ($TASKID_ROW['parent'] != 0 ) ) {
331 $content .= "[<a href=\"javascript:void(document.getElementById('done').submit())\">".$lang['i_finished']."</a>]&nbsp;\n";
332 $this_form .= $form2;
333 }
334
335 //(owner) & (uncompleted task)==> [I don't want it anymore] button
336 if(UID == $TASKID_ROW['owner'] && ($TASKID_ROW['status'] != 'done' ) ) {
337 $content .= "[<a href=\"javascript:void(document.getElementById('deown').submit())\">".$lang['i_dont_want']."</a>]&nbsp;\n";
338 $this_form .= $form3;
339 }
340
341 //(admin) & (not owner) & (has owner) & (uncompleted task) ==> [Take over task] button
342 if((ADMIN ) && (UID != $TASKID_ROW['owner'] ) && ($TASKID_ROW['owner'] != 0 ) && ($TASKID_ROW['status'] != 'done' ) ) {
343 $content .= "[<a href=\"javascript:void(document.getElementById('meown').submit())\">".sprintf($lang["take_over_".$TYPE] )."</a>]\n";
344 $this_form .= $form1;
345 }
346 $content .= "</span></div>\n".$this_form;
347}
348
349new_box( $title, $content, 'boxdata2' );
350
351?>
Note: See TracBrowser for help on using the repository browser.