r203: - Custom field `select_single` now is stored as a string instead of an integer...
[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 $message->error_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 $message->error('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 // custom fields
61 $customfields = '';
62
63 $allfields = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield");
64 while ($field = $db->fetch_array($allfields))
65 {
66 $fieldlist["$field[shortname]"] = $field;
67 }
68
69 $fieldvalues = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]");
70
71 foreach ($fieldvalues AS $shortname => $value)
72 {
73 if ($shortname == 'bugid')
74 {
75 continue;
76 }
77
78 $field =& $fieldlist["$shortname"];
79
80 $customfields .= "<div><strong>$field[name]:</strong> ";
81
82 if (is_null($value))
83 {
84 $value = $field['defaultvalue'];
85 }
86
87 if ($field['type'] == 'input_text' OR $field['type'] == 'textarea' OR $field['type'] == 'select_single')
88 {
89 $customfields .= $value;
90 }
91 else if ($field['type'] == 'input_checkbox')
92 {
93 $customfields .= (($value) ? 'True' : 'False');
94 }
95 $customfields .= "</div>\n\n";
96 }
97
98 // -------------------------------------------------------------------
99 // hilight
100 $words = explode(' ', $bugsys->in['hilight']);
101 foreach ($words AS $word)
102 {
103 if (trim($word))
104 {
105 $word = preg_quote($bugsys->unsanitize($word));
106 $hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
107 }
108 }
109
110 // -------------------------------------------------------------------
111 // attachments
112 $show['getattachments'] = ((can_perform('cangetattach') OR can_perform('caneditattach')) ? true : false);
113 $show['putattachments'] = ((can_perform('canputattach') OR can_perform('caneditattach')) ? true : false);
114
115 if ($show['getattachments'] OR $show['putattachments'])
116 {
117 $attachments_fetch = $db->query("
118 SELECT attachment.*, user.email, user.showemail,
119 user.displayname
120 FROM " . TABLE_PREFIX . "attachment AS attachment
121 LEFT JOIN " . TABLE_PREFIX . "user AS user
122 ON (attachment.userid = user.userid)
123 WHERE attachment.bugid = $bug[bugid]
124 ORDER BY attachment.dateline"
125 );
126 while ($attachment = $db->fetch_array($attachments_fetch))
127 {
128 $show['editattach'] = ((can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo['userid'] AND can_perform('canputattach'))) ? true : false);
129 $attachment['date'] = datelike('standard', $attachment['dateline']);
130 $attachment['user'] = construct_user_display($attachment, false);
131 eval('$attachments .= "' . $template->fetch('showreport_attachment') . '";');
132 }
133 }
134
135 // -------------------------------------------------------------------
136 // get comments
137 $comments_fetch = $db->query("
138 SELECT comment.*, user.email, user.showemail, user.displayname
139 FROM " . TABLE_PREFIX . "comment AS comment
140 LEFT JOIN " . TABLE_PREFIX . "user AS user
141 ON (comment.userid = user.userid)
142 WHERE comment.bugid = $bug[bugid]
143 ORDER BY comment.dateline ASC"
144 );
145 while ($comment = $db->fetch_array($comments_fetch))
146 {
147 $comment['posttime'] = datelike('standard', $comment['dateline']);
148 $comment['postby'] = construct_user_display($comment);
149 $show['editcomment'] = (((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) ? true : false);
150
151 if (is_array($hilight))
152 {
153 foreach ($hilight AS $id => $find)
154 {
155 $find = "#($find)#";
156 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
157 $comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
158 }
159 }
160
161 eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
162 }
163
164 $show['newreply'] = ((can_perform('canpostcomments')) ? true : false);
165
166 if (is_array($hilight))
167 {
168 foreach ($hilight AS $id => $find)
169 {
170 $find = "#($find)#";
171 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
172 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
173 }
174 }
175
176 eval('$template->flush("' . $template->fetch('SHOWREPORT') . '");');
177
178 /*=====================================================================*\
179 || ###################################################################
180 || # $HeadURL$
181 || # $Id$
182 || ###################################################################
183 \*=====================================================================*/
184 ?>