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 \*=====================================================================*/
13 $fetchtemplates = array(
15 'showreport_attachment',
19 'bugfield_static_text'
22 define('SVN', '$Id$');
24 $focus['showreport'] = 'focus';
26 require_once('./global.php');
27 require_once('./includes/functions_product.php');
29 if (!can_perform('canviewbugs'))
31 $message->error_permission();
34 $show['edit'] = (((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $bug['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')) ? true
: false
;
36 $bugid = intval($bugsys->in
['bugid']);
38 // ###################################################################
40 if (empty($bugid) OR $_REQUEST['do'] == 'quicksearch')
44 if ($db->query_first("SELECT bugid FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bugid"))
46 header("Location: showreport.php?bugid=$bugid");
51 $error = $lang->getlex('error_invalid_id');
55 eval('$template->flush("' . $template->fetch('quicksearch') . '");');
59 // ###################################################################
61 // -------------------------------------------------------------------
63 $bug = $db->query_first("
64 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
65 FROM " . TABLE_PREFIX
. "bug AS bug
66 LEFT JOIN " . TABLE_PREFIX
. "user AS user
67 ON (bug.userid = user.userid)
68 LEFT JOIN " . TABLE_PREFIX
. "bugvaluefill AS bugvaluefill
69 ON (bug.bugid = bugvaluefill.bugid)
70 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
75 $message->error($lang->getlex('error_invalid_id'));
78 if ($bug['hidden'] AND !can_perform('canviewhidden'))
80 $message->error_permission();
83 // ###################################################################
84 // global display items
86 $favourite = (bool
)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "favourite WHERE bugid = $bug[bugid] AND userid = " . $bugsys->userinfo
['userid']);
87 $favouritetext = (($favourite) ?
$lang->string('Remove from Favourites') : $lang->string('Add to Favourites'));
89 $bug['userinfo'] = construct_user_display($bug);
90 $bug['datetime'] = $datef->format($bugsys->options
['dateformat'], $bug['dateline']);
91 $bug['product'] = $bugsys->datastore
['product']["$bug[productid]"]['title'];
92 $bug['component'] = (($bug['componentid']) ?
$bugsys->datastore
['product']["$bug[componentid]"]['title'] : '');
93 $bug['version'] = $bugsys->datastore
['version']["$bug[versionid]"]['version'];
95 // ###################################################################
99 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
101 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
102 if (can_perform('canchangestatus'))
104 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
105 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
106 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
109 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
110 if (can_perform('canassign'))
112 foreach ($bugsys->datastore
['assignto'] AS $dev)
114 $value = $dev['userid'];
115 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
116 $label = construct_user_display($dev, false
);
117 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
121 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
123 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
125 if ($bug['duplicateof'])
127 $duplicate = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
130 if ($bug['dependency'])
132 $dependencies = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
133 while ($dependency = $db->fetch_array($dependencies))
135 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" title=\"$dependency[summary]\">$dependency[bugid]</a>";
137 $dependencies = implode(' ', $depends);
140 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "autoaction ORDER BY name ASC");
141 $select['autoactions'] = '';
142 $show['autoactions'] = false
;
143 while ($action = $db->fetch_array($actions))
145 $label = $action['name'];
146 $value = $action['actionid'];
148 eval('$select[autoaction] .= "' . $template->fetch('selectoption') . '";');
149 $show['autoactions'] = true
;
151 if ($show['autoactions'])
156 eval('$select[autoaction] = "' . $template->fetch('selectoption') . '" . $select[autoaction];');
160 // ###################################################################
164 // -------------------------------------------------------------------
166 $bug['status'] = $bugsys->datastore
['status']["$bug[status]"]['status'];
167 $bug['resolution'] = $bugsys->datastore
['resolution']["$bug[resolution]"]['resolution'];
168 $bug['severity'] = $bugsys->datastore
['severity']["$bug[severity]"]['severity'];
169 $bug['priority'] = $bugsys->datastore
['priority']["$bug[priority]"]['priority'];
171 $assigninfo = $bugsys->datastore
['assignto']["$bug[assignedto]"];
172 $bug['assigninfo'] = ((is_array($assigninfo)) ?
construct_user_display($assigninfo) : '');
174 $duplicateof = $db->query_first("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
176 $duplicates = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE duplicateof = $bug[bugid]");
177 while ($duplicate = $db->fetch_array($duplicates))
179 $dupelist[] = "<a href=\"showreport.php?bugid=$duplicate[bugid]\" target=\"_blank\">$duplicate[summary]</a>";
181 $dupelist = implode(', ', $dupelist);
183 if ($bug['dependency'])
185 $dependencies = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
186 while ($dependency = $db->fetch_array($dependencies))
188 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" title=\"$dependency[summary]\" target=\"_blank\">$dependency[bugid]</a>";
190 $dependencies = implode(' ', $depends);
194 // ###################################################################
195 // custom field output
197 $fields = construct_custom_fields($bug);
198 $show['customfields'] = ($fields ? true
: false
);
200 $bugsys->debug('fields modulo: ' . count($fields) %
2);
202 foreach ($fields AS $field)
204 $bugsys->debug("i = $i");
207 $customfields['right'] .= $field;
211 $customfields['left'] .= $field;
217 // ###################################################################
220 // -------------------------------------------------------------------
222 $words = explode(' ', $bugsys->in
['hilight']);
223 foreach ($words AS $word)
227 $word = preg_quote($bugsys->unsanitize($word));
228 $hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
232 // -------------------------------------------------------------------
234 $show['getattachments'] = ((can_perform('cangetattach') OR can_perform('caneditattach')) ? true
: false
);
235 $show['putattachments'] = ((can_perform('canputattach') OR can_perform('caneditattach')) ? true
: false
);
236 $show['attachments'] = ($show['getattachments'] OR $show['putattachments']) ? true
: false
;
238 if ($show['getattachments'] OR $show['putattachments'])
240 $attachments_fetch = $db->query("
241 SELECT attachment.*, user.email, user.showemail,
243 FROM " . TABLE_PREFIX
. "attachment AS attachment
244 LEFT JOIN " . TABLE_PREFIX
. "user AS user
245 ON (attachment.userid = user.userid)
246 WHERE attachment.bugid = $bug[bugid]
247 ORDER BY attachment.dateline"
251 while ($attachment = $db->fetch_array($attachments_fetch))
254 $show['editattach'] = ((can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo
['userid'] AND can_perform('canputattach'))) ? true
: false
);
255 $attachment['date'] = $datef->format($bugsys->options
['dateformat'], $attachment['dateline']);
256 $attachment['user'] = construct_user_display($attachment, false
);
257 eval('$attachments .= "' . $template->fetch('showreport_attachment') . '";');
260 $show['attachments'] = (!$show['putattachments'] AND !$attaches) ? false
: true
;
263 // -------------------------------------------------------------------
266 $vote = $db->query_first("SELECT *, FIND_IN_SET(" . $bugsys->userinfo
['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX
. "vote WHERE bugid = $bug[bugid]");
268 $vote['total'] = $vote['votefor'] +
$vote['voteagainst'];
269 $vote['forpercent'] = round($vote['votefor'] / $vote['total'], 3) * 100;
270 $vote['againstpercent'] = round($vote['voteagainst'] / $vote['total'], 3) * 100;
272 $show['vote'] = ((can_perform('canvote') AND !$vote['uservote']) ? true
: false
);
274 // -------------------------------------------------------------------
276 $comments_fetch = $db->query("
277 SELECT comment.*, user.email, user.showemail, user.displayname
278 FROM " . TABLE_PREFIX
. "comment AS comment
279 LEFT JOIN " . TABLE_PREFIX
. "user AS user
280 ON (comment.userid = user.userid)
281 WHERE comment.bugid = $bug[bugid]" . ((!can_perform('canviewhidden')) ?
"
282 AND !hidden" : '') . "
283 ORDER BY comment.dateline ASC"
285 while ($comment = $db->fetch_array($comments_fetch))
287 $comment['posttime'] = $datef->format($bugsys->options
['dateformat'], $comment['dateline']);
288 $comment['postby'] = construct_user_display($comment);
289 $show['editcomment'] = (((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) ? true
: false
);
291 if (is_array($hilight))
293 foreach ($hilight AS $id => $find)
296 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
297 $comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
301 eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
304 $show['newreply'] = ((can_perform('canpostcomments')) ? true
: false
);
306 if (is_array($hilight))
308 foreach ($hilight AS $id => $find)
311 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
312 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
316 eval('$template->flush("' . $template->fetch('showreport') . '");');
318 /*=====================================================================*\
319 || ###################################################################
322 || ###################################################################
323 \*=====================================================================*/