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 $focus['showreport'] = 'focus';
23 require_once('./global.php');
25 if (!can_perform('canviewbugs'))
27 $message->error_permission();
30 // ###################################################################
32 // -------------------------------------------------------------------
34 $bug = $db->query_first("
35 SELECT bug.*, user.displayname, user.email, user.showemail
36 FROM " . TABLE_PREFIX
. "bug AS bug
37 LEFT JOIN " . TABLE_PREFIX
. "user AS user
38 ON (bug.userid = user.userid)
39 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
44 $message->error('alert: bad bug');
47 if ($bug['hidden'] AND !can_perform('canviewhidden'))
49 $message->error_permission();
52 // -------------------------------------------------------------------
54 $bug['userinfo'] = construct_user_display($bug);
55 $bug['product'] = $bugsys->datastore
['product']["$bug[productid]"]['title'];
56 $bug['component'] = (($bug['componentid']) ?
$bugsys->datastore
['product']["$bug[componentid]"]['title'] : '');
57 $bug['version'] = $bugsys->datastore
['version']["$bug[versionid]"]['version'];
58 $bug['status'] = $bugsys->datastore
['status']["$bug[status]"]['status'];
59 $bug['resolution'] = $bugsys->datastore
['resolution']["$bug[resolution]"]['resolution'];
60 $bug['severity'] = $bugsys->datastore
['severity']["$bug[severity]"]['severity'];
61 $bug['priority'] = $bugsys->datastore
['priority']["$bug[priority]"]['priority'];
63 $assigninfo = $bugsys->datastore
['assignto']["$bug[assignedto]"];
64 $bug['assigninfo'] = ((is_array($assigninfo)) ?
construct_user_display($assigninfo) : '');
66 $show['editreport'] = ((((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')) ? true
: false
);
68 $duplicateof = $db->query_first("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
70 $duplicates = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE duplicateof = $bug[bugid]");
71 while ($duplicate = $db->fetch_array($duplicates))
73 $dupelist[] = "<a href=\"showreport.php?bugid=$duplicate[bugid]\" target=\"_blank\">$duplicate[summary]</a>";
75 $dupelist = implode(', ', $dupelist);
77 if ($bug['dependency'])
79 $dependencies = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
80 while ($dependency = $db->fetch_array($dependencies))
82 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" title=\"$dependency[summary]\" target=\"_blank\">$dependency[bugid]</a>";
84 $dependencies = implode(' ', $depends);
87 $favourite = (bool
)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "favourite WHERE bugid = $bug[bugid] AND userid = " . $bugsys->userinfo
['userid']);
88 $favouritetext = (($favourite) ?
'Remove from Favourites' : 'Add to Favourites');
90 // -------------------------------------------------------------------
94 $allfields = $db->query("
96 FROM " . TABLE_PREFIX
. "bugfield AS bugfield
97 LEFT JOIN " . TABLE_PREFIX
. "bugfieldpermission AS permission
98 ON (bugfield.fieldid = permission.fieldid)
99 WHERE permission.mask <> 0
100 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}"
102 while ($field = $db->fetch_array($allfields))
104 $fieldlist["$field[fieldid]"] = $field;
107 $fieldvalues = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
109 foreach ($fieldlist AS $fieldid => $field)
111 if (is_null($fieldvalues["field$fieldid"]))
113 if ($field['type'] == 'select_single')
115 if ($field['usedefault'])
117 $temp = unserialize($field['selects']);
118 $value = trim($temp[0]);
127 $value = $field['defaultvalue'];
132 $value = $fieldvalues["field$fieldid"];
135 $customfields .= "<div><strong>$field[name]:</strong> ";
137 if ($field['type'] == 'input_text' OR $field['type'] == 'select_single')
139 $customfields .= $value;
141 else if ($field['type'] == 'input_checkbox')
143 $customfields .= (($value) ?
'True' : 'False');
145 $customfields .= "</div>\n\n";
148 // -------------------------------------------------------------------
150 $words = explode(' ', $bugsys->in
['hilight']);
151 foreach ($words AS $word)
155 $word = preg_quote($bugsys->unsanitize($word));
156 $hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
160 // -------------------------------------------------------------------
162 $show['getattachments'] = ((can_perform('cangetattach') OR can_perform('caneditattach')) ? true
: false
);
163 $show['putattachments'] = ((can_perform('canputattach') OR can_perform('caneditattach')) ? true
: false
);
165 if ($show['getattachments'] OR $show['putattachments'])
167 $attachments_fetch = $db->query("
168 SELECT attachment.*, user.email, user.showemail,
170 FROM " . TABLE_PREFIX
. "attachment AS attachment
171 LEFT JOIN " . TABLE_PREFIX
. "user AS user
172 ON (attachment.userid = user.userid)
173 WHERE attachment.bugid = $bug[bugid]
174 ORDER BY attachment.dateline"
176 while ($attachment = $db->fetch_array($attachments_fetch))
178 $show['editattach'] = ((can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo
['userid'] AND can_perform('canputattach'))) ? true
: false
);
179 $attachment['date'] = $datef->format($bugsys->options
['dateformat'], $attachment['dateline']);
180 $attachment['user'] = construct_user_display($attachment, false
);
181 eval('$attachments .= "' . $template->fetch('showreport_attachment') . '";');
185 // -------------------------------------------------------------------
188 $vote = $db->query_first("SELECT *, FIND_IN_SET(" . $bugsys->userinfo
['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX
. "vote WHERE bugid = $bug[bugid]");
190 $vote['total'] = $vote['votefor'] +
$vote['voteagainst'];
191 $vote['forpercent'] = round($vote['votefor'] / $vote['total'], 3) * 100;
192 $vote['againstpercent'] = round($vote['voteagainst'] / $vote['total'], 3) * 100;
194 $show['vote'] = ((can_perform('canvote') AND !$vote['uservote']) ? true
: false
);
196 // -------------------------------------------------------------------
198 $comments_fetch = $db->query("
199 SELECT comment.*, user.email, user.showemail, user.displayname
200 FROM " . TABLE_PREFIX
. "comment AS comment
201 LEFT JOIN " . TABLE_PREFIX
. "user AS user
202 ON (comment.userid = user.userid)
203 WHERE comment.bugid = $bug[bugid]" . ((!can_perform('canviewhidden')) ?
"
204 AND !hidden" : '') . "
205 ORDER BY comment.dateline ASC"
207 while ($comment = $db->fetch_array($comments_fetch))
209 $comment['posttime'] = $datef->format($bugsys->options
['dateformat'], $comment['dateline']);
210 $comment['postby'] = construct_user_display($comment);
211 $show['editcomment'] = (((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) ? true
: false
);
213 if (is_array($hilight))
215 foreach ($hilight AS $id => $find)
218 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
219 $comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
223 eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
226 $show['newreply'] = ((can_perform('canpostcomments')) ? true
: false
);
228 if (is_array($hilight))
230 foreach ($hilight AS $id => $find)
233 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
234 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
238 eval('$template->flush("' . $template->fetch('SHOWREPORT') . '");');
240 /*=====================================================================*\
241 || ###################################################################
244 || ###################################################################
245 \*=====================================================================*/