r303: Added SVN constant to user files; now ISSO debug information shows SVN details.
[bugdar.git] / showreport.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 'SHOWREPORT',
15 'showreport_attachment',
16 'showreport_comment'
17 );
18
19 define('SVN', '$Id$');
20
21 require_once('./global.php');
22
23 if (!can_perform('canviewbugs'))
24 {
25 $message->error_permission();
26 }
27
28 // ###################################################################
29
30 // -------------------------------------------------------------------
31 // get the report
32 $bug = $db->query_first("
33 SELECT bug.*, user.displayname, user.email, user.showemail
34 FROM " . TABLE_PREFIX . "bug AS bug
35 LEFT JOIN " . TABLE_PREFIX . "user AS user
36 ON (bug.userid = user.userid)
37 WHERE bug.bugid = " . intval($bugsys->in['bugid'])
38 );
39
40 if (!is_array($bug))
41 {
42 $message->error('alert: bad bug');
43 }
44
45 if ($bug['hidden'] AND !can_perform('canviewhidden'))
46 {
47 $message->error_permission();
48 }
49
50 // -------------------------------------------------------------------
51 // prep display
52 $bug['userinfo'] = construct_user_display($bug);
53 $bug['product'] = $bugsys->datastore['product']["$bug[productid]"]['title'];
54 $bug['component'] = (($bug['componentid']) ? $bugsys->datastore['product']["$bug[componentid]"]['title'] : '');
55 $bug['version'] = $bugsys->datastore['version']["$bug[versionid]"]['version'];
56 $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
57 $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
58 $bug['severity'] = $bugsys->datastore['severity']["$bug[severity]"]['severity'];
59 $bug['priority'] = $bugsys->datastore['priority']["$bug[priority]"]['priority'];
60
61 $assigninfo = $bugsys->datastore['assignto']["$bug[assignedto]"];
62 $bug['assigninfo'] = ((is_array($assigninfo)) ? construct_user_display($assigninfo) : '');
63
64 $show['editreport'] = ((((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')) ? true : false);
65
66 $duplicateof = $db->query_first("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[duplicateof]");
67
68 $duplicates = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE duplicateof = $bug[bugid]");
69 while ($duplicate = $db->fetch_array($duplicates))
70 {
71 $dupelist[] = "<a href=\"showreport.php?bugid=$duplicate[bugid]\" target=\"_blank\">$duplicate[summary]</a>";
72 }
73 $dupelist = implode(', ', $dupelist);
74
75 if ($bug['dependency'])
76 {
77 $dependencies = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE bugid IN ($bug[dependency])");
78 while ($dependency = $db->fetch_array($dependencies))
79 {
80 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" title=\"$dependency[summary]\" target=\"_blank\">$dependency[bugid]</a>";
81 }
82 $dependencies = implode(' ', $depends);
83 }
84
85 $favourite = (bool)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "favourite WHERE bugid = $bug[bugid] AND userid = " . $bugsys->userinfo['userid']);
86 $favouritetext = (($favourite) ? 'Remove from Favourites' : 'Add to Favourites');
87
88 // -------------------------------------------------------------------
89 // custom fields
90 $customfields = '';
91
92 $allfields = $db->query("
93 SELECT bugfield.*
94 FROM " . TABLE_PREFIX . "bugfield AS bugfield
95 LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
96 ON (bugfield.fieldid = permission.fieldid)
97 WHERE permission.mask <> 0
98 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}"
99 );
100 while ($field = $db->fetch_array($allfields))
101 {
102 $fieldlist["$field[fieldid]"] = $field;
103 }
104
105 $fieldvalues = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]");
106
107 foreach ($fieldlist AS $fieldid => $field)
108 {
109 if (is_null($fieldvalues["field$fieldid"]))
110 {
111 if ($field['type'] == 'select_single')
112 {
113 if ($field['usedefault'])
114 {
115 $temp = unserialize($field['selects']);
116 $value = trim($temp[0]);
117 }
118 else
119 {
120 continue;
121 }
122 }
123 else
124 {
125 $value = $field['defaultvalue'];
126 }
127 }
128 else
129 {
130 $value = $fieldvalues["field$fieldid"];
131 }
132
133 $customfields .= "<div><strong>$field[name]:</strong> ";
134
135 if ($field['type'] == 'input_text' OR $field['type'] == 'select_single')
136 {
137 $customfields .= $value;
138 }
139 else if ($field['type'] == 'input_checkbox')
140 {
141 $customfields .= (($value) ? 'True' : 'False');
142 }
143 $customfields .= "</div>\n\n";
144 }
145
146 // -------------------------------------------------------------------
147 // hilight
148 $words = explode(' ', $bugsys->in['hilight']);
149 foreach ($words AS $word)
150 {
151 if (trim($word))
152 {
153 $word = preg_quote($bugsys->unsanitize($word));
154 $hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
155 }
156 }
157
158 // -------------------------------------------------------------------
159 // attachments
160 $show['getattachments'] = ((can_perform('cangetattach') OR can_perform('caneditattach')) ? true : false);
161 $show['putattachments'] = ((can_perform('canputattach') OR can_perform('caneditattach')) ? true : false);
162
163 if ($show['getattachments'] OR $show['putattachments'])
164 {
165 $attachments_fetch = $db->query("
166 SELECT attachment.*, user.email, user.showemail,
167 user.displayname
168 FROM " . TABLE_PREFIX . "attachment AS attachment
169 LEFT JOIN " . TABLE_PREFIX . "user AS user
170 ON (attachment.userid = user.userid)
171 WHERE attachment.bugid = $bug[bugid]
172 ORDER BY attachment.dateline"
173 );
174 while ($attachment = $db->fetch_array($attachments_fetch))
175 {
176 $show['editattach'] = ((can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo['userid'] AND can_perform('canputattach'))) ? true : false);
177 $attachment['date'] = $datef->format($bugsys->options['dateformat'], $attachment['dateline']);
178 $attachment['user'] = construct_user_display($attachment, false);
179 eval('$attachments .= "' . $template->fetch('showreport_attachment') . '";');
180 }
181 }
182
183 // -------------------------------------------------------------------
184 // votes
185
186 $vote = $db->query_first("SELECT *, FIND_IN_SET(" . $bugsys->userinfo['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX . "vote WHERE bugid = $bug[bugid]");
187
188 $vote['total'] = $vote['votefor'] + $vote['voteagainst'];
189 $vote['forpercent'] = round($vote['votefor'] / $vote['total'], 3) * 100;
190 $vote['againstpercent'] = round($vote['voteagainst'] / $vote['total'], 3) * 100;
191
192 $show['vote'] = ((can_perform('canvote') AND !$vote['uservote']) ? true : false);
193
194 // -------------------------------------------------------------------
195 // get comments
196 $comments_fetch = $db->query("
197 SELECT comment.*, user.email, user.showemail, user.displayname
198 FROM " . TABLE_PREFIX . "comment AS comment
199 LEFT JOIN " . TABLE_PREFIX . "user AS user
200 ON (comment.userid = user.userid)
201 WHERE comment.bugid = $bug[bugid]" . ((!can_perform('canviewhidden')) ? "
202 AND !hidden" : '') . "
203 ORDER BY comment.dateline ASC"
204 );
205 while ($comment = $db->fetch_array($comments_fetch))
206 {
207 $comment['posttime'] = $datef->format($bugsys->options['dateformat'], $comment['dateline']);
208 $comment['postby'] = construct_user_display($comment);
209 $show['editcomment'] = (((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) ? true : false);
210
211 if (is_array($hilight))
212 {
213 foreach ($hilight AS $id => $find)
214 {
215 $find = "#($find)#";
216 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
217 $comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
218 }
219 }
220
221 eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
222 }
223
224 $show['newreply'] = ((can_perform('canpostcomments')) ? true : false);
225
226 if (is_array($hilight))
227 {
228 foreach ($hilight AS $id => $find)
229 {
230 $find = "#($find)#";
231 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
232 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
233 }
234 }
235
236 eval('$template->flush("' . $template->fetch('SHOWREPORT') . '");');
237
238 /*=====================================================================*\
239 || ###################################################################
240 || # $HeadURL$
241 || # $Id$
242 || ###################################################################
243 \*=====================================================================*/
244 ?>