Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / print_bug_page.php
blob7dd2e3a8c1321d6d053fbcf8bf1beac370c52ef7
1 <?php
2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # MantisBT is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * @package MantisBT
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
23 * @uses core.php
24 * @uses access_api.php
25 * @uses bug_api.php
26 * @uses category_api.php
27 * @uses columns_api.php
28 * @uses compress_api.php
29 * @uses config_api.php
30 * @uses constant_inc.php
31 * @uses custom_field_api.php
32 * @uses date_api.php
33 * @uses file_api.php
34 * @uses gpc_api.php
35 * @uses helper_api.php
36 * @uses history_api.php
37 * @uses html_api.php
38 * @uses lang_api.php
39 * @uses last_visited_api.php
40 * @uses prepare_api.php
41 * @uses print_api.php
42 * @uses project_api.php
43 * @uses relationship_api.php
44 * @uses string_api.php
45 * @uses tag_api.php
46 * @uses utility_api.php
47 * @uses version_api.php
50 require_once( 'core.php' );
51 require_api( 'access_api.php' );
52 require_api( 'bug_api.php' );
53 require_api( 'category_api.php' );
54 require_api( 'columns_api.php' );
55 require_api( 'compress_api.php' );
56 require_api( 'config_api.php' );
57 require_api( 'constant_inc.php' );
58 require_api( 'custom_field_api.php' );
59 require_api( 'date_api.php' );
60 require_api( 'file_api.php' );
61 require_api( 'gpc_api.php' );
62 require_api( 'helper_api.php' );
63 require_api( 'history_api.php' );
64 require_api( 'html_api.php' );
65 require_api( 'lang_api.php' );
66 require_api( 'last_visited_api.php' );
67 require_api( 'prepare_api.php' );
68 require_api( 'print_api.php' );
69 require_api( 'project_api.php' );
70 require_api( 'relationship_api.php' );
71 require_api( 'string_api.php' );
72 require_api( 'tag_api.php' );
73 require_api( 'utility_api.php' );
74 require_api( 'version_api.php' );
76 $f_bug_id = gpc_get_int( 'bug_id' );
78 bug_ensure_exists( $f_bug_id );
80 $tpl_bug = bug_get( $f_bug_id, true );
82 $t_selected_project = helper_get_current_project();
83 if ( $tpl_bug->project_id != $t_selected_project ) {
84 # in case the current project is not the same project of the bug we are viewing...
85 # ... override the current project. This to avoid problems with categories and handlers lists etc.
86 $g_project_override = $tpl_bug->project_id;
89 access_ensure_bug_level( VIEWER, $f_bug_id );
91 $t_fields = config_get( 'bug_print_page_fields' );
92 $t_fields = columns_filter_disabled( $t_fields );
94 compress_enable();
96 $t_history = history_get_events_array( $f_bug_id );
98 $tpl_show_id = in_array( BUG_FIELD_ID, $t_fields );
99 $tpl_show_project = in_array( BUG_FIELD_PROJECT, $t_fields );
100 $tpl_show_category = in_array( BUG_FIELD_CATEGORY, $t_fields );
101 $tpl_show_date_submitted = in_array( BUG_FIELD_DATE_SUBMITTED, $t_fields );
102 $tpl_show_last_updated = in_array( BUG_FIELD_LAST_UPDATED, $t_fields );
103 $tpl_show_view_state = in_array( BUG_FIELD_VIEW_STATE, $t_fields );
104 $tpl_show_reporter = in_array( BUG_FIELD_REPORTER, $t_fields );
105 $tpl_show_handler = in_array( BUG_FIELD_HANDLER, $t_fields ) && access_has_bug_level( config_get( 'view_handler_threshold' ), $f_bug_id );
106 $tpl_show_due_date = in_array( BUG_FIELD_DUE_DATE, $t_fields ) && access_has_bug_level( config_get( 'due_date_view_threshold' ), $f_bug_id );
107 $tpl_show_priority = in_array( BUG_FIELD_PRIORITY, $t_fields );
108 $tpl_show_severity = in_array( BUG_FIELD_SEVERITY, $t_fields );
109 $tpl_show_reproducibility = in_array( BUG_FIELD_REPRODUCIBILITY, $t_fields );
110 $tpl_show_platform = in_array( BUG_FIELD_PLATFORM, $t_fields );
111 $tpl_show_os = in_array( BUG_FIELD_OS, $t_fields );
112 $tpl_show_os_version = in_array( BUG_FIELD_OS_VERSION, $t_fields );
113 $tpl_show_status = in_array( BUG_FIELD_STATUS, $t_fields );
114 $tpl_show_resolution = in_array( BUG_FIELD_RESOLUTION, $t_fields );
115 $tpl_show_projection = in_array( BUG_FIELD_PROJECTION, $t_fields );
116 $tpl_show_eta = in_array( BUG_FIELD_ETA, $t_fields );
117 $tpl_show_versions = version_should_show_product_version( $tpl_bug->project_id );
118 $tpl_show_product_version = $tpl_show_versions && in_array( BUG_FIELD_PRODUCT_VERSION, $t_fields );
119 $tpl_show_product_build = $tpl_show_versions && in_array( BUG_FIELD_PRODUCT_BUILD, $t_fields ) && config_get( 'enable_product_build' );
120 $tpl_show_fixed_in_version = $tpl_show_versions && in_array( BUG_FIELD_FIXED_IN_VERSION, $t_fields );
121 $tpl_show_target_version = $tpl_show_versions && in_array( BUG_FIELD_TARGET_VERSION, $t_fields ) && access_has_bug_level( config_get( 'roadmap_view_threshold' ), $f_bug_id );
122 $tpl_show_summary = in_array( BUG_FIELD_SUMMARY, $t_fields );
123 $tpl_show_description = in_array( BUG_FIELD_DESCRIPTION, $t_fields );
124 $tpl_show_steps_to_reproduce = in_array( BUG_FIELD_STEPS_TO_REPRODUCE, $t_fields );
125 $tpl_show_additional_information = in_array( BUG_FIELD_ADDITIONAL_INFO, $t_fields );
126 $tpl_show_tags = in_array( BUG_FIELD_TAGS, $t_fields );
127 $tpl_show_attachments = in_array( BUG_FIELD_ATTACHMENTS, $t_fields );
129 $tpl_window_title = string_display_line( config_get( 'window_title' ) );
130 $tpl_project_name = $tpl_show_project ? string_display_line( project_get_name( $tpl_bug->project_id ) ) : '';
131 $tpl_formatted_bug_id = $tpl_show_id ? bug_format_id( $f_bug_id ) : '';
132 $tpl_category_name = $tpl_show_category ? string_display_line( category_full_name( $tpl_bug->category_id ) ) : '';
133 $tpl_severity = string_display_line( get_enum_element( 'severity', $tpl_bug->severity ) );
134 $tpl_reproducibility = string_display_line( get_enum_element( 'reproducibility', $tpl_bug->reproducibility ) );
135 $tpl_date_submitted = $tpl_show_date_submitted ? string_display_line( date( config_get( 'normal_date_format' ), $tpl_bug->date_submitted ) ) : '';
136 $tpl_last_updated = $tpl_show_last_updated ? string_display_line( date( config_get( 'normal_date_format' ), $tpl_bug->last_updated ) ) : '';
137 $tpl_platform = string_display_line( $tpl_bug->platform );
138 $tpl_os = string_display_line( $tpl_bug->os );
139 $tpl_os_version = string_display_line( $tpl_bug->os_build );
140 $tpl_is = string_display_line( $tpl_bug->os );
141 $tpl_status = string_display_line( get_enum_element( 'status', $tpl_bug->status ) );
142 $tpl_priority = string_display_line( get_enum_element( 'priority', $tpl_bug->priority ) );
143 $tpl_resolution = string_display_line( get_enum_element( 'resolution', $tpl_bug->resolution ) );
144 $tpl_product_build = string_display_line( $tpl_bug->build );
145 $tpl_projection = string_display_line( get_enum_element( 'projection', $tpl_bug->projection ) );
146 $tpl_eta = string_display_line ( get_enum_element( 'eta', $tpl_bug->eta ) );
147 $tpl_summary = string_display_line_links( bug_format_summary( $f_bug_id, SUMMARY_FIELD ) );
148 $tpl_description = string_display_links( $tpl_bug->description );
149 $tpl_steps_to_reproduce = string_display_links( $tpl_bug->steps_to_reproduce );
150 $tpl_additional_information = string_display_links( $tpl_bug->additional_information );
151 $tpl_view_state = $tpl_show_view_state ? get_enum_element( 'view_state', $tpl_bug->view_state ) : '';
153 if ( $tpl_show_due_date ) {
154 if ( !date_is_null( $tpl_bug->due_date ) ) {
155 $tpl_due_date = date( config_get( 'normal_date_format' ), $tpl_bug->due_date );
156 } else {
157 $tpl_due_date = '';
161 $tpl_product_version =
162 $tpl_show_product_version ?
163 string_display_line( prepare_version_string( $tpl_bug->project_id, version_get_id( $tpl_bug->version, $tpl_bug->project_id ) ) ) : '';
165 $tpl_target_version =
166 $tpl_show_target_version ?
167 string_display_line( prepare_version_string( $tpl_bug->project_id, version_get_id( $tpl_bug->target_version, $tpl_bug->project_id ) ) ) : '';
169 $tpl_fixed_in_version =
170 $tpl_show_fixed_in_version ?
171 string_display_line( prepare_version_string( $tpl_bug->project_id, version_get_id( $tpl_bug->fixed_in_version, $tpl_bug->project_id ) ) ) : '';
173 html_page_top1( bug_format_summary( $f_bug_id, SUMMARY_CAPTION ) );
174 html_head_end();
175 html_body_begin();
177 echo '<br />';
179 echo '<table class="width100" cellspacing="1">';
180 echo '<tr>';
181 echo '<td class="form-title" colspan="6">';
182 echo '<div class="center">', $tpl_window_title;
184 if ( !is_blank( $tpl_project_name ) ) {
185 echo ' - ' . $tpl_project_name;
188 echo '</div></td>';
189 echo '</tr>';
191 echo '<tr>';
192 echo '<td class="form-title" colspan="6">', lang_get( 'bug_view_title' ), '</td>';
193 echo '</tr>';
195 echo '<tr><td class="print-spacer" colspan="6"><hr size="1" /></td></tr>';
197 if ( $tpl_show_id || $tpl_show_project || $tpl_show_category || $tpl_show_view_state ||
198 $tpl_show_date_submitted || $tpl_show_last_updated ) {
199 echo '<tr class="print-category">';
200 echo '<td class="print" width="16%">', $tpl_show_id ? lang_get( 'id' ) : '', '</td>';
201 echo '<td class="print" width="16%">', $tpl_show_project ? lang_get( 'email_project' ) : '', '</td>';
202 echo '<td class="print" width="16%">', $tpl_show_category ? lang_get( 'category' ) : '', '</td>';
203 echo '<td class="print" width="16%">', $tpl_show_view_state ? lang_get( 'view_status' ) : '', '</td>';
204 echo '<td class="print" width="16%">', $tpl_show_date_submitted ? lang_get( 'date_submitted' ) : '', '</td>';
205 echo '<td class="print" width="16%">', $tpl_show_last_updated ? lang_get( 'last_update' ) : '', '</td>';
206 echo '</tr>';
208 echo '<tr class="print">';
209 echo '<td class="print">', $tpl_formatted_bug_id, '</td>';
210 echo '<td class="print">', $tpl_project_name, '</td>';
211 echo '<td class="print">', $tpl_category_name, '</td>';
212 echo '<td class="print">', $tpl_view_state, '</td>';
213 echo '<td class="print">', $tpl_date_submitted, '</td>';
214 echo '<td class="print">', $tpl_last_updated, '</td>';
215 echo '</tr>';
217 echo '<tr><td class="print-spacer" colspan="6"><hr size="1" /></td></tr>';
221 # Reporter
224 if ( $tpl_show_reporter ) {
225 echo '<tr class="print">';
226 echo '<td class="print-category">', lang_get( 'reporter' ), '</td>';
227 echo '<td class="print">';
228 print_user_with_subject( $tpl_bug->reporter_id, $f_bug_id );
229 echo '</td>';
230 echo '<td class="print" colspan="4">&nbsp;</td>';
231 echo '</tr>';
235 # Handler, Due Date
238 if ( $tpl_show_handler || $tpl_show_due_date ) {
239 $t_spacer = 2;
241 echo '<tr class="print">';
243 if ( $tpl_show_handler ) {
244 echo '<td class="print-category">', lang_get( 'assigned_to' ), '</td>';
245 echo '<td class="print">';
246 print_user_with_subject( $tpl_bug->handler_id, $f_bug_id );
247 echo '</td>';
248 } else {
249 $t_spacer += 2;
252 if ( $tpl_show_due_date ) {
253 echo '<td class="print-category">', lang_get( 'due_date' ), '</td>';
254 echo '<td class="print">', $tpl_due_date, '</td>';
255 } else {
256 $t_spacer += 2;
259 echo '<td class="print" colspan="', $t_spacer, '">&nbsp;</td>';
260 echo '</tr>';
264 # Priority, Severity, Reproducibility
267 if ( $tpl_show_priority || $tpl_show_severity || $tpl_show_reproducibility ) {
268 echo '<tr class="print">';
270 $t_spacer = 0;
272 if ( $tpl_show_priority ) {
273 echo '<td class="print-category">', lang_get( 'priority' ), '</td>';
274 echo '<td class="print">', $tpl_priority, '</td>';
275 } else {
276 $t_spacer += 2;
279 if ( $tpl_show_severity ) {
280 echo '<td class="print-category">', lang_get( 'severity' ), '</td>';
281 echo '<td class="print">', $tpl_severity, '</td>';
282 } else {
283 $t_spacer += 2;
286 if ( $tpl_show_reproducibility ) {
287 echo '<td class="print-category">', lang_get( 'reproducibility' ), '</td>';
288 echo '<td class="print">', $tpl_reproducibility, '</td>';
289 } else {
290 $t_spacer += 2;
293 if ( $t_spacer > 0 ) {
294 echo '<td class="print" colspan="', $t_spacer, '">&nbsp;</td>';
297 echo '</tr>';
301 # Status, Resolution
304 if ( $tpl_show_status || $tpl_show_resolution ) {
305 echo '<tr class="print">';
307 $t_spacer = 2;
309 if ( $tpl_show_status ) {
310 echo '<td class="print-category">', lang_get( 'status' ), '</td>';
311 echo '<td class="print">', $tpl_status, '</td>';
312 } else {
313 $t_spacer += 2;
316 if ( $tpl_show_resolution ) {
317 echo '<td class="print-category">', lang_get( 'resolution' ), '</td>';
318 echo '<td class="print">', $tpl_resolution, '</td>';
319 } else {
320 $t_spacer += 2;
323 echo '<td class="print" colspan="', $t_spacer, '">&nbsp;</td>';
324 echo '</tr>';
328 # Projection, ETA
331 if ( $tpl_show_projection || $tpl_show_eta ) {
332 $t_spacer = 2;
334 echo '<tr class="print">';
336 if ( $tpl_show_projection ) {
337 echo '<td class="print-category">', lang_get( 'projection' ), '</td>';
338 echo '<td class="print">', $tpl_projection, '</td>';
339 } else {
340 $t_spacer += 2;
343 if ( $tpl_show_eta ) {
344 echo '<td class="print-category">', lang_get( 'eta' ), '</td>';
345 echo '<td class="print">', $tpl_eta, '</td>';
346 } else {
347 $t_spacer += 2;
350 echo '<td class="print" colspan="', $t_spacer, '">&nbsp;</td>';
351 echo '</tr>';
355 # Platform, OS, OS Version
358 if ( $tpl_show_platform || $tpl_show_os || $tpl_show_os_version ) {
359 echo '<tr class="print">';
361 $t_spacer = 0;
363 if ( $tpl_show_platform ) {
364 echo '<td class="print-category">', lang_get( 'platform' ), '</td>';
365 echo '<td class="print">', $tpl_platform, '</td>';
366 } else {
367 $t_spacer += 2;
370 if ( $tpl_show_os ) {
371 echo '<td class="print-category">', lang_get( 'os' ), '</td>';
372 echo '<td class="print">', $tpl_os, '</td>';
373 } else {
374 $t_spacer += 2;
377 if ( $tpl_show_os_version ) {
378 echo '<td class="print-category">', lang_get( 'os_version' ), '</td>';
379 echo '<td class="print">', $tpl_os_version, '</td>';
380 } else {
381 $t_spacer += 2;
384 if ( $t_spacer > 0 ) {
385 echo '<td class="print" colspan="', $t_spacer, '">&nbsp;</td>';
388 echo '</tr>';
392 # Product Version, Product Build
395 if ( $tpl_show_product_version || $tpl_show_product_build ) {
396 echo '<tr class="print">';
398 $t_spacer = 2;
400 if ( $tpl_show_product_version ) {
401 echo '<td class="print-category">', lang_get( 'product_version' ), '</td>';
402 echo '<td class="print">', $tpl_product_version, '</td>';
403 } else {
404 $t_spacer += 2;
407 if ( $tpl_show_product_build ) {
408 echo '<td class="print-category">', lang_get( 'product_build' ), '</td>';
409 echo '<td class="print">', $tpl_product_build, '</td>';
410 } else {
411 $t_spacer += 2;
414 echo '<td class="print" colspan="', $t_spacer, '">&nbsp;</td>';
415 echo '</tr>';
419 # Target Version, Fixed in Version
422 if ( $tpl_show_target_version || $tpl_show_fixed_in_version ) {
423 echo '<tr>';
425 $t_spacer = 2;
427 if ( $tpl_show_target_version ) {
428 echo '<td class="print-category">', lang_get( 'target_version' ), '</td>';
429 echo '<td class="print">', $tpl_target_version, '</td>';
430 } else {
431 $t_spacer += 2;
434 if ( $tpl_show_fixed_in_version ) {
435 echo '<td class="print-category">', lang_get( 'fixed_in_version' ), '</td>';
436 echo '<td class="print">', $tpl_fixed_in_version, '</td>';
437 } else {
438 $t_spacer += 2;
441 echo '<td class="print" colspan="', $t_spacer, '">&nbsp;</td>';
442 echo '</tr>';
446 # Custom Fields
449 $t_related_custom_field_ids = custom_field_get_linked_ids( $tpl_bug->project_id );
450 foreach( $t_related_custom_field_ids as $t_id ) {
451 $t_def = custom_field_get_definition( $t_id );
453 echo '<tr class="print">';
454 echo '<td class="print-category">', string_display_line( lang_get_defaulted( $t_def['name'] ) ), '</td>';
455 echo '<td class="print" colspan="4">';
456 print_custom_field_value( $t_def, $t_id, $f_bug_id );
457 echo '</td>';
458 echo '</tr>';
459 } // foreach
461 echo '<tr><td class="print-spacer" colspan="6"><hr size="1" /></td></tr>';
463 if ( $tpl_show_summary ) {
464 echo '<tr class="print">';
465 echo '<td class="print-category">', lang_get( 'summary' ), '</td>';
466 echo '<td class="print" colspan="5">', $tpl_summary, '</td>';
467 echo '</tr>';
470 if ( $tpl_show_description ) {
471 echo '<tr class="print">';
472 echo '<td class="print-category">', lang_get( 'description' ), '</td>';
473 echo '<td class="print" colspan="5">', $tpl_description, '</td>';
474 echo '</tr>';
477 if ( $tpl_show_steps_to_reproduce ) {
478 echo '<tr class="print">';
479 echo '<td class="print-category">', lang_get( 'steps_to_reproduce' ), '</td>';
480 echo '<td class="print" colspan="5">', $tpl_steps_to_reproduce, '</td>';
481 echo '</tr>';
484 if ( $tpl_show_additional_information ) {
485 echo '<tr class="print">';
486 echo '<td class="print-category">', lang_get( 'additional_information' ), '</td>';
487 echo '<td class="print" colspan="5">', $tpl_additional_information, '</td>';
488 echo '</tr>';
491 # Tagging
492 if ( $tpl_show_tags ) {
493 echo "<tr class=\"print\">";
494 echo '<td class="print-category">', lang_get( 'tags' ), '</td>';
495 echo '<td class="print" colspan="5">';
496 tag_display_attached( $f_bug_id );
497 echo '</td></tr>';
500 echo "<tr class=\"print\">";
501 echo "<td class=\"print-category\">" . lang_get( 'bug_relationships' ) . "</td>";
502 echo "<td class=\"print\" colspan=\"5\">" . relationship_get_summary_html_preview( $f_bug_id ) . "</td></tr>";
504 if ( $tpl_show_attachments ) {
505 echo '<tr class="print">';
506 echo '<td class="print-category">', lang_get( 'attached_files' ), '</td>';
507 echo '<td class="print" colspan="5">';
509 $t_attachments = file_get_visible_attachments( $f_bug_id );
510 $t_first_attachment = true;
511 $t_path = config_get_global( 'path' );
513 foreach ( $t_attachments as $t_attachment ) {
514 if ( $t_first_attachment ) {
515 $t_first_attachment = false;
516 } else {
517 echo '<br />';
520 $c_filename = string_display_line( $t_attachment['display_name'] );
521 $c_download_url = $t_path . htmlspecialchars( $t_attachment['download_url'] );
522 $c_filesize = number_format( $t_attachment['size'] );
523 $c_date_added = date( config_get( 'normal_date_format' ), $t_attachment['date_added'] );
524 if ( isset( $t_attachment['icon'] ) ) {
525 echo '<img src="', $t_attachment['icon']['url'], '" alt="', $t_attachment['icon']['alt'], '" />&nbsp;';
528 echo "$c_filename ($c_filesize) <span class=\"italic\">$c_date_added</span><br />$c_download_url";
530 if ( $t_attachment['preview'] && $t_attachment['type'] == 'image' ) {
531 echo '<br /><img src="', $t_attachment['download_url'], '" alt="', $t_attachment['alt'], '" border="0" /><br />';
535 echo '</td></tr>';
538 echo '<tr><td class="print-spacer" colspan="6"><hr size="1" /></td></tr>';
540 # ISSUE HISTORY
541 echo '<tr><td class="form-title">', lang_get( 'bug_history' ), '</td></tr>';
543 echo '<tr class="print-category">';
544 echo '<td class="row-category-history">', lang_get( 'date_modified' ), '</td>';
545 echo '<td class="row-category-history">', lang_get( 'username' ), '</td>';
546 echo '<td class="row-category-history">', lang_get( 'field' ), '</td>';
547 echo '<td class="row-category-history">', lang_get( 'change' ), '</td>';
548 echo '</tr>';
550 foreach ( $t_history as $t_item ) {
551 echo '<tr class="print">';
552 echo '<td class="print">', $t_item['date'], '</td>';
553 echo '<td class="print">';
554 print_user( $t_item['userid'] );
555 echo '</td>';
556 echo '<td class="print">', string_display( $t_item['note'] ), '</td>';
557 echo '<td class="print">', string_display_line_links( $t_item['change'] ), '</td>';
558 echo '</tr>';
561 echo '</table>';
563 include( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'print_bugnote_inc.php' ) ;
565 last_visited_issue( $f_bug_id );