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