SOAP API: do not try to unserialize an invalid filter
[mantis.git] / print_bug_page.php
blobfc2d0e449847561c175f026c6d8f0bec346ed91f
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 - 2011 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 /**
51 * MantisBT Core API's
53 require_once( 'core.php' );
54 require_api( 'access_api.php' );
55 require_api( 'bug_api.php' );
56 require_api( 'category_api.php' );
57 require_api( 'columns_api.php' );
58 require_api( 'compress_api.php' );
59 require_api( 'config_api.php' );
60 require_api( 'constant_inc.php' );
61 require_api( 'custom_field_api.php' );
62 require_api( 'date_api.php' );
63 require_api( 'file_api.php' );
64 require_api( 'gpc_api.php' );
65 require_api( 'helper_api.php' );
66 require_api( 'history_api.php' );
67 require_api( 'html_api.php' );
68 require_api( 'lang_api.php' );
69 require_api( 'last_visited_api.php' );
70 require_api( 'prepare_api.php' );
71 require_api( 'print_api.php' );
72 require_api( 'project_api.php' );
73 require_api( 'relationship_api.php' );
74 require_api( 'string_api.php' );
75 require_api( 'tag_api.php' );
76 require_api( 'utility_api.php' );
77 require_api( 'version_api.php' );
79 $f_bug_id = gpc_get_int( 'bug_id' );
81 bug_ensure_exists( $f_bug_id );
83 $tpl_bug = bug_get( $f_bug_id, true );
85 $t_selected_project = helper_get_current_project();
86 if ( $tpl_bug->project_id != $t_selected_project ) {
87 # in case the current project is not the same project of the bug we are viewing...
88 # ... override the current project. This to avoid problems with categories and handlers lists etc.
89 $g_project_override = $tpl_bug->project_id;
92 access_ensure_bug_level( VIEWER, $f_bug_id );
94 $t_fields = config_get( 'bug_print_page_fields' );
95 $t_fields = columns_filter_disabled( $t_fields );
97 compress_enable();
99 $tpl_show_id = in_array( 'id', $t_fields );
100 $tpl_show_project = in_array( 'project', $t_fields );
101 $tpl_show_category = in_array( 'category_id', $t_fields );
102 $tpl_show_date_submitted = in_array( 'date_submitted', $t_fields );
103 $tpl_show_last_updated = in_array( 'last_updated', $t_fields );
104 $tpl_show_view_state = in_array( 'view_state', $t_fields );
105 $tpl_show_reporter = in_array( 'reporter', $t_fields );
106 $tpl_show_handler = in_array( 'handler', $t_fields ) && access_has_bug_level( config_get( 'view_handler_threshold' ), $f_bug_id );
107 $tpl_show_due_date = in_array( 'due_date', $t_fields ) && access_has_bug_level( config_get( 'due_date_view_threshold' ), $f_bug_id );
108 $tpl_show_priority = in_array( 'priority', $t_fields );
109 $tpl_show_severity = in_array( 'severity', $t_fields );
110 $tpl_show_reproducibility = in_array( 'reproducibility', $t_fields );
111 $tpl_show_platform = in_array( 'platform', $t_fields );
112 $tpl_show_os = in_array( 'os', $t_fields );
113 $tpl_show_os_version = in_array( 'os_version', $t_fields );
114 $tpl_show_status = in_array( 'status', $t_fields );
115 $tpl_show_resolution = in_array( 'resolution', $t_fields );
116 $tpl_show_projection = in_array( 'projection', $t_fields );
117 $tpl_show_eta = in_array( 'eta', $t_fields );
118 $tpl_show_versions = version_should_show_product_version( $tpl_bug->project_id );
119 $tpl_show_product_version = $tpl_show_versions && in_array( 'product_version', $t_fields );
120 $tpl_show_product_build = $tpl_show_versions && in_array( 'product_build', $t_fields ) && config_get( 'enable_product_build' );
121 $tpl_show_fixed_in_version = $tpl_show_versions && in_array( 'fixed_in_version', $t_fields );
122 $tpl_show_target_version = $tpl_show_versions && in_array( 'target_version', $t_fields ) && access_has_bug_level( config_get( 'roadmap_view_threshold' ), $f_bug_id );
123 $tpl_show_summary = in_array( 'summary', $t_fields );
124 $tpl_show_description = in_array( 'description', $t_fields );
125 $tpl_show_steps_to_reproduce = in_array( 'steps_to_reproduce', $t_fields );
126 $tpl_show_additional_information = in_array( 'additional_info', $t_fields );
127 $tpl_show_tags = in_array( 'tags', $t_fields );
128 $tpl_show_attachments = in_array( 'attachments', $t_fields );
129 $tpl_show_history = access_has_bug_level( config_get( 'view_history_threshold' ), $f_bug_id );
131 $tpl_window_title = string_display_line( config_get( 'window_title' ) );
132 $tpl_project_name = $tpl_show_project ? string_display_line( project_get_name( $tpl_bug->project_id ) ) : '';
133 $tpl_formatted_bug_id = $tpl_show_id ? bug_format_id( $f_bug_id ) : '';
134 $tpl_category_name = $tpl_show_category ? string_display_line( category_full_name( $tpl_bug->category_id ) ) : '';
135 $tpl_severity = string_display_line( get_enum_element( 'severity', $tpl_bug->severity ) );
136 $tpl_reproducibility = string_display_line( get_enum_element( 'reproducibility', $tpl_bug->reproducibility ) );
137 $tpl_date_submitted = $tpl_show_date_submitted ? string_display_line( date( config_get( 'normal_date_format' ), $tpl_bug->date_submitted ) ) : '';
138 $tpl_last_updated = $tpl_show_last_updated ? string_display_line( date( config_get( 'normal_date_format' ), $tpl_bug->last_updated ) ) : '';
139 $tpl_platform = string_display_line( $tpl_bug->platform );
140 $tpl_os = string_display_line( $tpl_bug->os );
141 $tpl_os_version = string_display_line( $tpl_bug->os_build );
142 $tpl_is = string_display_line( $tpl_bug->os );
143 $tpl_status = string_display_line( get_enum_element( 'status', $tpl_bug->status ) );
144 $tpl_priority = string_display_line( get_enum_element( 'priority', $tpl_bug->priority ) );
145 $tpl_resolution = string_display_line( get_enum_element( 'resolution', $tpl_bug->resolution ) );
146 $tpl_product_build = string_display_line( $tpl_bug->build );
147 $tpl_projection = string_display_line( get_enum_element( 'projection', $tpl_bug->projection ) );
148 $tpl_eta = string_display_line ( get_enum_element( 'eta', $tpl_bug->eta ) );
149 $tpl_summary = string_display_line_links( bug_format_summary( $f_bug_id, SUMMARY_FIELD ) );
150 $tpl_description = string_display_links( $tpl_bug->description );
151 $tpl_steps_to_reproduce = string_display_links( $tpl_bug->steps_to_reproduce );
152 $tpl_additional_information = string_display_links( $tpl_bug->additional_information );
153 $tpl_view_state = $tpl_show_view_state ? get_enum_element( 'view_state', $tpl_bug->view_state ) : '';
155 if ( $tpl_show_due_date ) {
156 if ( !date_is_null( $tpl_bug->due_date ) ) {
157 $tpl_due_date = date( config_get( 'normal_date_format' ), $tpl_bug->due_date );
158 } else {
159 $tpl_due_date = '';
163 $tpl_product_version =
164 $tpl_show_product_version ?
165 string_display_line( prepare_version_string( $tpl_bug->project_id, version_get_id( $tpl_bug->version, $tpl_bug->project_id ) ) ) : '';
167 $tpl_target_version =
168 $tpl_show_target_version ?
169 string_display_line( prepare_version_string( $tpl_bug->project_id, version_get_id( $tpl_bug->target_version, $tpl_bug->project_id ) ) ) : '';
171 $tpl_fixed_in_version =
172 $tpl_show_fixed_in_version ?
173 string_display_line( prepare_version_string( $tpl_bug->project_id, version_get_id( $tpl_bug->fixed_in_version, $tpl_bug->project_id ) ) ) : '';
175 html_page_top1( bug_format_summary( $f_bug_id, SUMMARY_CAPTION ) );
176 html_head_end();
177 html_body_begin();
179 echo '<br />';
181 echo '<table class="width100" cellspacing="1">';
182 echo '<tr>';
183 echo '<td class="form-title" colspan="6">';
184 echo '<div class="center">', $tpl_window_title;
186 if ( !is_blank( $tpl_project_name ) ) {
187 echo ' - ' . $tpl_project_name;
190 echo '</div></td>';
191 echo '</tr>';
193 echo '<tr>';
194 echo '<td class="form-title" colspan="6">', lang_get( 'bug_view_title' ), '</td>';
195 echo '</tr>';
197 echo '<tr><td class="print-spacer" colspan="6"><hr /></td></tr>';
199 if ( $tpl_show_id || $tpl_show_project || $tpl_show_category || $tpl_show_view_state ||
200 $tpl_show_date_submitted || $tpl_show_last_updated ) {
201 echo '<tr class="print-category">';
202 echo '<td class="print" width="16%">', $tpl_show_id ? lang_get( 'id' ) : '', '</td>';
203 echo '<td class="print" width="16%">', $tpl_show_project ? lang_get( 'email_project' ) : '', '</td>';
204 echo '<td class="print" width="16%">', $tpl_show_category ? lang_get( 'category' ) : '', '</td>';
205 echo '<td class="print" width="16%">', $tpl_show_view_state ? lang_get( 'view_status' ) : '', '</td>';
206 echo '<td class="print" width="16%">', $tpl_show_date_submitted ? lang_get( 'date_submitted' ) : '', '</td>';
207 echo '<td class="print" width="16%">', $tpl_show_last_updated ? lang_get( 'last_update' ) : '', '</td>';
208 echo '</tr>';
210 echo '<tr class="print">';
211 echo '<td class="print">', $tpl_formatted_bug_id, '</td>';
212 echo '<td class="print">', $tpl_project_name, '</td>';
213 echo '<td class="print">', $tpl_category_name, '</td>';
214 echo '<td class="print">', $tpl_view_state, '</td>';
215 echo '<td class="print">', $tpl_date_submitted, '</td>';
216 echo '<td class="print">', $tpl_last_updated, '</td>';
217 echo '</tr>';
219 echo '<tr><td class="print-spacer" colspan="6"><hr /></td></tr>';
223 # Reporter
226 if ( $tpl_show_reporter ) {
227 echo '<tr class="print">';
228 echo '<th class="print-category">', lang_get( 'reporter' ), '</th>';
229 echo '<td class="print">';
230 print_user_with_subject( $tpl_bug->reporter_id, $f_bug_id );
231 echo '</td>';
232 echo '<td class="print" colspan="4">&#160;</td>';
233 echo '</tr>';
237 # Handler, Due Date
240 if ( $tpl_show_handler || $tpl_show_due_date ) {
241 $t_spacer = 2;
243 echo '<tr class="print">';
245 if ( $tpl_show_handler ) {
246 echo '<th class="print-category">', lang_get( 'assigned_to' ), '</th>';
247 echo '<td class="print">';
248 print_user_with_subject( $tpl_bug->handler_id, $f_bug_id );
249 echo '</td>';
250 } else {
251 $t_spacer += 2;
254 if ( $tpl_show_due_date ) {
255 echo '<th class="print-category">', lang_get( 'due_date' ), '</th>';
256 echo '<td class="print">', $tpl_due_date, '</td>';
257 } else {
258 $t_spacer += 2;
261 echo '<td class="print" colspan="', $t_spacer, '">&#160;</td>';
262 echo '</tr>';
266 # Priority, Severity, Reproducibility
269 if ( $tpl_show_priority || $tpl_show_severity || $tpl_show_reproducibility ) {
270 echo '<tr class="print">';
272 $t_spacer = 0;
274 if ( $tpl_show_priority ) {
275 echo '<th class="print-category">', lang_get( 'priority' ), '</th>';
276 echo '<td class="print">', $tpl_priority, '</td>';
277 } else {
278 $t_spacer += 2;
281 if ( $tpl_show_severity ) {
282 echo '<th class="print-category">', lang_get( 'severity' ), '</th>';
283 echo '<td class="print">', $tpl_severity, '</td>';
284 } else {
285 $t_spacer += 2;
288 if ( $tpl_show_reproducibility ) {
289 echo '<th class="print-category">', lang_get( 'reproducibility' ), '</th>';
290 echo '<td class="print">', $tpl_reproducibility, '</td>';
291 } else {
292 $t_spacer += 2;
295 if ( $t_spacer > 0 ) {
296 echo '<td class="print" colspan="', $t_spacer, '">&#160;</td>';
299 echo '</tr>';
303 # Status, Resolution
306 if ( $tpl_show_status || $tpl_show_resolution ) {
307 echo '<tr class="print">';
309 $t_spacer = 2;
311 if ( $tpl_show_status ) {
312 echo '<th class="print-category">', lang_get( 'status' ), '</th>';
313 echo '<td class="print">', $tpl_status, '</td>';
314 } else {
315 $t_spacer += 2;
318 if ( $tpl_show_resolution ) {
319 echo '<th class="print-category">', lang_get( 'resolution' ), '</th>';
320 echo '<td class="print">', $tpl_resolution, '</td>';
321 } else {
322 $t_spacer += 2;
325 echo '<td class="print" colspan="', $t_spacer, '">&#160;</td>';
326 echo '</tr>';
330 # Projection, ETA
333 if ( $tpl_show_projection || $tpl_show_eta ) {
334 $t_spacer = 2;
336 echo '<tr class="print">';
338 if ( $tpl_show_projection ) {
339 echo '<th class="print-category">', lang_get( 'projection' ), '</th>';
340 echo '<td class="print">', $tpl_projection, '</td>';
341 } else {
342 $t_spacer += 2;
345 if ( $tpl_show_eta ) {
346 echo '<th class="print-category">', lang_get( 'eta' ), '</th>';
347 echo '<td class="print">', $tpl_eta, '</td>';
348 } else {
349 $t_spacer += 2;
352 echo '<td class="print" colspan="', $t_spacer, '">&#160;</td>';
353 echo '</tr>';
357 # Platform, OS, OS Version
360 if ( $tpl_show_platform || $tpl_show_os || $tpl_show_os_version ) {
361 echo '<tr class="print">';
363 $t_spacer = 0;
365 if ( $tpl_show_platform ) {
366 echo '<th class="print-category">', lang_get( 'platform' ), '</th>';
367 echo '<td class="print">', $tpl_platform, '</td>';
368 } else {
369 $t_spacer += 2;
372 if ( $tpl_show_os ) {
373 echo '<th class="print-category">', lang_get( 'os' ), '</th>';
374 echo '<td class="print">', $tpl_os, '</td>';
375 } else {
376 $t_spacer += 2;
379 if ( $tpl_show_os_version ) {
380 echo '<th class="print-category">', lang_get( 'os_version' ), '</th>';
381 echo '<td class="print">', $tpl_os_version, '</td>';
382 } else {
383 $t_spacer += 2;
386 if ( $t_spacer > 0 ) {
387 echo '<td class="print" colspan="', $t_spacer, '">&#160;</td>';
390 echo '</tr>';
394 # Product Version, Product Build
397 if ( $tpl_show_product_version || $tpl_show_product_build ) {
398 echo '<tr class="print">';
400 $t_spacer = 2;
402 if ( $tpl_show_product_version ) {
403 echo '<th class="print-category">', lang_get( 'product_version' ), '</th>';
404 echo '<td class="print">', $tpl_product_version, '</td>';
405 } else {
406 $t_spacer += 2;
409 if ( $tpl_show_product_build ) {
410 echo '<th class="print-category">', lang_get( 'product_build' ), '</th>';
411 echo '<td class="print">', $tpl_product_build, '</td>';
412 } else {
413 $t_spacer += 2;
416 echo '<td class="print" colspan="', $t_spacer, '">&#160;</td>';
417 echo '</tr>';
421 # Target Version, Fixed in Version
424 if ( $tpl_show_target_version || $tpl_show_fixed_in_version ) {
425 echo '<tr>';
427 $t_spacer = 2;
429 if ( $tpl_show_target_version ) {
430 echo '<th class="print-category">', lang_get( 'target_version' ), '</th>';
431 echo '<td class="print">', $tpl_target_version, '</td>';
432 } else {
433 $t_spacer += 2;
436 if ( $tpl_show_fixed_in_version ) {
437 echo '<th class="print-category">', lang_get( 'fixed_in_version' ), '</th>';
438 echo '<td class="print">', $tpl_fixed_in_version, '</td>';
439 } else {
440 $t_spacer += 2;
443 echo '<td class="print" colspan="', $t_spacer, '">&#160;</td>';
444 echo '</tr>';
448 # Custom Fields
451 $t_related_custom_field_ids = custom_field_get_linked_ids( $tpl_bug->project_id );
452 foreach( $t_related_custom_field_ids as $t_id ) {
453 $t_def = custom_field_get_definition( $t_id );
455 echo '<tr class="print">';
456 echo '<th class="print-category">', string_display_line( lang_get_defaulted( $t_def['name'] ) ), '</th>';
457 echo '<td class="print" colspan="4">';
458 print_custom_field_value( $t_def, $t_id, $f_bug_id );
459 echo '</td>';
460 echo '</tr>';
461 } // foreach
463 echo '<tr><td class="print-spacer" colspan="6"><hr /></td></tr>';
465 if ( $tpl_show_summary ) {
466 echo '<tr class="print">';
467 echo '<th class="print-category">', lang_get( 'summary' ), '</th>';
468 echo '<td class="print" colspan="5">', $tpl_summary, '</td>';
469 echo '</tr>';
472 if ( $tpl_show_description ) {
473 echo '<tr class="print">';
474 echo '<th class="print-category">', lang_get( 'description' ), '</th>';
475 echo '<td class="print" colspan="5">', $tpl_description, '</td>';
476 echo '</tr>';
479 if ( $tpl_show_steps_to_reproduce ) {
480 echo '<tr class="print">';
481 echo '<th class="print-category">', lang_get( 'steps_to_reproduce' ), '</th>';
482 echo '<td class="print" colspan="5">', $tpl_steps_to_reproduce, '</td>';
483 echo '</tr>';
486 if ( $tpl_show_additional_information ) {
487 echo '<tr class="print">';
488 echo '<th class="print-category">', lang_get( 'additional_information' ), '</th>';
489 echo '<td class="print" colspan="5">', $tpl_additional_information, '</td>';
490 echo '</tr>';
493 # Tagging
494 if ( $tpl_show_tags ) {
495 echo "<tr class=\"print\">";
496 echo '<th class="print-category">', lang_get( 'tags' ), '</th>';
497 echo '<td class="print" colspan="5">';
498 tag_display_attached( $f_bug_id );
499 echo '</td></tr>';
502 echo "<tr class=\"print\">";
503 echo "<td class=\"print-category\">" . lang_get( 'bug_relationships' ) . "</td>";
504 echo "<td class=\"print\" colspan=\"5\">" . relationship_get_summary_html_preview( $f_bug_id ) . "</td></tr>";
506 if ( $tpl_show_attachments ) {
507 echo '<tr class="print">';
508 echo '<th class="print-category">', lang_get( 'attached_files' ), '</th>';
509 echo '<td class="print" colspan="5">';
511 $t_attachments = file_get_visible_attachments( $f_bug_id );
512 $t_first_attachment = true;
513 $t_path = config_get_global( 'path' );
515 foreach ( $t_attachments as $t_attachment ) {
516 if ( $t_first_attachment ) {
517 $t_first_attachment = false;
518 } else {
519 echo '<br />';
522 $c_filename = string_display_line( $t_attachment['display_name'] );
523 $c_download_url = $t_path . htmlspecialchars( $t_attachment['download_url'] );
524 $c_filesize = number_format( $t_attachment['size'] );
525 $c_date_added = date( config_get( 'normal_date_format' ), $t_attachment['date_added'] );
526 if ( isset( $t_attachment['icon'] ) ) {
527 echo '<img src="', $t_attachment['icon']['url'], '" alt="', $t_attachment['icon']['alt'], '" />&#160;';
530 echo "$c_filename ($c_filesize) <span class=\"italic\">$c_date_added</span><br />$c_download_url";
532 if ( $t_attachment['preview'] && $t_attachment['type'] == 'image' ) {
533 echo '<br /><img src="', $t_attachment['download_url'], '" alt="', $t_attachment['alt'], '" /><br />';
537 echo '</td></tr>';
541 # Issue History
544 if ( $tpl_show_history ) {
545 echo '<tr><td class="print-spacer" colspan="6"><hr /></td></tr>';
547 echo '<tr><th class="form-title">', lang_get( 'bug_history' ), '</th></tr>';
549 echo '<tr class="print-category">';
550 echo '<th class="row-category-history">', lang_get( 'date_modified' ), '</th>';
551 echo '<th class="row-category-history">', lang_get( 'username' ), '</th>';
552 echo '<th class="row-category-history">', lang_get( 'field' ), '</th>';
553 echo '<th class="row-category-history">', lang_get( 'change' ), '</th>';
554 echo '</tr>';
556 $t_history = history_get_events_array( $f_bug_id );
558 foreach ( $t_history as $t_item ) {
559 echo '<tr class="print">';
560 echo '<td class="print">', $t_item['date'], '</td>';
561 echo '<td class="print">';
562 print_user( $t_item['userid'] );
563 echo '</td>';
564 echo '<td class="print">', string_display( $t_item['note'] ), '</td>';
565 echo '<td class="print">', string_display_line_links( $t_item['change'] ), '</td>';
566 echo '</tr>';
570 echo '</table>';
572 define( 'PRINT_BUGNOTE_INC_ALLOW', true );
573 include( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'print_bugnote_inc.php' ) ;
575 last_visited_issue( $f_bug_id );
577 html_body_end();
578 html_end();