]>
src.bluestatic.org Git - bugdar.git/blob - showreport.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©2002-2007 Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 $fetchtemplates = array (
24 'showreport_attachment' ,
27 'bugfield_static_text'
30 define ( 'SVN' , ' $Id $' );
32 $focus [' showreport
'] = ' focus
';
34 require_once(' ./ global . php
');
35 require_once(' ./ includes
/ functions_product
. php
');
37 $bugid = $input- >inputClean(' bugid
', TYPE_UINT);
39 // ###################################################################
41 if (empty( $bugid ) OR $_REQUEST [' do '] == ' quicksearch
')
45 if ( $db- >queryFirst("SELECT bugid FROM " . TABLE_PREFIX . "bug WHERE bugid = $bugid" ))
47 header("Location: showreport.php?bugid= $bugid" );
52 $error = L_INVALID_ID;
56 $tpl = new BSTemplate(' quicksearch
');
57 $tpl- >vars = array(' error
' => $error );
58 $tpl- >evaluate()->flush();
62 // ###################################################################
64 // -------------------------------------------------------------------
66 $bug = $db- >queryFirst("
67 SELECT bug.*, user.email, user.displayname, user.showemail
68 FROM " . TABLE_PREFIX . "bug AS bug
69 LEFT JOIN " . TABLE_PREFIX . "user AS user
70 ON (bug.userid = user.userid)
71 WHERE bug.bugid = $bugid"
76 $message- >error(L_INVALID_ID);
79 if (!check_bug_permissions( $bug ))
81 $message- >errorPermission();
84 $show [' edit
'] = ((can_perform(' caneditown
', $bug [' product
']) AND bugdar:: $userinfo [' userid
'] == $bug [' userid
'] AND $bug [' userid
'] != 0) OR (can_perform(' caneditother
', $bug [' product
']) AND bugdar:: $userinfo [' userid
'] != $bug [' userid
']));
85 $show [' delete
'] = can_perform(' candeletedata
', $bug [' product
']);
87 // ###################################################################
91 $select [' severity
'] = construct_datastore_select(' severity
', ' severity
', ' severityid
', $bug [' severity
']);
93 $show [' changestatus
'] = (can_perform(' canchangestatus
', $bug [' product
']) ? true : false);
94 if (can_perform(' canchangestatus
', $bug [' product
']))
96 $select [' priority
'] = construct_datastore_select(' priority
', ' priority
', ' priorityid
', $bug [' priority
']);
97 $select [' status
'] = construct_datastore_select(' status
', ' status
', ' statusid
', $bug [' status
']);
98 $select [' resolution
'] = construct_datastore_select(' resolution
', ' resolution
', ' resolutionid
', $bug [' resolution
']);
102 $bug [' status
'] = bugdar:: $datastore [' status
'][" $bug [status]"][' status
'];
103 $bug [' resolution
'] = bugdar:: $datastore [' resolution
'][" $bug [resolution]"][' resolution
'];
104 $bug [' severity
'] = bugdar:: $datastore [' severity
'][" $bug [severity]"][' severity
'];
105 $bug [' priority
'] = bugdar:: $datastore [' priority
'][" $bug [priority]"][' priority
'];
108 $show [' assign
'] = (can_perform(' canassign
', $bug [' product
']));
109 if (can_perform(' canassign
', $bug [' product
']) && is_array(bugdar:: $datastore [' assignto
']))
111 foreach (bugdar:: $datastore [' assignto
'] as $dev )
113 $tpl = new BSTemplate(' selectoption
');
115 ' value
' => $dev [' userid
'],
116 ' label
' => construct_user_display( $dev , false),
117 ' selected
' => ( $dev [' userid
'] == $bug [' assignedto
'])
119 $select [' dev
'] .= $tpl- >evaluate()->getTemplate();
123 $productSelect = ConstructProductSelect(' canviewbugs
', " $bug [product], $bug [component], $bug [version]");
125 if ( $bug [' duplicateof
'])
127 $duplicate = $db- >queryFirst("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug [duplicateof]");
130 if ( $bug [' dependency
'])
133 $dependencies = $db- >query("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid IN ( $bug [dependency])");
134 foreach ( $dependencies as $dependency )
136 $depends [] = "<a href= \" showreport.php?bugid= $dependency [bugid] \" title= \" $dependency [summary] \" > $dependency [bugid]</a>";
138 $dependencies = implode(' ', $depends );
141 $select [' automations
'] = ' ';
142 $show [' automations
'] = false;
143 if (is_array(bugdar:: $datastore [' automation
']))
145 foreach (bugdar:: $datastore [' automation
'] as $action )
147 $tpl = new BSTemplate(' selectoption
');
149 ' label
' => $action [' name
'],
150 ' value
' => $action [' actionid
'],
153 $select [' automation
'] .= $tpl- >evaluate()->getTemplate();
154 $show [' automations
'] = true;
156 if ( $show [' automations
'])
158 $tpl = new BSTemplate(' selectoption
');
164 $select [' automation
'] = $tpl- >evaluate()->getTemplate() . $select [' automation
'];
169 // ###################################################################
173 // -------------------------------------------------------------------
175 $bug [' status
'] = bugdar:: $datastore [' status
'][" $bug [status]"][' status
'];
176 $bug [' resolution
'] = bugdar:: $datastore [' resolution
'][" $bug [resolution]"][' resolution
'];
177 $bug [' severity
'] = bugdar:: $datastore [' severity
'][" $bug [severity]"][' severity
'];
178 $bug [' priority
'] = bugdar:: $datastore [' priority
'][" $bug [priority]"][' priority
'];
180 $assigninfo = bugdar:: $datastore [' assignto
'][" $bug [assignedto]"];
181 $bug [' assigninfo
'] = ((is_array( $assigninfo )) ? construct_user_display( $assigninfo ) : ' ');
183 $duplicateof = $db- >queryFirst("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug [duplicateof]");
186 $duplicates = $db- >query("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE duplicateof = $bug [bugid]");
187 foreach ( $duplicates as $duplicate )
189 $dupelist [] = "<a href= \" showreport.php?bugid= $duplicate [bugid] \" target= \" _blank \" > $duplicate [summary]</a>";
191 $dupelist = implode(' , ', $dupelist );
193 if ( $bug [' dependency
'])
196 $dependencies = $db- >query("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE bugid IN ( $bug [dependency])");
197 foreach ( $dependencies as $dependency )
199 $depends [] = "<a href= \" showreport.php?bugid= $dependency [bugid] \" title= \" $dependency [summary] \" target= \" _blank \" > $dependency [bugid]</a>";
201 $dependencies = implode(' ', $depends );
205 // ###################################################################
206 // global display items
208 $show [' subscribe
'] = can_perform(' cansubscribe
', $bug [' product
']);
210 $favorite = (bool) $db- >queryFirst("SELECT * FROM " . TABLE_PREFIX . "favorite WHERE bugid = $bug [bugid] AND userid = " . bugdar:: $userinfo [' userid
']);
211 $favoritetext = ( $favorite ? T(' Remove from Favorites
') : T(' Add to Favorites
'));
213 $bug [' userinfo
'] = construct_user_display( $bug );
214 $bug [' datetime
'] = $datef- >format(bugdar:: $options [' dateformat
'], $bug [' dateline
']);
215 $bug [' productid
'] = $bug [' product
'];
216 $bug [' product
'] = bugdar:: $datastore [' product
'][" $bug [product]"][' title
'];
217 $bug [' componentid
'] = $bug [' component
'];
218 $bug [' component
'] = ( $bug [' component
'] ? bugdar:: $datastore [' product
'][" $bug [component]"][' title
'] : ' ');
219 $bug [' versionid
'] = $bug [' version
'];
220 $bug [' version
'] = bugdar:: $datastore [' version
'][" $bug [version]"][' version
'];
222 // ###################################################################
223 // custom field output
225 $fields = construct_custom_fields( $bug );
227 foreach ( $fields AS $field )
231 $customfields [' left
'] .= $field ;
235 $customfields [' right
'] .= $field ;
240 // ###################################################################
243 // -------------------------------------------------------------------
245 $words = explode(' ', $input- >in[' hilight
']);
246 foreach ( $words AS $word )
250 $word = preg_quote( $input- >unsanitize( $word ));
251 $hilight [] = $temp = trim(preg_replace(' #[ ^
0 - 9 a
- zA
- Z_
] #', '', $word));
255 // -------------------------------------------------------------------
257 $show [ 'getattachments' ] = ( can_perform ( 'cangetattach' , $bug [ 'productid' ]) || can_perform ( 'caneditattach' , $bug [ 'productid' ]));
258 $show [ 'putattachments' ] = ( can_perform ( 'canputattach' , $bug [ 'productid' ]) || can_perform ( 'caneditattach' , $bug [ 'productid' ]));
259 $show [ 'attachments' ] = ( $show [ 'getattachments' ] || $show [ 'putattachments' ]);
261 if ( $show [ 'getattachments' ] || $show [ 'putattachments' ])
263 $attachments_fetch = $db- > query ( "
264 SELECT attachment.attachmentid, attachment.filename,
265 attachment.description, attachment.dateline,
266 attachment.userid, attachment.obsolete, user.email,
267 user.showemail, user.displayname
268 FROM " . TABLE_PREFIX
. "attachment AS attachment
269 LEFT JOIN " . TABLE_PREFIX
. "user AS user
270 ON (attachment.userid = user.userid)
271 WHERE attachment.bugid = $bug [bugid]
272 ORDER BY attachment.dateline"
276 foreach ( $attachments_fetch as $attachment )
279 $show [ 'editattach' ] = ( can_perform ( 'caneditattach' , $bug [ 'productid' ]) || ( $attachment [ 'userid' ] == bugdar
:: $userinfo [ 'userid' ] && can_perform ( 'canputattach' , $bug [ 'productid' ])));
280 $attachment [ 'date' ] = $datef- > format ( bugdar
:: $options [ 'dateformat' ], $attachment [ 'dateline' ]);
281 $attachment [ 'user' ] = construct_user_display ( $attachment , false );
283 $tpl = new BSTemplate ( 'showreport_attachment' );
285 'attachment' => $attachment
287 $attachments .= $tpl- > evaluate ()-> getTemplate ();
290 $show [ 'attachments' ] = ( $show [ 'putattachments' ] && $attaches );
293 // -------------------------------------------------------------------
296 $vote = $db- > queryFirst ( "SELECT *, FIND_IN_SET(" . bugdar
:: $userinfo [ 'userid' ] . ", userids) AS uservote FROM " . TABLE_PREFIX
. "vote WHERE bugid = $bug [bugid]" );
298 $vote [ 'total' ] = $vote [ 'votefor' ] +
$vote [ 'voteagainst' ];
299 if ( $vote [ 'total' ] != 0 )
301 $vote [ 'forpercent' ] = round ( $vote [ 'votefor' ] / $vote [ 'total' ], 3 ) * 100 ;
302 $vote [ 'againstpercent' ] = round ( $vote [ 'voteagainst' ] / $vote [ 'total' ], 3 ) * 100 ;
306 $vote [ 'forpercent' ] = 0 ;
307 $vote [ 'againstpercent' ] = 0 ;
310 $show [ 'vote' ] = (( can_perform ( 'canvote' , $bug [ 'productid' ]) AND ! $vote [ 'uservote' ]) ? true : false );
312 // -------------------------------------------------------------------
314 $comments_fetch = $db- > query ( "
315 SELECT comment.*, user.email, user.showemail, user.displayname
316 FROM " . TABLE_PREFIX
. "comment AS comment
317 LEFT JOIN " . TABLE_PREFIX
. "user AS user
318 ON (comment.userid = user.userid)
319 WHERE comment.bugid = $bug [bugid]" . (! can_perform ( 'canviewhidden' , $bug [ 'productid' ]) ? "
320 AND !hidden" : '' ) . "
321 ORDER BY comment.dateline ASC"
323 foreach ( $comments_fetch as $comment )
325 $comment [ 'posttime' ] = $datef- > format ( bugdar
:: $options [ 'dateformat' ], $comment [ 'dateline' ]);
326 $comment [ 'postby' ] = construct_user_display ( $comment );
327 $show [ 'editcomment' ] = (( can_perform ( 'caneditownreply' , $bug [ 'productid' ]) AND bugdar
:: $userinfo [ 'userid' ] == $comment [ 'userid' ]) OR ( can_perform ( 'caneditotherreply' , $bug [ 'productid' ]) AND bugdar
:: $userinfo [ 'userid' ] != $comment [ 'userid' ]));
329 BSApp
:: debug ( 'can edit own replies: ' . ( int )( can_perform ( 'caneditownreply' , $bug [ 'productid' ]) AND bugdar
:: $userinfo [ 'userid' ] == $comment [ 'userid' ]));
330 BSApp
:: debug ( 'can edit other replies:' . ( int )( can_perform ( 'caneditotherreply' , $bug [ 'productid' ]) AND bugdar
:: $userinfo [ 'userid' ] != $comment [ 'userid' ]));
331 BSApp
:: debug ( ' $show [editcomment]: ' . $show [ 'editcomment' ]);
333 if ( is_array ( $hilight ))
335 foreach ( $hilight AS $id => $find )
337 $find = "#( $find )#i" ;
338 $replace = "<span style= \" background-color: yellow; font-weight: bold; color: red; \" > \\ 1</span>" ;
339 $comment [ 'comment_parsed' ] = preg_replace ( $find , $replace , $comment [ 'comment_parsed' ]);
343 $tpl = new BSTemplate ( 'showreport_comment' );
344 $tpl- > vars
= array ( 'comment' => $comment );
345 $comments .= $tpl- > evaluate ()-> getTemplate ();
348 $show [ 'newreply' ] = ( can_perform ( 'canpostcomments' , $bug [ 'productid' ]) ? true : false );
350 $bug [ 'summary_title' ] = $bug [ 'summary' ];
351 if ( is_array ( $hilight ) AND ! $show [ 'edit' ])
353 foreach ( $hilight AS $id => $find )
355 $find = "#( $find )#i" ;
356 $replace = "<span style= \" background-color: yellow; font-weight: bold; color: red; \" > \\ 1</span>" ;
357 $bug [ 'summary' ] = preg_replace ( $find , $replace , $bug [ 'summary' ]);
361 $tpl = new BSTemplate ( 'showreport' );
364 'comments' => $comments ,
367 'favoritetext' => $favoritetext ,
368 'customfields' => $customfields ,
369 'attachments' => $attachments
371 $tpl- > evaluate ()-> flush ();
373 /*=====================================================================*\
374 || ###################################################################
377 || ###################################################################
378 \*=====================================================================*/