r63: Updated initial copyright year from 2003 to 2002
[bugdar.git] / showreport.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Renapsus [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2002-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2002 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 $fetchtemplates = array(
14 'SHOWREPORT',
15 'showreport_comment'
16 );
17
18 require_once('./global.php');
19
20 if (!can_perform('canviewbugs'))
21 {
22 echo 'no permission';
23 exit;
24 }
25
26 // ###################################################################
27
28 // -------------------------------------------------------------------
29 // get the report
30 sanitize(array('bugid' => INT, 'hilight' => STR));
31
32 $bug = $DB_sql->query_first("
33 SELECT bug.*, user.displayname, user.email, user.showemail
34 FROM " . TABLE_PREFIX . "bug AS bug
35 LEFT JOIN " . TABLE_PREFIX . "user AS user
36 ON (bug.userid = user.userid)
37 WHERE bug.bugid = $vars[bugid]"
38 );
39
40 if (!is_array($bug))
41 {
42 echo 'alert: bad bug';
43 exit;
44 }
45
46 // -------------------------------------------------------------------
47 // prep display
48 $bug['userinfo'] = construct_user_display($bug);
49 $bug['product'] = $bugsys->datastore['product']["$bug[productid]"]['title'];
50 $bug['component'] = iff($bug['componentid'], $bugsys->datastore['product']["$bug[componentid]"]['title']);
51 $bug['version'] = $bugsys->datastore['version']["$bug[versionid]"]['version'];
52 $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
53 $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
54 $bug['severity'] = $bugsys->datastore['severity']["$bug[severity]"]['severity'];
55 $bug['priority'] = $bugsys->datastore['priority']["$bug[priority]"]['priority'];
56
57 $assigninfo = $bugsys->datastore['assignto']["$bug[assignedto]"];
58 $bug['assigninfo'] = iff(is_array($assigninfo), construct_user_display($assigninfo));
59
60 if (((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo'))
61 {
62 $show['editreport'] = true;
63 }
64 else
65 {
66 $show['editreport'] = false;
67 }
68
69 // -------------------------------------------------------------------
70 // hilight
71 $words = explode(' ', $vars['hilight']);
72 foreach ($words AS $word)
73 {
74 if (trim($word))
75 {
76 $word = preg_quote($word);
77 $hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
78 }
79 }
80 print_r($words);
81 print_r($hilight);
82
83 // -------------------------------------------------------------------
84 // get comments
85 $comments_fetch = $DB_sql->query("
86 SELECT comment.*, user.email, user.showemail, user.displayname
87 FROM " . TABLE_PREFIX . "comment AS comment
88 LEFT JOIN " . TABLE_PREFIX . "user AS user
89 ON (comment.userid = user.userid)
90 WHERE comment.bugid = $vars[bugid]
91 ORDER BY comment.dateline ASC"
92 );
93 while ($comment = $DB_sql->fetch_array($comments_fetch))
94 {
95 $comment['posttime'] = datelike('standard', $comment['dateline']);
96 $comment['postby'] = construct_user_display($comment);
97 if ((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers'))
98 {
99 $show['editcomment'] = true;
100 }
101 else
102 {
103 $show['editcomment'] = false;
104 }
105
106 if (is_array($hilight))
107 {
108 foreach ($hilight AS $id => $find)
109 {
110 $find = "#($find)#";
111 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
112 $comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
113 }
114 }
115
116 eval('$comments .= "' . $tpl->fetch('showreport_comment') . '";');
117 }
118
119 if (can_perform('canpostcomments'))
120 {
121 $show['newreply'] = true;
122 }
123 else
124 {
125 $show['newreply'] = false;
126 }
127
128 if (is_array($hilight))
129 {
130 foreach ($hilight AS $id => $find)
131 {
132 $find = "#($find)#";
133 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
134 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
135 }
136 }
137
138 eval('$tpl->flush("' . $tpl->fetch('SHOWREPORT') . '");');
139
140 /*=====================================================================*\
141 || ###################################################################
142 || # $HeadURL$
143 || # $Id$
144 || ###################################################################
145 \*=====================================================================*/
146 ?>