r546: Additional permission checking
[bugdar.git] / showhistory.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 $fetchtemplates = array(
14 'history',
15 'history_bit'
16 );
17
18 define('SVN', '$Id$');
19
20 $focus['showreport'] = 'focus';
21
22 require_once('./global.php');
23
24 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . intval($bugsys->in['bugid']));
25 if (!$bug)
26 {
27 $message->error($lang->getlex('error_invalid_id'));
28 }
29
30 if (($bug['hidden'] AND !can_perform('canviewhidden', $bug['productid'])) OR !can_perform('canviewbugs', $bug['productid']))
31 {
32 $message->error_permission();
33 }
34
35 // ###################################################################
36
37 $customfields = $db->query("
38 SELECT bugfield.*
39 FROM " . TABLE_PREFIX . "bugfield AS bugfield
40 LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
41 ON (bugfield.fieldid = permission.fieldid)
42 WHERE permission.mask <> 0
43 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}"
44 );
45
46 while ($field = $db->fetch_array($customfields))
47 {
48 $fieldlist["custom_field$field[fieldid]"] = 'custom_field' . $field['fieldid'] . " (\"$field[name]\")";
49 }
50
51 // ###################################################################
52
53 $logs_fetch = $db->query("
54 SELECT history.*, user.userid, user.email, user.displayname, user.showemail
55 FROM " . TABLE_PREFIX . "history AS history
56 LEFT JOIN " . TABLE_PREFIX . "user AS user
57 ON (user.userid = history.userid)
58 WHERE bugid = $bug[bugid]"
59 );
60 while ($log = $db->fetch_array($logs_fetch))
61 {
62 $log['date'] = $datef->format($bugsys->options['dateformat'], $log['dateline']);
63 $log['user'] = construct_user_display($log);
64
65 $logs["$log[dateline]"]["$log[historyid]"] = $log;
66 ksort($logs["$log[dateline]"]);
67 }
68
69 ksort($logs);
70
71 foreach ($logs AS $dateline => $logitems)
72 {
73 $show['group'] = true;
74
75 foreach ($logitems AS $log)
76 {
77 $funct->exec_swap_bg('', $stylevar['alt_colour']);
78 $bgcolour = $funct->bgcolour;
79
80 if ($newlog = $fieldlist["$log[field]"])
81 {
82 $log['field'] = $newlog;
83 }
84
85 eval('$history .= "' . $template->fetch('history_bit') . '";');
86 $show['group'] = false;
87 }
88 }
89
90 eval('$template->flush("' . $template->fetch('history') . '");');
91
92 /*=====================================================================*\
93 || ###################################################################
94 || # $HeadURL$
95 || # $Id$
96 || ###################################################################
97 \*=====================================================================*/
98 ?>