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',
20 define('SVN', '$Id$');
22 $focus['showreport'] = 'focus';
24 require_once('./global.php');
26 if (!can_perform('canviewbugs'))
28 $message->error_permission();
31 $bugid = intval($bugsys->in
['bugid']);
33 // ###################################################################
35 if (empty($bugid) OR $_REQUEST['do'] == 'quicksearch')
39 if ($db->query_first("SELECT bugid FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bugid"))
41 header("Location: showreport.php?bugid=$bugid");
46 $error = lang
::p('error_invalid_id');
50 eval('$template->flush("' . $template->fetch('quicksearch') . '");');
54 // ###################################################################
56 // -------------------------------------------------------------------
58 $bug = $db->query_first("
59 SELECT bug.*, user.displayname, user.email, user.showemail
60 FROM " . TABLE_PREFIX
. "bug AS bug
61 LEFT JOIN " . TABLE_PREFIX
. "user AS user
62 ON (bug.userid = user.userid)
63 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
68 $message->error(lang
::p('error_invalid_id'));
71 if ($bug['hidden'] AND !can_perform('canviewhidden'))
73 $message->error_permission();
76 // -------------------------------------------------------------------
78 $bug['userinfo'] = construct_user_display($bug);
79 $bug['product'] = $bugsys->datastore
['product']["$bug[productid]"]['title'];
80 $bug['component'] = (($bug['componentid']) ?
$bugsys->datastore
['product']["$bug[componentid]"]['title'] : '');
81 $bug['version'] = $bugsys->datastore
['version']["$bug[versionid]"]['version'];
82 $bug['status'] = $bugsys->datastore
['status']["$bug[status]"]['status'];
83 $bug['resolution'] = $bugsys->datastore
['resolution']["$bug[resolution]"]['resolution'];
84 $bug['severity'] = $bugsys->datastore
['severity']["$bug[severity]"]['severity'];
85 $bug['priority'] = $bugsys->datastore
['priority']["$bug[priority]"]['priority'];
87 $assigninfo = $bugsys->datastore
['assignto']["$bug[assignedto]"];
88 $bug['assigninfo'] = ((is_array($assigninfo)) ?
construct_user_display($assigninfo) : '');
90 $show['editreport'] = ((((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')) ? true
: false
);
92 $duplicateof = $db->query_first("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
94 $duplicates = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE duplicateof = $bug[bugid]");
95 while ($duplicate = $db->fetch_array($duplicates))
97 $dupelist[] = "<a href=\"showreport.php?bugid=$duplicate[bugid]\" target=\"_blank\">$duplicate[summary]</a>";
99 $dupelist = implode(', ', $dupelist);
101 if ($bug['dependency'])
103 $dependencies = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
104 while ($dependency = $db->fetch_array($dependencies))
106 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" title=\"$dependency[summary]\" target=\"_blank\">$dependency[bugid]</a>";
108 $dependencies = implode(' ', $depends);
111 $favourite = (bool
)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "favourite WHERE bugid = $bug[bugid] AND userid = " . $bugsys->userinfo
['userid']);
112 $favouritetext = (($favourite) ?
'Remove from Favourites' : 'Add to Favourites');
114 // -------------------------------------------------------------------
118 $allfields = $db->query("
120 FROM " . TABLE_PREFIX
. "bugfield AS bugfield
121 LEFT JOIN " . TABLE_PREFIX
. "bugfieldpermission AS permission
122 ON (bugfield.fieldid = permission.fieldid)
123 WHERE permission.mask <> 0
124 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}"
126 while ($field = $db->fetch_array($allfields))
128 $fieldlist["$field[fieldid]"] = $field;
131 $fieldvalues = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
133 foreach ($fieldlist AS $fieldid => $field)
135 if (is_null($fieldvalues["field$fieldid"]))
137 if ($field['type'] == 'select_single')
139 if ($field['usedefault'])
141 $temp = unserialize($field['selects']);
142 $value = trim($temp[0]);
151 $value = $field['defaultvalue'];
156 $value = $fieldvalues["field$fieldid"];
159 $customfields .= "<div><strong>$field[name]:</strong> ";
161 if ($field['type'] == 'input_text' OR $field['type'] == 'select_single')
163 $customfields .= $value;
165 else if ($field['type'] == 'input_checkbox')
167 $customfields .= (($value) ?
'True' : 'False');
169 $customfields .= "</div>\n\n";
172 // -------------------------------------------------------------------
174 $words = explode(' ', $bugsys->in
['hilight']);
175 foreach ($words AS $word)
179 $word = preg_quote($bugsys->unsanitize($word));
180 $hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
184 // -------------------------------------------------------------------
186 $show['getattachments'] = ((can_perform('cangetattach') OR can_perform('caneditattach')) ? true
: false
);
187 $show['putattachments'] = ((can_perform('canputattach') OR can_perform('caneditattach')) ? true
: false
);
189 if ($show['getattachments'] OR $show['putattachments'])
191 $attachments_fetch = $db->query("
192 SELECT attachment.*, user.email, user.showemail,
194 FROM " . TABLE_PREFIX
. "attachment AS attachment
195 LEFT JOIN " . TABLE_PREFIX
. "user AS user
196 ON (attachment.userid = user.userid)
197 WHERE attachment.bugid = $bug[bugid]
198 ORDER BY attachment.dateline"
200 while ($attachment = $db->fetch_array($attachments_fetch))
202 $show['editattach'] = ((can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo
['userid'] AND can_perform('canputattach'))) ? true
: false
);
203 $attachment['date'] = $datef->format($bugsys->options
['dateformat'], $attachment['dateline']);
204 $attachment['user'] = construct_user_display($attachment, false
);
205 eval('$attachments .= "' . $template->fetch('showreport_attachment') . '";');
209 // -------------------------------------------------------------------
212 $vote = $db->query_first("SELECT *, FIND_IN_SET(" . $bugsys->userinfo
['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX
. "vote WHERE bugid = $bug[bugid]");
214 $vote['total'] = $vote['votefor'] +
$vote['voteagainst'];
215 $vote['forpercent'] = round($vote['votefor'] / $vote['total'], 3) * 100;
216 $vote['againstpercent'] = round($vote['voteagainst'] / $vote['total'], 3) * 100;
218 $show['vote'] = ((can_perform('canvote') AND !$vote['uservote']) ? true
: false
);
220 // -------------------------------------------------------------------
222 $comments_fetch = $db->query("
223 SELECT comment.*, user.email, user.showemail, user.displayname
224 FROM " . TABLE_PREFIX
. "comment AS comment
225 LEFT JOIN " . TABLE_PREFIX
. "user AS user
226 ON (comment.userid = user.userid)
227 WHERE comment.bugid = $bug[bugid]" . ((!can_perform('canviewhidden')) ?
"
228 AND !hidden" : '') . "
229 ORDER BY comment.dateline ASC"
231 while ($comment = $db->fetch_array($comments_fetch))
233 $comment['posttime'] = $datef->format($bugsys->options
['dateformat'], $comment['dateline']);
234 $comment['postby'] = construct_user_display($comment);
235 $show['editcomment'] = (((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) ? true
: false
);
237 if (is_array($hilight))
239 foreach ($hilight AS $id => $find)
242 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
243 $comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
247 eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
250 $show['newreply'] = ((can_perform('canpostcomments')) ? true
: false
);
252 if (is_array($hilight))
254 foreach ($hilight AS $id => $find)
257 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
258 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
262 eval('$template->flush("' . $template->fetch('SHOWREPORT') . '");');
264 /*=====================================================================*\
265 || ###################################################################
268 || ###################################################################
269 \*=====================================================================*/