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/>.
18 * Word 2000 export page
19 * The bugs displayed in print_all_bug_page.php are saved in a .doc file
20 * The IE icon allows to see or directly print the same result
23 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
24 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
25 * @link http://www.mantisbt.org
28 * @uses access_api.php
29 * @uses authentication_api.php
31 * @uses bugnote_api.php
32 * @uses category_api.php
33 * @uses config_api.php
34 * @uses constant_inc.php
35 * @uses custom_field_api.php
38 * @uses filter_api.php
40 * @uses helper_api.php
44 * @uses prepare_api.php
46 * @uses profile_api.php
47 * @uses project_api.php
48 * @uses string_api.php
54 require_once( 'core.php' );
55 require_api( 'access_api.php' );
56 require_api( 'authentication_api.php' );
57 require_api( 'bug_api.php' );
58 require_api( 'bugnote_api.php' );
59 require_api( 'category_api.php' );
60 require_api( 'config_api.php' );
61 require_api( 'constant_inc.php' );
62 require_api( 'custom_field_api.php' );
63 require_api( 'date_api.php' );
64 require_api( 'file_api.php' );
65 require_api( 'filter_api.php' );
66 require_api( 'gpc_api.php' );
67 require_api( 'helper_api.php' );
68 require_api( 'html_api.php' );
69 require_api( 'http_api.php' );
70 require_api( 'lang_api.php' );
71 require_api( 'prepare_api.php' );
72 require_api( 'print_api.php' );
73 require_api( 'profile_api.php' );
74 require_api( 'project_api.php' );
75 require_api( 'string_api.php' );
77 auth_ensure_user_authenticated();
79 $f_type_page = gpc_get_string( 'type_page', 'word' );
80 $f_search = gpc_get_string( 'search', false ); /** @todo need a better default */
81 $f_offset = gpc_get_int( 'offset', 0 );
82 $f_export = gpc_get_string( 'export' );
83 $f_show_flag = gpc_get_bool( 'show_flag' );
85 helper_begin_long_process();
88 if ( $f_type_page != 'html' ) {
89 $t_export_title = helper_get_default_export_filename( '' );
90 $t_export_title = preg_replace( '/[\/:*?"<>|]/', '', $t_export_title );
91 $t_export_title .= '.doc';
93 # Make sure that IE can download the attachments under https.
94 header( 'Pragma: public' );
96 header( 'Content-Type: application/msword' );
98 http_content_disposition_header( $t_export_title );
101 # This is where we used to do the entire actual filter ourselves
102 $t_page_number = gpc_get_int( 'page_number', 1 );
105 $t_page_count = null;
107 $result = filter_get_bug_rows( $t_page_number, $t_per_page, $t_page_count, $t_bug_count );
108 $t_row_count = count( $result );
111 <html xmlns
:o
="urn:schemas-microsoft-com:office:office"
112 xmlns
:w
="urn:schemas-microsoft-com:office:word"
113 xmlns
="http://www.w3.org/TR/REC-html40">
120 $f_bug_arr = explode( ',', $f_export );
121 $t_count_exported = 0;
122 $t_date_format = config_get( 'normal_date_format' );
123 $t_short_date_format = config_get( 'short_date_format' );
125 $t_lang_bug_view_title = lang_get( 'bug_view_title' );
126 $t_lang_id = lang_get( 'id' );
127 $t_lang_category = lang_get( 'category' );
128 $t_lang_severity = lang_get( 'severity' );
129 $t_lang_reproducibility = lang_get( 'reproducibility' );
130 $t_lang_date_submitted = lang_get( 'date_submitted' );
131 $t_lang_last_update = lang_get( 'last_update' );
132 $t_lang_reporter = lang_get( 'reporter' );
133 $t_lang_assigned_to = lang_get( 'assigned_to' );
134 $t_lang_platform = lang_get( 'platform' );
135 $t_lang_due_date = lang_get( 'due_date' );
136 $t_lang_os = lang_get( 'os' );
137 $t_lang_os_version = lang_get( 'os_version' );
138 $t_lang_fixed_in_version = lang_get( 'fixed_in_version' );
139 $t_lang_resolution = lang_get( 'resolution' );
140 $t_lang_priority = lang_get( 'priority' );
141 $t_lang_product_build = lang_get( 'product_build' );
142 $t_lang_eta = lang_get( 'eta' );
143 $t_lang_status = lang_get( 'status' );
144 $t_lang_product_version = lang_get( 'product_version' );
145 $t_lang_no_bugnotes_msg = lang_get( 'no_bugnotes_msg' );
146 $t_lang_projection = lang_get( 'projection' );
147 $t_lang_target_version = lang_get( 'target_version' );
148 $t_lang_summary = lang_get( 'summary' );
149 $t_lang_description = lang_get( 'description' );
150 $t_lang_steps_to_reproduce = lang_get( 'steps_to_reproduce' );
151 $t_lang_additional_information = lang_get( 'additional_information' );
152 $t_lang_bug_notes_title = lang_get( 'bug_notes_title' );
153 $t_lang_system_profile = lang_get( 'system_profile' );
154 $t_lang_attached_files = lang_get( 'attached_files' );
156 $t_current_user_id = auth_get_current_user_id();
157 $t_user_bugnote_order = user_pref_get_pref ( $t_current_user_id, 'bugnote_order' );
159 for( $j=0; $j < $t_row_count; $j++
) {
160 $t_bug = $result[$j];
163 if ( $j %
50 == 0 ) {
164 # to save ram as report will list data once, clear cache after 50 bugs
165 bug_text_clear_cache();
167 bugnote_clear_cache();
170 # display the available and selected bugs
171 if ( in_array( $t_id, $f_bug_arr ) ||
!$f_show_flag ) {
172 if ( $t_count_exported > 0 ) {
173 echo '<br style="mso-special-character: line-break; page-break-before: always">';
178 $t_last_updated = date( $g_short_date_format, $t_bug->last_updated
);
180 # grab the project name
181 $t_project_name = project_get_field( $t_bug->project_id
, 'name' );
182 $t_category_name = category_full_name( $t_bug->category_id
, false );
185 <table
class="width100" cellspacing
="1">
187 <td
class="form-title" colspan
="3">
188 <?php
echo $t_lang_bug_view_title ?
>
192 <td
class="print-spacer" colspan
="6">
196 <tr
class="print-category">
197 <td
class="print" width
="16%">
198 <?php
echo sprintf( lang_get( 'label' ), $t_lang_id ) ?
>
200 <td
class="print" width
="16%">
201 <?php
echo sprintf( lang_get( 'label' ), $t_lang_category ) ?
>
203 <td
class="print" width
="16%">
204 <?php
echo sprintf( lang_get( 'label' ), $t_lang_severity ) ?
>
206 <td
class="print" width
="16%">
207 <?php
echo sprintf( lang_get( 'label' ), $t_lang_reproducibility ) ?
>
209 <td
class="print" width
="16%">
210 <?php
echo sprintf( lang_get( 'label' ), $t_lang_date_submitted ) ?
>
212 <td
class="print" width
="16%">
213 <?php
echo sprintf( lang_get( 'label' ), $t_lang_last_update ) ?
>
221 <?php
echo '[' . string_display_line( $t_project_name ) . '] ' . string_display_line( $t_category_name ) ?
>
224 <?php
echo get_enum_element( 'severity', $t_bug->severity
) ?
>
227 <?php
echo get_enum_element( 'reproducibility', $t_bug->reproducibility
) ?
>
230 <?php
echo date( $t_date_format, $t_bug->date_submitted
) ?
>
233 <?php
echo date( $t_date_format, $t_bug->last_updated
) ?
>
237 <td
class="print-spacer" colspan
="6">
242 <td
class="print-category">
243 <?php
echo sprintf( lang_get( 'label' ), $t_lang_reporter ) ?
>
246 <?php
print_user_with_subject( $t_bug->reporter_id
, $t_id ) ?
>
248 <td
class="print-category">
249 <?php
echo sprintf( lang_get( 'label' ), $t_lang_platform ) ?
>
252 <?php
echo string_display_line( $t_bug->platform
) ?
>
254 <?php
if ( access_has_bug_level( config_get( 'due_date_view_threshold' ), $t_id ) ) { ?
>
255 <td
class="print-category">
256 <?php
echo sprintf( lang_get( 'label' ), $t_lang_due_date ) ?
>
259 if ( bug_is_overdue( $t_id ) ) { ?
>
260 <td
class="print-overdue">
266 if ( !date_is_null( $t_bug->due_date
) ) {
267 echo date( $t_short_date_format, $t_bug->due_date
);
272 <td
class="print" colspan
="2"> </td>
276 <td
class="print-category">
277 <?php
echo sprintf( lang_get( 'label' ), $t_lang_assigned_to ) ?
>
281 if ( access_has_bug_level( config_get( 'view_handler_threshold' ), $t_id ) ) {
282 print_user_with_subject( $t_bug->handler_id
, $t_id );
286 <td
class="print-category">
287 <?php
echo sprintf( lang_get( 'label' ), $t_lang_os ) ?
>
290 <?php
echo string_display_line( $t_bug->os
) ?
>
292 <td
class="print" colspan
="2"> </td>
295 <td
class="print-category">
296 <?php
echo sprintf( lang_get( 'label' ), $t_lang_priority ) ?
>
299 <?php
echo get_enum_element( 'priority', $t_bug->priority
) ?
>
301 <td
class="print-category">
302 <?php
echo sprintf( lang_get( 'label' ), $t_lang_os_version ) ?
>
305 <?php
echo string_display_line( $t_bug->os_build
) ?
>
307 <td
class="print" colspan
="2"> </td>
310 <td
class="print-category">
311 <?php
echo sprintf( lang_get( 'label' ), $t_lang_status ) ?
>
314 <?php
echo get_enum_element( 'status', $t_bug->status
) ?
>
316 <td
class="print-category">
317 <?php
echo sprintf( lang_get( 'label' ), $t_lang_product_version ) ?
>
320 <?php
echo string_display_line( $t_bug->version
) ?
>
322 <td
class="print" colspan
="2"> </td>
325 <td
class="print-category">
326 <?php
echo sprintf( lang_get( 'label' ), $t_lang_product_build ) ?
>
329 <?php
echo string_display_line( $t_bug->build
) ?
>
331 <td
class="print-category">
332 <?php
echo sprintf( lang_get( 'label' ), $t_lang_resolution ) ?
>
335 <?php
echo get_enum_element( 'resolution', $t_bug->resolution
) ?
>
337 <td
class="print" colspan
="2"> </td>
340 <td
class="print-category">
341 <?php
echo sprintf( lang_get( 'label' ), $t_lang_projection ) ?
>
344 <?php
echo get_enum_element( 'projection', $t_bug->projection
) ?
>
346 <td
class="print-category">
352 <td
class="print" colspan
="2"> </td>
355 <td
class="print-category">
356 <?php
echo sprintf( lang_get( 'label' ), $t_lang_eta ) ?
>
359 <?php
echo get_enum_element( 'eta', $t_bug->eta
) ?
>
361 <td
class="print-category">
362 <?php
echo sprintf( lang_get( 'label' ), $t_lang_fixed_in_version ) ?
>
365 <?php
echo string_display_line( $t_bug->fixed_in_version
) ?
>
367 <td
class="print" colspan
="2"> </td>
371 <td
class="print-category">
377 <td
class="print-category">
378 <?php
echo sprintf( lang_get( 'label' ), $t_lang_target_version ) ?
>
381 <?php
echo string_display_line( $t_bug->target_version
) ?
>
383 <td
class="print" colspan
="2"> </td>
386 $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug->project_id
);
387 foreach( $t_related_custom_field_ids as $t_custom_field_id ) {
388 $t_def = custom_field_get_definition( $t_custom_field_id );
391 <td
class="print-category">
392 <?php
echo sprintf( lang_get( 'label' ), lang_get_defaulted( $t_def['name'] ) ) ?
>
394 <td
class="print" colspan
="5">
395 <?php
print_custom_field_value( $t_def, $t_custom_field_id, $t_id ); ?
>
402 <td
class="print-spacer" colspan
="6">
407 <td
class="print-category">
408 <?php
echo sprintf( lang_get( 'label' ), $t_lang_summary ) ?
>
410 <td
class="print" colspan
="5">
411 <?php
echo string_display_line_links( $t_bug->summary
) ?
>
415 <td
class="print-category">
416 <?php
echo sprintf( lang_get( 'label' ), $t_lang_description ) ?
>
418 <td
class="print" colspan
="5">
419 <?php
echo string_display_line_links( $t_bug->description
) ?
>
423 <td
class="print-category">
424 <?php
echo sprintf( lang_get( 'label' ), $t_lang_steps_to_reproduce ) ?
>
426 <td
class="print" colspan
="5">
427 <?php
echo string_display_line_links( $t_bug->steps_to_reproduce
) ?
>
431 <td
class="print-category">
432 <?php
echo sprintf( lang_get( 'label' ), $t_lang_additional_information ) ?
>
434 <td
class="print" colspan
="5">
435 <?php
echo string_display_line_links( $t_bug->additional_information
) ?
>
439 # account profile description
440 if ( $t_bug->profile_id
> 0 ) {
441 $t_profile_row = profile_get_row_direct( $t_bug->profile_id
);
442 $t_profile_description = string_display( $t_profile_row['description'] );
446 <td
class="print-category">
447 <?php
echo $t_lang_system_profile ?
>
449 <td
class="print" colspan
="5">
450 <?php
echo $t_profile_description ?
>
454 } # profile description
457 <td
class="print-category">
458 <?php
echo sprintf( lang_get( 'label' ), $t_lang_attached_files ) ?
>
460 <td
class="print" colspan
="5">
462 $t_attachments = file_get_visible_attachments( $t_id );
463 $t_first_attachment = true;
464 $t_path = config_get_global( 'path' );
466 foreach ( $t_attachments as $t_attachment ) {
467 if ( $t_first_attachment ) {
468 $t_first_attachment = false;
473 $c_filename = string_display_line( $t_attachment['display_name'] );
474 $c_download_url = $t_path . htmlspecialchars( $t_attachment['download_url'] );
475 $c_filesize = number_format( $t_attachment['size'] );
476 $c_date_added = date( $t_date_format, $t_attachment['date_added'] );
477 echo "$c_filename ($c_filesize) <span class=\"italic\">$c_date_added</span><br />$c_download_url";
479 if ( $t_attachment['preview'] && $t_attachment['type'] == 'image' && $f_type_page == 'html' ) {
480 echo '<br /><img src="', $t_attachment['download_url'], '" alt="', $t_attachment['alt'], '" /><br />';
487 $t_user_bugnote_limit = 0;
489 $t_bugnotes = bugnote_get_all_visible_bugnotes( $t_id, $t_user_bugnote_order, $t_user_bugnote_limit );
492 <table
class="width100" cellspacing
="1">
495 if ( 0 == count( $t_bugnotes ) ) {
498 <td
class="print" colspan
="2">
499 <?php
echo $t_lang_no_bugnotes_msg ?
>
503 } else { # print bugnotes ?>
505 <td
class="form-title" colspan
="2">
506 <?php
echo $t_lang_bug_notes_title ?
>
510 foreach ( $t_bugnotes as $t_bugnote ) {
511 # prefix all bugnote data with v3_
512 $t_date_submitted = date( $t_date_format, $t_bugnote->date_submitted
);
513 $t_last_modified = date( $t_date_format, $t_bugnote->last_modified
);
515 # grab the bugnote text and id and prefix with v3_
516 $t_note = string_display_links( $t_bugnote->note
);
519 <td
class="print-spacer" colspan
="2">
524 <td
class="nopad" width
="20%">
525 <table
class="hide" cellspacing
="1">
528 (<?php
echo bugnote_format_id( $t_bugnote->id
) ?
>)
533 <?php
print_user( $t_bugnote->reporter_id
) ?
>   
538 <?php
echo $t_date_submitted ?
>   
539 <?php
if ( $t_bugnote->date_submitted
!= $t_bugnote->last_modified
) {
540 echo '<br />(' . lang_get( 'last_edited') . lang_get( 'word_separator' ) . $t_last_modified . ')';
546 <td
class="nopad" width
="85%">
547 <table
class="hide" cellspacing
="1">
551 switch ( $t_bugnote->note_type
) {
553 echo lang_get( 'reminder_sent_to' ) . ' ';
554 $t_note_attr = utf8_substr( $t_bugnote->note_attr
, 1, utf8_strlen( $t_bugnote->note_attr
) - 2 );
556 foreach ( explode( '|', $t_note_attr ) as $t_recipient ) {
557 $t_to[] = prepare_user_name( $t_recipient );
559 echo implode( ', ', $t_to ) . '<br />';
561 echo string_display_links( $t_bugnote->note
);
575 <?php
# Bugnotes END ?>