2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]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',
18 'bugfield_static_text'
21 define('SVN', '$Id$');
23 $focus['showreport'] = 'focus';
25 require_once('./global.php');
26 require_once('./includes/functions_product.php');
28 $bugid = intval($bugsys->in
['bugid']);
30 // ###################################################################
32 if (empty($bugid) OR $_REQUEST['do'] == 'quicksearch')
36 if ($db->query_first("SELECT bugid FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bugid"))
38 header("Location: showreport.php?bugid=$bugid");
43 $error = $lang->getlex('error_invalid_id');
47 eval('$template->flush("' . $template->fetch('quicksearch') . '");');
51 // ###################################################################
53 // -------------------------------------------------------------------
55 $bug = $db->query_first("
56 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
57 FROM " . TABLE_PREFIX
. "bug AS bug
58 LEFT JOIN " . TABLE_PREFIX
. "user AS user
59 ON (bug.userid = user.userid)
60 LEFT JOIN " . TABLE_PREFIX
. "bugvaluefill AS bugvaluefill
61 ON (bug.bugid = bugvaluefill.bugid)
62 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
65 if (!can_perform('canviewbugs', $bug['productid']))
67 $message->error_permission();
70 $show['edit'] = ((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo
['userid'] == $bug['userid'] AND $bug['userid'] != 0) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo
['userid'] != $bug['userid']));
74 $message->error($lang->getlex('error_invalid_id'));
77 if ($bug['hidden'] AND !can_perform('canviewhidden', $bug['productid']))
79 $message->error_permission();
82 // ###################################################################
83 // global display items
85 $show['subscribe'] = can_perform('cansubscribe', $bug['productid']);
87 $favourite = (bool
)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "favourite WHERE bugid = $bug[bugid] AND userid = " . $bugsys->userinfo
['userid']);
88 $favouritetext = (($favourite) ?
$lang->string('Remove from Favourites') : $lang->string('Add to Favourites'));
90 $bug['userinfo'] = construct_user_display($bug);
91 $bug['datetime'] = $datef->format($bugsys->options
['dateformat'], $bug['dateline']);
92 $bug['product'] = $bugsys->datastore
['product']["$bug[productid]"]['title'];
93 $bug['component'] = (($bug['componentid']) ?
$bugsys->datastore
['product']["$bug[componentid]"]['title'] : '');
94 $bug['version'] = $bugsys->datastore
['version']["$bug[versionid]"]['version'];
96 // ###################################################################
100 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
102 $show['changestatus'] = ((can_perform('canchangestatus', $bug['productid'])) ? true
: false
);
103 if (can_perform('canchangestatus', $bug['productid']))
105 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
106 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
107 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
111 $bug['status'] = $bugsys->datastore
['status']["$bug[status]"]['status'];
112 $bug['resolution'] = $bugsys->datastore
['resolution']["$bug[resolution]"]['resolution'];
113 $bug['severity'] = $bugsys->datastore
['severity']["$bug[severity]"]['severity'];
114 $bug['priority'] = $bugsys->datastore
['priority']["$bug[priority]"]['priority'];
117 $show['assign'] = ((can_perform('canassign', $bug['productid'])) ? true
: false
);
118 if (can_perform('canassign', $bug['productid']))
120 foreach ($bugsys->datastore
['assignto'] AS $dev)
122 $value = $dev['userid'];
123 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
124 $label = construct_user_display($dev, false
);
125 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
129 $pcv_select = construct_pcv_select('canviewbugs', "p$bug[productid]c$bug[componentid]v$bug[versionid]");
131 if ($bug['duplicateof'])
133 $duplicate = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
136 if ($bug['dependency'])
138 $dependencies = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
139 while ($dependency = $db->fetch_array($dependencies))
141 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" title=\"$dependency[summary]\">$dependency[bugid]</a>";
143 $dependencies = implode(' ', $depends);
146 $select['autoactions'] = '';
147 $show['autoactions'] = false
;
148 foreach ($bugsys->datastore
['autoaction'] AS $action)
150 $label = $action['name'];
151 $value = $action['actionid'];
153 eval('$select[autoaction] .= "' . $template->fetch('selectoption') . '";');
154 $show['autoactions'] = true
;
156 if ($show['autoactions'])
161 eval('$select[autoaction] = "' . $template->fetch('selectoption') . '" . $select[autoaction];');
165 // ###################################################################
169 // -------------------------------------------------------------------
171 $bug['status'] = $bugsys->datastore
['status']["$bug[status]"]['status'];
172 $bug['resolution'] = $bugsys->datastore
['resolution']["$bug[resolution]"]['resolution'];
173 $bug['severity'] = $bugsys->datastore
['severity']["$bug[severity]"]['severity'];
174 $bug['priority'] = $bugsys->datastore
['priority']["$bug[priority]"]['priority'];
176 $assigninfo = $bugsys->datastore
['assignto']["$bug[assignedto]"];
177 $bug['assigninfo'] = ((is_array($assigninfo)) ?
construct_user_display($assigninfo) : '');
179 $duplicateof = $db->query_first("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
181 $duplicates = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE duplicateof = $bug[bugid]");
182 while ($duplicate = $db->fetch_array($duplicates))
184 $dupelist[] = "<a href=\"showreport.php?bugid=$duplicate[bugid]\" target=\"_blank\">$duplicate[summary]</a>";
186 $dupelist = implode(', ', $dupelist);
188 if ($bug['dependency'])
190 $dependencies = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
191 while ($dependency = $db->fetch_array($dependencies))
193 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" title=\"$dependency[summary]\" target=\"_blank\">$dependency[bugid]</a>";
195 $dependencies = implode(' ', $depends);
199 // ###################################################################
200 // custom field output
202 $fields = construct_custom_fields($bug);
204 foreach ($fields AS $field)
208 $customfields['left'] .= $field;
212 $customfields['right'] .= $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', $bug['productid']) OR can_perform('caneditattach', $bug['productid'])) ? true
: false
);
235 $show['putattachments'] = ((can_perform('canputattach', $bug['productid']) OR can_perform('caneditattach', $bug['productid'])) ? 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.attachmentid, attachment.filename,
242 attachment.description, attachment.dateline,
243 attachment.userid, attachment.obsolete, user.email,
244 user.showemail, user.displayname
245 FROM " . TABLE_PREFIX
. "attachment AS attachment
246 LEFT JOIN " . TABLE_PREFIX
. "user AS user
247 ON (attachment.userid = user.userid)
248 WHERE attachment.bugid = $bug[bugid]
249 ORDER BY attachment.dateline"
253 while ($attachment = $db->fetch_array($attachments_fetch))
256 $show['editattach'] = ((can_perform('caneditattach', $bug['productid']) OR ($attachment['userid'] == $bugsys->userinfo
['userid'] AND can_perform('canputattach', $bug['productid']))) ? true
: false
);
257 $attachment['date'] = $datef->format($bugsys->options
['dateformat'], $attachment['dateline']);
258 $attachment['user'] = construct_user_display($attachment, false
);
259 eval('$attachments .= "' . $template->fetch('showreport_attachment') . '";');
262 $show['attachments'] = (!$show['putattachments'] AND !$attaches) ? false
: true
;
265 // -------------------------------------------------------------------
268 $vote = $db->query_first("SELECT *, FIND_IN_SET(" . $bugsys->userinfo
['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX
. "vote WHERE bugid = $bug[bugid]");
270 $vote['total'] = $vote['votefor'] +
$vote['voteagainst'];
271 $vote['forpercent'] = round($vote['votefor'] / $vote['total'], 3) * 100;
272 $vote['againstpercent'] = round($vote['voteagainst'] / $vote['total'], 3) * 100;
274 $show['vote'] = ((can_perform('canvote', $bug['productid']) AND !$vote['uservote']) ? true
: false
);
276 // -------------------------------------------------------------------
278 $comments_fetch = $db->query("
279 SELECT comment.*, user.email, user.showemail, user.displayname
280 FROM " . TABLE_PREFIX
. "comment AS comment
281 LEFT JOIN " . TABLE_PREFIX
. "user AS user
282 ON (comment.userid = user.userid)
283 WHERE comment.bugid = $bug[bugid]" . ((!can_perform('canviewhidden', $bug['productid'])) ?
"
284 AND !hidden" : '') . "
285 ORDER BY comment.dateline ASC"
287 while ($comment = $db->fetch_array($comments_fetch))
289 $comment['posttime'] = $datef->format($bugsys->options
['dateformat'], $comment['dateline']);
290 $comment['postby'] = construct_user_display($comment);
291 $show['editcomment'] = ((can_perform('caneditownreply', $bug['productid']) AND $bugsys->userinfo
['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['productid']) AND $bugsys->userinfo
['userid'] != $comment['userid']));
293 $bugsys->debug('can edit own replies: ' . (int)(can_perform('caneditownreply', $bug['productid']) AND $bugsys->userinfo
['userid'] == $comment['userid']));
294 $bugsys->debug('can edit other replies:' . (int)(can_perform('caneditotherreply', $bug['productid']) AND $bugsys->userinfo
['userid'] != $comment['userid']));
295 $bugsys->debug('$show[editcomment]: ' . $show['editcomment']);
297 if (is_array($hilight))
299 foreach ($hilight AS $id => $find)
301 $find = "#($find)#i";
302 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
303 $comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
307 eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
310 $show['newreply'] = ((can_perform('canpostcomments', $bug['productid'])) ? true
: false
);
312 if (is_array($hilight))
314 foreach ($hilight AS $id => $find)
316 $find = "#($find)#i";
317 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
318 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
322 eval('$template->flush("' . $template->fetch('showreport') . '");');
324 /*=====================================================================*\
325 || ###################################################################
328 || ###################################################################
329 \*=====================================================================*/