r94: Updated hilighting to have better support for when a HTML tag is entered.
[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_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 $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 echo 'alert: bad bug';
41 exit;
42 }
43
44 // -------------------------------------------------------------------
45 // prep display
46 $bug['userinfo'] = construct_user_display($bug);
47 $bug['product'] = $bugsys->datastore['product']["$bug[productid]"]['title'];
48 $bug['component'] = (($bug['componentid']) ? $bugsys->datastore['product']["$bug[componentid]"]['title'] : '');
49 $bug['version'] = $bugsys->datastore['version']["$bug[versionid]"]['version'];
50 $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
51 $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
52 $bug['severity'] = $bugsys->datastore['severity']["$bug[severity]"]['severity'];
53 $bug['priority'] = $bugsys->datastore['priority']["$bug[priority]"]['priority'];
54
55 $assigninfo = $bugsys->datastore['assignto']["$bug[assignedto]"];
56 $bug['assigninfo'] = ((is_array($assigninfo)) ? construct_user_display($assigninfo) : '');
57
58 if (((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo'))
59 {
60 $show['editreport'] = true;
61 }
62 else
63 {
64 $show['editreport'] = false;
65 }
66
67 // -------------------------------------------------------------------
68 // hilight
69 $words = explode(' ', $bugsys->in['hilight']);
70 foreach ($words AS $word)
71 {
72 if (trim($word))
73 {
74 $word = preg_quote($bugsys->unsanitize($word));
75 $hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
76 }
77 }
78 print_r($words);
79 print_r($hilight);
80
81 // -------------------------------------------------------------------
82 // get comments
83 $comments_fetch = $db->query("
84 SELECT comment.*, user.email, user.showemail, user.displayname
85 FROM " . TABLE_PREFIX . "comment AS comment
86 LEFT JOIN " . TABLE_PREFIX . "user AS user
87 ON (comment.userid = user.userid)
88 WHERE comment.bugid = $bug[bugid]
89 ORDER BY comment.dateline ASC"
90 );
91 while ($comment = $db->fetch_array($comments_fetch))
92 {
93 $comment['posttime'] = datelike('standard', $comment['dateline']);
94 $comment['postby'] = construct_user_display($comment);
95 if ((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers'))
96 {
97 $show['editcomment'] = true;
98 }
99 else
100 {
101 $show['editcomment'] = false;
102 }
103
104 if (is_array($hilight))
105 {
106 foreach ($hilight AS $id => $find)
107 {
108 $find = "#($find)#";
109 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
110 $comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
111 }
112 }
113
114 eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
115 }
116
117 if (can_perform('canpostcomments'))
118 {
119 $show['newreply'] = true;
120 }
121 else
122 {
123 $show['newreply'] = false;
124 }
125
126 if (is_array($hilight))
127 {
128 foreach ($hilight AS $id => $find)
129 {
130 $find = "#($find)#";
131 $replace = "<span style=\"background-color: yellow; font-weight: bold; color: red;\">\\1</span>";
132 $bug['summary'] = preg_replace($find, $replace, $bug['summary']);
133 }
134 }
135
136 eval('$template->flush("' . $template->fetch('SHOWREPORT') . '");');
137
138 /*=====================================================================*\
139 || ###################################################################
140 || # $HeadURL$
141 || # $Id$
142 || ###################################################################
143 \*=====================================================================*/
144 ?>