2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©2002-2007 Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 $fetchtemplates = array(
24 'showreport_attachment',
27 'bugfield_static_text'
30 define('SVN', '$Id$');
32 $focus['showreport'] = 'focus';
34 require_once('./global.php');
35 require_once('./includes/functions_product.php');
37 $bugid = $input->inputClean('bugid', TYPE_UINT
);
39 // ###################################################################
41 if (empty($bugid) OR $_REQUEST['do'] == 'quicksearch')
45 if ($db->queryFirst("SELECT bugid FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bugid"))
47 header("Location: showreport.php?bugid=$bugid");
52 $error = L_INVALID_ID
;
56 eval('$template->flush("' . $template->fetch('quicksearch') . '");');
60 // ###################################################################
62 // -------------------------------------------------------------------
64 $bug = $db->queryFirst("
65 SELECT bug.*, user.email, user.displayname, user.showemail
66 FROM " . TABLE_PREFIX
. "bug AS bug
67 LEFT JOIN " . TABLE_PREFIX
. "user AS user
68 ON (bug.userid = user.userid)
69 WHERE bug.bugid = $bugid"
74 $message->error(L_INVALID_ID
);
77 if (!check_bug_permissions($bug))
79 $message->errorPermission();
82 $show['edit'] = ((can_perform('caneditown', $bug['product']) AND bugdar
::$userinfo['userid'] == $bug['userid'] AND $bug['userid'] != 0) OR (can_perform('caneditother', $bug['product']) AND bugdar
::$userinfo['userid'] != $bug['userid']));
83 $show['delete'] = can_perform('candeletedata', $bug['product']);
85 // ###################################################################
89 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
91 $show['changestatus'] = (can_perform('canchangestatus', $bug['product']) ? true
: false
);
92 if (can_perform('canchangestatus', $bug['product']))
94 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
95 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
96 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
100 $bug['status'] = bugdar
::$datastore['status']["$bug[status]"]['status'];
101 $bug['resolution'] = bugdar
::$datastore['resolution']["$bug[resolution]"]['resolution'];
102 $bug['severity'] = bugdar
::$datastore['severity']["$bug[severity]"]['severity'];
103 $bug['priority'] = bugdar
::$datastore['priority']["$bug[priority]"]['priority'];
106 $show['assign'] = (can_perform('canassign', $bug['product']));
107 if (can_perform('canassign', $bug['product']) && is_array(bugdar
::$datastore['assignto']))
109 foreach (bugdar
::$datastore['assignto'] as $dev)
111 $tpl = new BSTemplate('selectoption');
113 'value' => $dev['userid'],
114 'label' => construct_user_display($dev, false
),
115 'selected' => ($dev['userid'] == $bug['assignedto'])
117 $select['dev'] .= $tpl->evaluate()->getTemplate();
121 $productSelect = ConstructProductSelect('canviewbugs', "$bug[product],$bug[component],$bug[version]");
123 if ($bug['duplicateof'])
125 $duplicate = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
128 if ($bug['dependency'])
131 $dependencies = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
132 foreach ($dependencies as $dependency)
134 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" title=\"$dependency[summary]\">$dependency[bugid]</a>";
136 $dependencies = implode(' ', $depends);
139 $select['automations'] = '';
140 $show['automations'] = false
;
141 if (is_array(bugdar
::$datastore['automation']))
143 foreach (bugdar
::$datastore['automation'] as $action)
145 $tpl = new BSTemplate('selectoption');
147 'label' => $action['name'],
148 'value' => $action['actionid'],
151 $select['automation'] .= $tpl->evaluate()->getTemplate();
152 $show['automations'] = true
;
154 if ($show['automations'])
156 $tpl = new BSTemplate('selectoption');
162 $select['automation'] = $tpl->evaluate()->getTemplate() . $select['automation'];
167 // ###################################################################
171 // -------------------------------------------------------------------
173 $bug['status'] = bugdar
::$datastore['status']["$bug[status]"]['status'];
174 $bug['resolution'] = bugdar
::$datastore['resolution']["$bug[resolution]"]['resolution'];
175 $bug['severity'] = bugdar
::$datastore['severity']["$bug[severity]"]['severity'];
176 $bug['priority'] = bugdar
::$datastore['priority']["$bug[priority]"]['priority'];
178 $assigninfo = bugdar
::$datastore['assignto']["$bug[assignedto]"];
179 $bug['assigninfo'] = ((is_array($assigninfo)) ?
construct_user_display($assigninfo) : '');
181 $duplicateof = $db->queryFirst("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
184 $duplicates = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE duplicateof = $bug[bugid]");
185 foreach ($duplicates as $duplicate)
187 $dupelist[] = "<a href=\"showreport.php?bugid=$duplicate[bugid]\" target=\"_blank\">$duplicate[summary]</a>";
189 $dupelist = implode(', ', $dupelist);
191 if ($bug['dependency'])
194 $dependencies = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
195 foreach ($dependencies as $dependency)
197 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" title=\"$dependency[summary]\" target=\"_blank\">$dependency[bugid]</a>";
199 $dependencies = implode(' ', $depends);
203 // ###################################################################
204 // global display items
206 $show['subscribe'] = can_perform('cansubscribe', $bug['product']);
208 $favorite = (bool
)$db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "favorite WHERE bugid = $bug[bugid] AND userid = " . bugdar
::$userinfo['userid']);
209 $favoritetext = ($favorite ?
T('Remove from Favorites') : T('Add to Favorites'));
211 $bug['userinfo'] = construct_user_display($bug);
212 $bug['datetime'] = $datef->format(bugdar
::$options['dateformat'], $bug['dateline']);
213 $bug['productid'] = $bug['product'];
214 $bug['product'] = bugdar
::$datastore['product']["$bug[product]"]['title'];
215 $bug['componentid'] = $bug['component'];
216 $bug['component'] = ($bug['component'] ? bugdar
::$datastore['product']["$bug[component]"]['title'] : '');
217 $bug['versionid'] = $bug['version'];
218 $bug['version'] = bugdar
::$datastore['version']["$bug[version]"]['version'];
220 // ###################################################################
221 // custom field output
223 $fields = construct_custom_fields($bug);
225 foreach ($fields AS $field)
229 $customfields['left'] .= $field;
233 $customfields['right'] .= $field;
238 // ###################################################################
241 // -------------------------------------------------------------------
243 $words = explode(' ', $input->in
['hilight']);
244 foreach ($words AS $word)
248 $word = preg_quote($input->unsanitize($word));
249 $hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
253 // -------------------------------------------------------------------
255 $show['getattachments'] = ((can_perform('cangetattach', $bug['productid']) OR can_perform('caneditattach', $bug['productid'])) ? true
: false
);
256 $show['putattachments'] = ((can_perform('canputattach', $bug['productid']) OR can_perform('caneditattach', $bug['productid'])) ? true
: false
);
257 $show['attachments'] = ($show['getattachments'] OR $show['putattachments']) ? true
: false
;
259 if ($show['getattachments'] OR $show['putattachments'])
261 $attachments_fetch = $db->query("
262 SELECT attachment.attachmentid, attachment.filename,
263 attachment.description, attachment.dateline,
264 attachment.userid, attachment.obsolete, user.email,
265 user.showemail, user.displayname
266 FROM " . TABLE_PREFIX
. "attachment AS attachment
267 LEFT JOIN " . TABLE_PREFIX
. "user AS user
268 ON (attachment.userid = user.userid)
269 WHERE attachment.bugid = $bug[bugid]
270 ORDER BY attachment.dateline"
274 foreach ($attachments_fetch as $attachment)
277 $show['editattach'] = ((can_perform('caneditattach', $bug['productid']) OR ($attachment['userid'] == bugdar
::$userinfo['userid'] AND can_perform('canputattach', $bug['productid']))) ? true
: false
);
278 $attachment['date'] = $datef->format(bugdar
::$options['dateformat'], $attachment['dateline']);
279 $attachment['user'] = construct_user_display($attachment, false
);
280 eval('$attachments .= "' . $template->fetch('showreport_attachment') . '";');
283 $show['attachments'] = (!$show['putattachments'] AND !$attaches) ? false
: true
;
286 // -------------------------------------------------------------------
289 $vote = $db->queryFirst("SELECT *, FIND_IN_SET(" . bugdar
::$userinfo['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX
. "vote WHERE bugid = $bug[bugid]");
291 $vote['total'] = $vote['votefor'] +
$vote['voteagainst'];
292 if ($vote['total'] != 0)
294 $vote['forpercent'] = round($vote['votefor'] / $vote['total'], 3) * 100;
295 $vote['againstpercent'] = round($vote['voteagainst'] / $vote['total'], 3) * 100;
299 $vote['forpercent'] = 0;
300 $vote['againstpercent'] = 0;
303 $show['vote'] = ((can_perform('canvote', $bug['productid']) AND !$vote['uservote']) ? true
: false
);
305 // -------------------------------------------------------------------
307 $comments_fetch = $db->query("
308 SELECT comment.*, user.email, user.showemail, user.displayname
309 FROM " . TABLE_PREFIX
. "comment AS comment
310 LEFT JOIN " . TABLE_PREFIX
. "user AS user
311 ON (comment.userid = user.userid)
312 WHERE comment.bugid = $bug[bugid]" . (!can_perform('canviewhidden', $bug['productid']) ?
"
313 AND !hidden" : '') . "
314 ORDER BY comment.dateline ASC"
316 foreach ($comments_fetch as $comment)
318 $comment['posttime'] = $datef->format(bugdar
::$options['dateformat'], $comment['dateline']);
319 $comment['postby'] = construct_user_display($comment);
320 $show['editcomment'] = ((can_perform('caneditownreply', $bug['productid']) AND bugdar
::$userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['productid']) AND bugdar
::$userinfo['userid'] != $comment['userid']));
322 BSApp
::debug('can edit own replies: ' . (int)(can_perform('caneditownreply', $bug['productid']) AND bugdar
::$userinfo['userid'] == $comment['userid']));
323 BSApp
::debug('can edit other replies:' . (int)(can_perform('caneditotherreply', $bug['productid']) AND bugdar
::$userinfo['userid'] != $comment['userid']));
324 BSApp
::debug('$show[editcomment]: ' . $show['editcomment']);
326 if (is_array($hilight))
328 foreach ($hilight AS $id => $find)
330 $find = "#($find)#i";
331 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
332 $comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
336 $tpl = new BSTemplate('showreport_comment');
337 $tpl->vars
= array('comment' => $comment);
338 $comments .= $tpl->evaluate()->getTemplate();
341 $show['newreply'] = (can_perform('canpostcomments', $bug['productid']) ? true
: false
);
343 $bug['summary_title'] = $bug['summary'];
344 if (is_array($hilight) AND !$show['edit'])
346 foreach ($hilight AS $id => $find)
348 $find = "#($find)#i";
349 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
350 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
354 $tpl = new BSTemplate('showreport');
357 'comments' => $comments,
360 'favoritetext' => $favoritetext,
361 'customfields' => $customfields
363 $tpl->evaluate()->flush();
365 /*=====================================================================*\
366 || ###################################################################
369 || ###################################################################
370 \*=====================================================================*/