SOAP API: Issue updates only set the provided fields
[mantis.git] / excel_xml_export.php
blob45aac7432c1aa35fcf03237576c17c5247d4700d
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 * Excel (2003 SP2 and above) export page
20 * @package MantisBT
21 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
22 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
23 * @link http://www.mantisbt.org
25 * @uses core.php
26 * @uses authentication_api.php
27 * @uses bug_api.php
28 * @uses columns_api.php
29 * @uses config_api.php
30 * @uses excel_api.php
31 * @uses file_api.php
32 * @uses filter_api.php
33 * @uses gpc_api.php
34 * @uses helper_api.php
35 * @uses print_api.php
36 * @uses utility_api.php
39 /**
40 * MantisBT Core API's
42 require_once( 'core.php' );
43 require_api( 'authentication_api.php' );
44 require_api( 'bug_api.php' );
45 require_api( 'columns_api.php' );
46 require_api( 'config_api.php' );
47 require_api( 'excel_api.php' );
48 require_api( 'file_api.php' );
49 require_api( 'filter_api.php' );
50 require_api( 'gpc_api.php' );
51 require_api( 'helper_api.php' );
52 require_api( 'print_api.php' );
53 require_api( 'utility_api.php' );
55 define( 'PRINT_ALL_BUG_OPTIONS_INC_ALLOW', true );
56 include( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'print_all_bug_options_inc.php' );
58 auth_ensure_user_authenticated();
60 $f_export = gpc_get_string( 'export', '' );
62 helper_begin_long_process();
64 $t_export_title = excel_get_default_filename();
66 $t_short_date_format = config_get( 'short_date_format' );
68 # This is where we used to do the entire actual filter ourselves
69 $t_page_number = gpc_get_int( 'page_number', 1 );
70 $t_per_page = 100;
71 $t_bug_count = null;
72 $t_page_count = null;
74 $result = filter_get_bug_rows( $t_page_number, $t_per_page, $t_page_count, $t_bug_count );
75 if ( $result === false ) {
76 print_header_redirect( 'view_all_set.php?type=0&print=1' );
79 header( 'Content-Type: application/vnd.ms-excel; charset=UTF-8' );
80 header( 'Pragma: public' );
81 header( 'Content-Disposition: attachment; filename="' . urlencode( file_clean_name( $t_export_title ) ) . '.xml"' ) ;
83 echo excel_get_header( $t_export_title );
84 echo excel_get_titles_row();
86 $f_bug_arr = explode( ',', $f_export );
88 $t_columns = excel_get_columns();
92 $t_more = true;
93 $t_row_count = count( $result );
95 for( $i = 0; $i < $t_row_count; $i++ ) {
96 $t_row = $result[$i];
97 $t_bug = null;
99 if ( is_blank( $f_export ) || in_array( $t_row->id, $f_bug_arr ) ) {
100 echo excel_get_start_row();
102 foreach ( $t_columns as $t_column ) {
103 if ( column_is_extended( $t_column ) ) {
104 if ( $t_bug === null ) {
105 $t_bug = bug_get( $t_row->id, /* extended = */ true );
108 $t_function = 'excel_format_' . $t_column;
109 echo $t_function( $t_bug->$t_column );
110 } else {
111 $t_custom_field = column_get_custom_field_name( $t_column );
112 if ( $t_custom_field !== null ) {
113 echo excel_format_custom_field( $t_row->id, $t_row->project_id, $t_custom_field );
114 } else {
115 $t_function = 'excel_format_' . $t_column;
116 echo $t_function( $t_row->$t_column );
121 echo excel_get_end_row();
122 } #in_array
123 } #for loop
125 // If got a full page, then attempt for the next one.
126 // @@@ Note that since we are not using a transaction, there is a risk that we get a duplicate record or we miss
127 // one due to a submit or update that happens in parallel.
128 if ( $t_row_count == $t_per_page ) {
129 $t_page_number++;
130 $t_bug_count = null;
131 $t_page_count = null;
133 $result = filter_get_bug_rows( $t_page_number, $t_per_page, $t_page_count, $t_bug_count );
134 if ( $result === false ) {
135 $t_more = false;
137 } else {
138 $t_more = false;
140 } while ( $t_more );
142 echo excel_get_footer();