]>
src.bluestatic.org Git - bugdar.git/blob - showreport.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2004-2008 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'
31 $focus [ 'showreport' ] = 'focus' ;
33 require_once ( './global.php' );
34 require_once ( './includes/functions_product.php' );
36 $bugid = $input- > inputClean ( 'bugid' , TYPE_UINT
);
38 // ###################################################################
40 if ( empty ( $bugid ) OR $_REQUEST [ 'do' ] == 'quicksearch' )
44 if ( $db- > queryFirst ( "SELECT bugid FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bugid" ))
46 header(" Location
: showreport
. php
? bugid
= $bugid" );
51 $error = L_INVALID_ID
;
55 $tpl = new BSTemplate ( 'quicksearch' );
56 $tpl- > vars
= array ( 'error' => $error );
57 $tpl- > evaluate ()-> flush ();
61 // ###################################################################
63 // -------------------------------------------------------------------
65 $bug = $db- > queryFirst ( "
66 SELECT bug.*, user.email, user.displayname, user.showemail
67 FROM " . TABLE_PREFIX
. "bug AS bug
68 LEFT JOIN " . TABLE_PREFIX
. "user AS user
69 ON (bug.userid = user.userid)
70 WHERE bug.bugid = $bugid"
75 $message- >error(L_INVALID_ID);
78 if (!check_bug_permissions( $bug ))
80 $message- >errorPermission();
83 $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']));
84 $show ['delete'] = can_perform('candeletedata', $bug ['product']);
86 // ###################################################################
90 $select ['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug ['severity']);
92 $show ['changestatus'] = (can_perform('canchangestatus', $bug ['product']) ? true : false);
93 if (can_perform('canchangestatus', $bug ['product']))
95 $select ['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug ['priority']);
96 $select ['status'] = construct_datastore_select('status', 'status', 'statusid', $bug ['status']);
97 $select ['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug ['resolution']);
101 $bug ['status'] = bugdar:: $datastore ['status'][" $bug [ status
] "]['status'];
102 $bug ['resolution'] = bugdar:: $datastore ['resolution'][" $bug [ resolution
] "]['resolution'];
103 $bug ['severity'] = bugdar:: $datastore ['severity'][" $bug [ severity
] "]['severity'];
104 $bug ['priority'] = bugdar:: $datastore ['priority'][" $bug [ priority
] "]['priority'];
107 $show ['assign'] = (can_perform('canassign', $bug ['product']));
108 if (can_perform('canassign', $bug ['product']) && is_array(bugdar:: $datastore ['assignto']))
110 foreach (bugdar:: $datastore ['assignto'] as $dev )
112 $tpl = new BSTemplate('selectoption');
114 'value' => $dev ['userid'],
115 'label' => construct_user_display( $dev , false),
116 'selected' => ( $dev ['userid'] == $bug ['assignedto'])
118 $select ['dev'] .= $tpl- >evaluate()->getTemplate();
122 $productSelect = construct_product_select('canviewbugs', " $bug [ product
], $bug [ component
], $bug [ version
] ");
124 if ( $bug ['duplicateof'])
126 $duplicate = $db- >queryFirst(" SELECT
* FROM
" . TABLE_PREFIX . " bug WHERE bugid
= $bug [ duplicateof
] ");
129 if ( $bug ['dependency'])
132 $dependencies = $db- >query(" SELECT
* FROM
" . TABLE_PREFIX . " bug WHERE bugid
IN ( $bug [ dependency
]) ");
133 foreach ( $dependencies as $dependency )
135 $depends [] = " < a href
=\" showreport
. php
? bugid
= $dependency [ bugid
]\" title
=\" $dependency [ summary
]\"> $dependency [ bugid
]</ a
> ";
137 $dependencies = implode(' ', $depends );
140 $select ['automations'] = '';
141 $show ['automations'] = false;
142 if (is_array(bugdar:: $datastore ['automation']))
144 foreach (bugdar:: $datastore ['automation'] as $action )
146 $tpl = new BSTemplate('selectoption');
148 'label' => $action ['name'],
149 'value' => $action ['actionid'],
152 $select ['automation'] .= $tpl- >evaluate()->getTemplate();
153 $show ['automations'] = true;
155 if ( $show ['automations'])
157 $tpl = new BSTemplate('selectoption');
163 $select ['automation'] = $tpl- >evaluate()->getTemplate() . $select ['automation'];
168 // ###################################################################
172 // -------------------------------------------------------------------
174 $bug ['status'] = bugdar:: $datastore ['status'][" $bug [ status
] "]['status'];
175 $bug ['resolution'] = bugdar:: $datastore ['resolution'][" $bug [ resolution
] "]['resolution'];
176 $bug ['severity'] = bugdar:: $datastore ['severity'][" $bug [ severity
] "]['severity'];
177 $bug ['priority'] = bugdar:: $datastore ['priority'][" $bug [ priority
] "]['priority'];
179 $assigninfo = bugdar:: $datastore ['assignto'][" $bug [ assignedto
] "];
180 $bug ['assigninfo'] = ((is_array( $assigninfo )) ? construct_user_display( $assigninfo ) : '');
182 $duplicateof = $db- >queryFirst(" SELECT bugid
, summary FROM
" . TABLE_PREFIX . " bug WHERE bugid
= $bug [ duplicateof
] ");
185 $duplicates = $db- >query(" SELECT bugid
, summary FROM
" . TABLE_PREFIX . " bug WHERE duplicateof
= $bug [ bugid
] ");
186 foreach ( $duplicates as $duplicate )
188 $dupelist [] = " < a href
=\" showreport
. php
? bugid
= $duplicate [ bugid
]\" target
=\" _blank\"
> $duplicate [ summary
]</ a
> ";
190 $dupelist = implode(', ', $dupelist );
192 if ( $bug ['dependency'])
195 $dependencies = $db- >query(" SELECT bugid
, summary FROM
" . TABLE_PREFIX . " bug WHERE bugid
IN ( $bug [ dependency
]) ");
196 foreach ( $dependencies as $dependency )
198 $depends [] = " < a href
=\" showreport
. php
? bugid
= $dependency [ bugid
]\" title
=\" $dependency [ summary
]\" target
=\" _blank\"
> $dependency [ bugid
]</ a
> ";
200 $dependencies = implode(' ', $depends );
204 // ###################################################################
205 // global display items
207 $show ['subscribe'] = can_perform('cansubscribe', $bug ['product']);
209 $favorite = (bool) $db- >queryFirst(" SELECT
* FROM
" . TABLE_PREFIX . " favorite WHERE bugid
= $bug [ bugid
] AND userid
= " . bugdar:: $userinfo ['userid']);
210 $favoritetext = ( $favorite ? T('Remove from Favorites') : T('Add to Favorites'));
212 $bug ['userinfo'] = construct_user_display( $bug );
213 $bug ['datetime'] = $datef- >format(bugdar:: $options ['dateformat'], $bug ['dateline']);
214 $bug ['productid'] = $bug ['product'];
215 $bug ['product'] = bugdar:: $datastore ['product'][" $bug [ product
] "]['title'];
216 $bug ['componentid'] = $bug ['component'];
217 $bug ['component'] = ( $bug ['component'] ? bugdar:: $datastore ['product'][" $bug [ component
] "]['title'] : '');
218 $bug ['versionid'] = $bug ['version'];
219 $bug ['version'] = bugdar:: $datastore ['version'][" $bug [ version
] "]['version'];
221 // ###################################################################
222 // custom field output
224 $fields = construct_custom_fields( $bug );
226 foreach ( $fields AS $field )
230 $customfields ['left'] .= $field ;
234 $customfields ['right'] .= $field ;
239 // ###################################################################
242 // -------------------------------------------------------------------
244 $words = explode(' ', $input- >in['hilight']);
245 foreach ( $words AS $word )
249 $word = preg_quote( $input- >unsanitize( $word ));
250 $hilight [] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word ));
254 // -------------------------------------------------------------------
256 $show ['getattachments'] = (can_perform('cangetattach', $bug ['productid']) || can_perform('caneditattach', $bug ['productid']));
257 $show ['putattachments'] = (can_perform('canputattach', $bug ['productid']) || can_perform('caneditattach', $bug ['productid']));
258 $show ['attachments'] = ( $show ['getattachments'] || $show ['putattachments']);
260 if ( $show ['getattachments'] || $show ['putattachments'])
262 $attachments_fetch = $db- >query("
263 SELECT attachment
. attachmentid
, attachment
. filename
,
264 attachment
. description
, attachment
. dateline
,
265 attachment
. userid
, attachment
. obsolete
, user
. email
,
266 user
. showemail
, user
. displayname
267 FROM
" . TABLE_PREFIX . " attachment
AS attachment
268 LEFT JOIN
" . TABLE_PREFIX . " user
AS user
269 ON ( attachment
. userid
= user
. userid
)
270 WHERE attachment
. bugid
= $bug [ bugid
]
271 ORDER BY attachment
. dateline
"
275 foreach ( $attachments_fetch as $attachment )
278 $show ['editattach'] = (can_perform('caneditattach', $bug ['productid']) || ( $attachment ['userid'] == bugdar:: $userinfo ['userid'] && can_perform('canputattach', $bug ['productid'])));
279 $attachment ['date'] = $datef- >format(bugdar:: $options ['dateformat'], $attachment ['dateline']);
280 $attachment ['user'] = construct_user_display( $attachment , false);
282 $tpl = new BSTemplate('showreport_attachment');
284 'attachment' => $attachment
286 $attachments .= $tpl- >evaluate()->getTemplate();
289 $show ['attachments'] = ( $show ['putattachments'] && $attaches );
292 // -------------------------------------------------------------------
295 $vote = $db- >queryFirst(" SELECT
*, FIND_IN_SET ( " . bugdar:: $userinfo ['userid'] . " , userids
) AS uservote FROM
" . TABLE_PREFIX . " vote WHERE bugid
= $bug [ bugid
] ");
297 $vote ['total'] = $vote ['votefor'] + $vote ['voteagainst'];
298 if ( $vote ['total'] != 0)
300 $vote ['forpercent'] = round( $vote ['votefor'] / $vote ['total'], 3) * 100;
301 $vote ['againstpercent'] = round( $vote ['voteagainst'] / $vote ['total'], 3) * 100;
305 $vote ['forpercent'] = 0;
306 $vote ['againstpercent'] = 0;
309 $show ['vote'] = ((can_perform('canvote', $bug ['productid']) AND ! $vote ['uservote']) ? true : false);
311 // -------------------------------------------------------------------
313 $comments_fetch = $db- >query("
314 SELECT comment
.*, user
. email
, user
. showemail
, user
. displayname
315 FROM
" . TABLE_PREFIX . " comment
AS comment
316 LEFT JOIN
" . TABLE_PREFIX . " user
AS user
317 ON ( comment
. userid
= user
. userid
)
318 WHERE comment
. bugid
= $bug [ bugid
] " . (!can_perform('canviewhidden', $bug ['productid']) ? "
319 AND ! hidden
" : '') . "
320 ORDER BY comment
. dateline ASC
"
322 foreach ( $comments_fetch as $comment )
324 $comment ['posttime'] = $datef- >format(bugdar:: $options ['dateformat'], $comment ['dateline']);
325 $comment ['postby'] = construct_user_display( $comment );
326 $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']));
328 BSApp::debug('can edit own replies: ' . (int)(can_perform('caneditownreply', $bug ['productid']) AND bugdar:: $userinfo ['userid'] == $comment ['userid']));
329 BSApp::debug('can edit other replies:' . (int)(can_perform('caneditotherreply', $bug ['productid']) AND bugdar:: $userinfo ['userid'] != $comment ['userid']));
330 BSApp::debug(' $show [editcomment]: ' . $show ['editcomment']);
332 if (is_array( $hilight ))
334 foreach ( $hilight AS $id => $find )
336 $find = " #($find)#i";
337 $replace = "<span style= \" background-color: yellow; font-weight: bold; color: red; \" > \\ 1</span>" ;
338 $comment [ 'comment_parsed' ] = preg_replace ( $find , $replace , $comment [ 'comment_parsed' ]);
342 $tpl = new BSTemplate ( 'showreport_comment' );
343 $tpl- > vars
= array ( 'comment' => $comment );
344 $comments .= $tpl- > evaluate ()-> getTemplate ();
347 $show [ 'newreply' ] = ( can_perform ( 'canpostcomments' , $bug [ 'productid' ]) ? true : false );
349 $bug [ 'summary_title' ] = $bug [ 'summary' ];
350 if ( is_array ( $hilight ) AND ! $show [ 'edit' ])
352 foreach ( $hilight AS $id => $find )
354 $find = "#( $find )#i" ;
355 $replace = "<span style= \" background-color: yellow; font-weight: bold; color: red; \" > \\ 1</span>" ;
356 $bug [ 'summary' ] = preg_replace ( $find , $replace , $bug [ 'summary' ]);
360 $tpl = new BSTemplate ( 'showreport' );
363 'comments' => $comments ,
366 'favoritetext' => $favoritetext ,
367 'customfields' => $customfields ,
368 'attachments' => $attachments ,
369 'productSelect' => $productSelect
371 $tpl- > evaluate ()-> flush ();