r172: Removing from our echo; exit; error reporting system to Error::throw()
[bugdar.git] / showreport.php
1 <?php
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 \*=====================================================================*/
12
13 $fetchtemplates = array(
14 'SHOWREPORT',
15 'showreport_attachment',
16 'showreport_comment'
17 );
18
19 require_once('./global.php');
20
21 if (!can_perform('canviewbugs'))
22 {
23 $error->throw_permission();
24 }
25
26 // ###################################################################
27
28 // -------------------------------------------------------------------
29 // get the report
30 $bug = $db->query_first("
31 SELECT bug.*, user.displayname, user.email, user.showemail
32 FROM " . TABLE_PREFIX . "bug AS bug
33 LEFT JOIN " . TABLE_PREFIX . "user AS user
34 ON (bug.userid = user.userid)
35 WHERE bug.bugid = " . intval($bugsys->in['bugid'])
36 );
37
38 if (!is_array($bug))
39 {
40 $error->throw('alert: bad bug');
41 }
42
43 // -------------------------------------------------------------------
44 // prep display
45 $bug['userinfo'] = construct_user_display($bug);
46 $bug['product'] = $bugsys->datastore['product']["$bug[productid]"]['title'];
47 $bug['component'] = (($bug['componentid']) ? $bugsys->datastore['product']["$bug[componentid]"]['title'] : '');
48 $bug['version'] = $bugsys->datastore['version']["$bug[versionid]"]['version'];
49 $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
50 $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
51 $bug['severity'] = $bugsys->datastore['severity']["$bug[severity]"]['severity'];
52 $bug['priority'] = $bugsys->datastore['priority']["$bug[priority]"]['priority'];
53
54 $assigninfo = $bugsys->datastore['assignto']["$bug[assignedto]"];
55 $bug['assigninfo'] = ((is_array($assigninfo)) ? construct_user_display($assigninfo) : '');
56
57 $show['editreport'] = ((((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')) ? true : false);
58
59 // -------------------------------------------------------------------
60 // hilight
61 $words = explode(' ', $bugsys->in['hilight']);
62 foreach ($words AS $word)
63 {
64 if (trim($word))
65 {
66 $word = preg_quote($bugsys->unsanitize($word));
67 $hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
68 }
69 }
70
71 // -------------------------------------------------------------------
72 // attachments
73 $show['getattachments'] = ((can_perform('cangetattach') OR can_perform('caneditattach')) ? true : false);
74 $show['putattachments'] = ((can_perform('canputattach') OR can_perform('caneditattach')) ? true : false);
75
76 if ($show['getattachments'] OR $show['putattachments'])
77 {
78 $attachments_fetch = $db->query("
79 SELECT attachment.*, user.email, user.showemail,
80 user.displayname
81 FROM " . TABLE_PREFIX . "attachment AS attachment
82 LEFT JOIN " . TABLE_PREFIX . "user AS user
83 ON (attachment.userid = user.userid)
84 WHERE attachment.bugid = $bug[bugid]
85 ORDER BY attachment.dateline"
86 );
87 while ($attachment = $db->fetch_array($attachments_fetch))
88 {
89 $show['editattach'] = ((can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo['userid'] AND can_perform('canputattach'))) ? true : false);
90 $attachment['date'] = datelike('standard', $attachment['dateline']);
91 $attachment['user'] = construct_user_display($attachment, false);
92 eval('$attachments .= "' . $template->fetch('showreport_attachment') . '";');
93 }
94 }
95
96 // -------------------------------------------------------------------
97 // get comments
98 $comments_fetch = $db->query("
99 SELECT comment.*, user.email, user.showemail, user.displayname
100 FROM " . TABLE_PREFIX . "comment AS comment
101 LEFT JOIN " . TABLE_PREFIX . "user AS user
102 ON (comment.userid = user.userid)
103 WHERE comment.bugid = $bug[bugid]
104 ORDER BY comment.dateline ASC"
105 );
106 while ($comment = $db->fetch_array($comments_fetch))
107 {
108 $comment['posttime'] = datelike('standard', $comment['dateline']);
109 $comment['postby'] = construct_user_display($comment);
110 $show['editcomment'] = (((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) ? true : false);
111
112 if (is_array($hilight))
113 {
114 foreach ($hilight AS $id => $find)
115 {
116 $find = "#($find)#";
117 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
118 $comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
119 }
120 }
121
122 eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
123 }
124
125 $show['newreply'] = ((can_perform('canpostcomments')) ? true : false);
126
127 if (is_array($hilight))
128 {
129 foreach ($hilight AS $id => $find)
130 {
131 $find = "#($find)#";
132 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
133 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
134 }
135 }
136
137 eval('$template->flush("' . $template->fetch('SHOWREPORT') . '");');
138
139 /*=====================================================================*\
140 || ###################################################################
141 || # $HeadURL$
142 || # $Id$
143 || ###################################################################
144 \*=====================================================================*/
145 ?>