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 define('SVN', '$Id$');
21 require_once('./global.php');
23 if (!can_perform('canviewbugs'))
25 $message->error_permission();
28 // ###################################################################
30 // -------------------------------------------------------------------
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'])
42 $message->error('alert: bad bug');
45 if ($bug['hidden'] AND !can_perform('canviewhidden'))
47 $message->error_permission();
50 // -------------------------------------------------------------------
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'];
61 $assigninfo = $bugsys->datastore
['assignto']["$bug[assignedto]"];
62 $bug['assigninfo'] = ((is_array($assigninfo)) ?
construct_user_display($assigninfo) : '');
64 $show['editreport'] = ((((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')) ? true
: false
);
66 $duplicateof = $db->query_first("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
68 $duplicates = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE duplicateof = $bug[bugid]");
69 while ($duplicate = $db->fetch_array($duplicates))
71 $dupelist[] = "<a href=\"showreport.php?bugid=$duplicate[bugid]\" target=\"_blank\">$duplicate[summary]</a>";
73 $dupelist = implode(', ', $dupelist);
75 if ($bug['dependency'])
77 $dependencies = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
78 while ($dependency = $db->fetch_array($dependencies))
80 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" title=\"$dependency[summary]\" target=\"_blank\">$dependency[bugid]</a>";
82 $dependencies = implode(' ', $depends);
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');
88 // -------------------------------------------------------------------
92 $allfields = $db->query("
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']}"
100 while ($field = $db->fetch_array($allfields))
102 $fieldlist["$field[fieldid]"] = $field;
105 $fieldvalues = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
107 foreach ($fieldlist AS $fieldid => $field)
109 if (is_null($fieldvalues["field$fieldid"]))
111 if ($field['type'] == 'select_single')
113 if ($field['usedefault'])
115 $temp = unserialize($field['selects']);
116 $value = trim($temp[0]);
125 $value = $field['defaultvalue'];
130 $value = $fieldvalues["field$fieldid"];
133 $customfields .= "<div><strong>$field[name]:</strong> ";
135 if ($field['type'] == 'input_text' OR $field['type'] == 'select_single')
137 $customfields .= $value;
139 else if ($field['type'] == 'input_checkbox')
141 $customfields .= (($value) ?
'True' : 'False');
143 $customfields .= "</div>\n\n";
146 // -------------------------------------------------------------------
148 $words = explode(' ', $bugsys->in
['hilight']);
149 foreach ($words AS $word)
153 $word = preg_quote($bugsys->unsanitize($word));
154 $hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
158 // -------------------------------------------------------------------
160 $show['getattachments'] = ((can_perform('cangetattach') OR can_perform('caneditattach')) ? true
: false
);
161 $show['putattachments'] = ((can_perform('canputattach') OR can_perform('caneditattach')) ? true
: false
);
163 if ($show['getattachments'] OR $show['putattachments'])
165 $attachments_fetch = $db->query("
166 SELECT attachment.*, user.email, user.showemail,
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"
174 while ($attachment = $db->fetch_array($attachments_fetch))
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') . '";');
183 // -------------------------------------------------------------------
186 $vote = $db->query_first("SELECT *, FIND_IN_SET(" . $bugsys->userinfo
['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX
. "vote WHERE bugid = $bug[bugid]");
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;
192 $show['vote'] = ((can_perform('canvote') AND !$vote['uservote']) ? true
: false
);
194 // -------------------------------------------------------------------
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"
205 while ($comment = $db->fetch_array($comments_fetch))
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
);
211 if (is_array($hilight))
213 foreach ($hilight AS $id => $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']);
221 eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
224 $show['newreply'] = ((can_perform('canpostcomments')) ? true
: false
);
226 if (is_array($hilight))
228 foreach ($hilight AS $id => $find)
231 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
232 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
236 eval('$template->flush("' . $template->fetch('SHOWREPORT') . '");');
238 /*=====================================================================*\
239 || ###################################################################
242 || ###################################################################
243 \*=====================================================================*/