Skip to content

Commit 29374df

Browse files
committedNov 12, 2012
Fix #14871: Add support for the built-in soap extension in addition to
nusoap Conflicts: api/soap/mantisconnect.php api/soap/mc_issue_api.php docbook/administration_guide/en/configuration.sgml
1 parent 4143f30 commit 29374df

17 files changed

+1813
-1904
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ custom_functions_inc.php
55
custom_relationships_inc.php
66
custom_strings_inc.php
77
mantis_offline.php
8+
api/soap/mc_config_inc.php
89

910
# Docbook builds
1011
docbook/*/*/builddate

‎api/soap/mantisconnect.php

+81-1,678
Large diffs are not rendered by default.

‎api/soap/mantisconnect.wsdl

+1,420
Large diffs are not rendered by default.

‎api/soap/mc_api.php

+109-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,105 @@
99
# set up error_handler() as the new default error handling function
1010
set_error_handler( 'mc_error_handler' );
1111

12+
/**
13+
* Abstract the differences in creating SOAP objects between the php5 soap extension and nusoap
14+
*
15+
* <p>As long as we decide to support both implementations we should add all non-generic
16+
* factory code to this class.</p>
17+
*/
18+
class SoapObjectsFactory {
19+
20+
static function newSoapFault( $p_fault_code, $p_fault_string) {
21+
if ( class_exists('soap_fault') )
22+
return new soap_fault( $p_fault_code, '', $p_fault_string );
23+
else
24+
return new SoapFault( $p_fault_code, $p_fault_string );
25+
}
26+
27+
static function unwrapObject( $p_object ) {
28+
if ( is_object( $p_object ) )
29+
return get_object_vars( $p_object );
30+
31+
return $p_object;
32+
}
33+
34+
static function newDateTimeVar( $p_value ) {
35+
36+
$string_value = self::newDateTimeString( $p_value );
37+
38+
if ( class_exists('soapval') )
39+
return new soapval( 'due_date', 'xsd:dateTime', $string_value );
40+
else
41+
return new SoapVar( $string_value, XSD_DATETIME, 'dateTime');
42+
}
43+
44+
static function newDateTimeString ( $p_timestamp ) {
45+
46+
if ( $p_timestamp == null || date_is_null( $p_timestamp) )
47+
return null;
48+
else if ( function_exists('timestamp_to_iso8601') )
49+
return timestamp_to_iso8601( $p_timestamp, false);
50+
else {
51+
return date('c', (int) $p_timestamp);
52+
}
53+
}
54+
55+
static function parseDateTimeString ( $p_string ) {
56+
57+
if ( function_exists('iso8601_to_timestamp') ) {
58+
return iso8601_to_timestamp( $p_string );
59+
} else {
60+
return strtotime( $p_string );
61+
}
62+
}
63+
64+
static function encodeBinary ( $p_binary ) {
65+
if ( class_exists('soap_fault') )
66+
return base64_encode( $p_binary );
67+
else
68+
return $p_binary;
69+
}
70+
71+
static function isSoapFault ( $p_maybe_fault ) {
72+
if ( ! is_object( $p_maybe_fault ) )
73+
return false;
74+
75+
if ( class_exists('soap_fault') ) {
76+
return get_class($p_maybe_fault ) == 'soap_fault';
77+
} else {
78+
return get_class($p_maybe_fault ) == 'SoapFault';
79+
}
80+
}
81+
}
82+
83+
/**
84+
* Abstract the differences in common actions between the php5 soap extension and nusoap
85+
*
86+
* <p>As long as we decide to support both implementations we should add all non-generic
87+
* action code to this class.</p>
88+
*/
89+
class SoapActions {
90+
91+
/**
92+
* Sends a fault to the user and immediately terminates processing
93+
*
94+
* @param string $p_error_type
95+
* @param string $p_error_message
96+
* @throws SoapFault
97+
*/
98+
static function sendSoapFault ( $p_error_type, $p_error_message) {
99+
100+
global $l_oServer;
101+
102+
if ( $l_oServer ) {
103+
$l_oServer->fault( $p_error_type, $p_error_message);
104+
$l_oServer->send_response();
105+
exit();
106+
} else {
107+
throw new SoapFault($p_error_type, $p_error_message);
108+
}
109+
}
110+
}
12111
/**
13112
* Get the MantisConnect webservice version.
14113
*/
@@ -105,6 +204,9 @@ function mci_has_administrator_access( $p_user_id, $p_project_id = ALL_PROJECTS
105204
}
106205

107206
function mci_get_project_id( $p_project ) {
207+
if ( is_object( $p_project ) )
208+
$p_project = get_object_vars( $p_project );
209+
108210
if ( isset( $p_project['id'] ) && (int) $p_project['id'] != 0 ) {
109211
$t_project_id = (int) $p_project['id'];
110212
} else if ( isset( $p_project['name'] ) && !is_blank( $p_project['name'] ) ) {
@@ -125,6 +227,9 @@ function mci_get_project_view_state_id( $p_view_state ) {
125227
}
126228

127229
function mci_get_user_id( $p_user ) {
230+
231+
$p_user = SoapObjectsFactory::unwrapObject( $p_user );
232+
128233
$t_user_id = 0;
129234

130235
if ( isset( $p_user['id'] ) && (int) $p_user['id'] != 0 ) {
@@ -341,7 +446,7 @@ function mci_project_version_as_array( $p_version ) {
341446
'id' => $p_version['id'],
342447
'name' => $p_version['version'],
343448
'project_id' => $p_version['project_id'],
344-
'date_order' => timestamp_to_iso8601( $p_version['date_order'], false ),
449+
'date_order' => SoapObjectsFactory::newDateTimeVar( $p_version['date_order'] ),
345450
'description' => mci_null_if_empty( $p_version['description'] ),
346451
'released' => $p_version['released'],
347452
'obsolete' => $p_version['obsolete']
@@ -376,7 +481,6 @@ function mci_get_time_tracking_from_note( $p_issue_id, $p_note) {
376481
# The others, being system errors, will come with a string in $p_error
377482
#
378483
function mc_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
379-
global $l_oServer;
380484

381485
# check if errors were disabled with @ somewhere in this call chain
382486
# also suppress php 5 strict warnings
@@ -424,9 +528,7 @@ function mc_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
424528

425529
error_log("[mantisconnect.php] Error Type: $t_error_type,\nError Description: $t_error_description\nStack Trace:\n$t_error_stack");
426530

427-
$l_oServer->fault( 'Server', "Error Type: $t_error_type,\nError Description: $t_error_description" );
428-
$l_oServer->send_response();
429-
exit();
531+
SoapActions::sendSoapFault('Server', "Error Type: $t_error_type,\nError Description: $t_error_description");
430532
}
431533

432534
# Get a stack trace if PHP provides the facility or xdebug is present
@@ -495,7 +597,7 @@ function error_get_stack_trace() {
495597
* @return soap_fault
496598
*/
497599
function mci_soap_fault_login_failed() {
498-
return new soap_fault('Client', '', 'Access denied.');
600+
return SoapObjectsFactory::newSoapFault('Client', 'Access denied');
499601
}
500602

501603
/**
@@ -512,5 +614,5 @@ function mci_soap_fault_access_denied( $p_user_id, $p_detail = '' ) {
512614
if ( !is_blank( $p_detail ))
513615
$t_reason .= ' Reason: ' . $p_detail . '.';
514616

515-
return new soap_fault( 'Client', '', $t_reason );
617+
return SoapObjectsFactory::newSoapFault('Client', $t_reason);
516618
}

‎api/soap/mc_config_api.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ function mc_config_get_string( $p_username, $p_password, $p_config_var ) {
1717
}
1818

1919
if( config_is_private( $p_config_var ) ) {
20-
return new soap_fault( 'Client', '', "Access to '$p_config_var' is denied" );
20+
return SoapObjectsFactory::newSoapFault( 'Client', "Access to '$p_config_var' is denied" );
2121
}
2222

2323
if( !config_is_set( $p_config_var ) ) {
24-
return new soap_fault( 'Client', '', "Config '$p_config_var' is undefined" );
24+
return SoapObjectsFactory::newSoapFault( 'Client', "Config '$p_config_var' is undefined" );
2525
}
2626

2727
return config_get( $p_config_var );

‎api/soap/mc_config_defaults_inc.php

+10
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@
4545
# Default version to be used if the specified version is not found and $g_mc_error_when_version_not_found == OFF.
4646
# (at the moment this value does not depend on the project).
4747
$g_mc_version_when_not_found = '';
48+
49+
/**
50+
* MantisConnect - use nusoap for SOAP handling
51+
*
52+
* <p>When the native PHP extension is available this flag default to OFF, which means that nusoap
53+
* will not used. The native extension has the advantage of being faster, more memory efficient and
54+
* maintained to work with recent versions on PHP. When the extension is not available
55+
* MantisBT falls back to using nusoap.</p>
56+
*/
57+
$g_mc_use_nusoap = extension_loaded('soap') ? OFF : ON;

‎api/soap/mc_core.php

-19
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,6 @@
66
# change the license of future releases.
77
# See docs/ folder for more details
88

9-
# Path to MantisBT is assumed to be the grand parent directory. If this is not
10-
# the case, then this variable should be set to the MantisBT path.
11-
# This can not be a configuration option, then MantisConnect configuration
12-
# needs MantisBT to be included first to make use of the constants and possibly
13-
# configuration defined in MantisBT.
14-
$t_mantis_dir = dirname( dirname( dirname( __FILE__ ) ) ) . DIRECTORY_SEPARATOR;
15-
16-
# include Mantis files
17-
$g_bypass_headers = true;
18-
require_once( $t_mantis_dir . 'core.php' );
19-
20-
# constants and configurations
21-
$t_current_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
22-
require_once( $t_current_dir . 'mc_config_defaults_inc.php' );
23-
24-
$t_user_configs = $t_current_dir . 'mc_config_inc.php';
25-
if( file_exists( $t_user_configs ) ) {
26-
require_once( $t_user_configs );
27-
}
289

2910
# MantisConnect APIs
3011
# mc_* = public methods

‎api/soap/mc_custom_field_api.php

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
* @param ObjectRef $p_object_ref An associate array with "id" and "name" keys.
1616
*/
1717
function mci_get_custom_field_id_from_objectref( $p_object_ref ) {
18+
19+
$p_object_ref = SoapObjectsFactory::unwrapObject( $p_object_ref );
20+
1821
if( (int) $p_object_ref['id'] != 0 ) {
1922
$t_id = (int) $p_object_ref['id'];
2023
} else {

‎api/soap/mc_enum_api.php

+16-13
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
function mc_enum_status( $p_username, $p_password ) {
1717
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
18-
return new soap_fault( 'Client', '', 'Access Denied' );
18+
return mci_soap_fault_login_failed();
1919
}
2020

2121
return mci_explode_to_objectref( 'status' );
@@ -30,7 +30,7 @@ function mc_enum_status( $p_username, $p_password ) {
3030
*/
3131
function mc_enum_priorities( $p_username, $p_password ) {
3232
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
33-
return new soap_fault( 'Client', '', 'Access Denied' );
33+
return mci_soap_fault_login_failed();
3434
}
3535

3636
return mci_explode_to_objectref( 'priority' );
@@ -45,7 +45,7 @@ function mc_enum_priorities( $p_username, $p_password ) {
4545
*/
4646
function mc_enum_severities( $p_username, $p_password ) {
4747
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
48-
return new soap_fault( 'Client', '', 'Access Denied' );
48+
return mci_soap_fault_login_failed();
4949
}
5050

5151
return mci_explode_to_objectref( 'severity' );
@@ -60,7 +60,7 @@ function mc_enum_severities( $p_username, $p_password ) {
6060
*/
6161
function mc_enum_reproducibilities( $p_username, $p_password ) {
6262
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
63-
return new soap_fault( 'Client', '', 'Access Denied' );
63+
return mci_soap_fault_login_failed();
6464
}
6565

6666
return mci_explode_to_objectref( 'reproducibility' );
@@ -75,7 +75,7 @@ function mc_enum_reproducibilities( $p_username, $p_password ) {
7575
*/
7676
function mc_enum_projections( $p_username, $p_password ) {
7777
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
78-
return new soap_fault( 'Client', '', 'Access Denied' );
78+
return mci_soap_fault_login_failed();
7979
}
8080

8181
return mci_explode_to_objectref( 'projection' );
@@ -90,7 +90,7 @@ function mc_enum_projections( $p_username, $p_password ) {
9090
*/
9191
function mc_enum_etas( $p_username, $p_password ) {
9292
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
93-
return new soap_fault( 'Client', '', 'Access Denied' );
93+
return mci_soap_fault_login_failed();
9494
}
9595

9696
return mci_explode_to_objectref( 'eta' );
@@ -105,7 +105,7 @@ function mc_enum_etas( $p_username, $p_password ) {
105105
*/
106106
function mc_enum_resolutions( $p_username, $p_password ) {
107107
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
108-
return new soap_fault( 'Client', '', 'Access Denied' );
108+
return mci_soap_fault_login_failed();
109109
}
110110

111111
return mci_explode_to_objectref( 'resolution' );
@@ -120,7 +120,7 @@ function mc_enum_resolutions( $p_username, $p_password ) {
120120
*/
121121
function mc_enum_access_levels( $p_username, $p_password ) {
122122
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
123-
return new soap_fault( 'Client', '', 'Access Denied' );
123+
return mci_soap_fault_login_failed();
124124
}
125125

126126
return mci_explode_to_objectref( 'access_levels' );
@@ -135,7 +135,7 @@ function mc_enum_access_levels( $p_username, $p_password ) {
135135
*/
136136
function mc_enum_project_status( $p_username, $p_password ) {
137137
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
138-
return new soap_fault( 'Client', '', 'Access Denied' );
138+
return mci_soap_fault_login_failed();
139139
}
140140

141141
return mci_explode_to_objectref( 'project_status' );
@@ -150,7 +150,7 @@ function mc_enum_project_status( $p_username, $p_password ) {
150150
*/
151151
function mc_enum_project_view_states( $p_username, $p_password ) {
152152
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
153-
return new soap_fault( 'Client', '', 'Access Denied' );
153+
return mci_soap_fault_login_failed();
154154
}
155155

156156
return mci_explode_to_objectref( 'project_view_state' );
@@ -165,7 +165,7 @@ function mc_enum_project_view_states( $p_username, $p_password ) {
165165
*/
166166
function mc_enum_view_states( $p_username, $p_password ) {
167167
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
168-
return new soap_fault( 'Client', '', 'Access Denied' );
168+
return mci_soap_fault_login_failed();
169169
}
170170

171171
return mci_explode_to_objectref( 'view_state' );
@@ -180,7 +180,7 @@ function mc_enum_view_states( $p_username, $p_password ) {
180180
*/
181181
function mc_enum_custom_field_types( $p_username, $p_password ) {
182182
if ( !mci_validate_enum_access( $p_username, $p_password ) ) {
183-
return new soap_fault( 'Client', '', 'Access Denied' );
183+
return mci_soap_fault_login_failed();
184184
}
185185

186186
return mci_explode_to_objectref( 'custom_field_type' );
@@ -196,7 +196,7 @@ function mc_enum_custom_field_types( $p_username, $p_password ) {
196196
*/
197197
function mc_enum_get( $p_username, $p_password, $p_enumeration ) {
198198
if ( ! mci_validate_enum_access($p_username, $p_password)) {
199-
return new soap_fault( 'Client', '', 'Access Denied' );
199+
return mci_soap_fault_login_failed();
200200
}
201201

202202
// safe to call directly after login checks
@@ -298,6 +298,9 @@ function mci_get_enum_value_from_label( $p_enum_string, $p_label ) {
298298
* @return enum id
299299
*/
300300
function mci_get_enum_id_from_objectref( $p_enum, $p_object_ref ) {
301+
302+
$p_object_ref = SoapObjectsFactory::unwrapObject( $p_object_ref );
303+
301304
if( !is_null( $p_object_ref ) && isset( $p_object_ref['id'] ) && (int) $p_object_ref['id'] != 0 ) {
302305
$t_id = (int) $p_object_ref['id'];
303306
} else {

‎api/soap/mc_file_api.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ function mci_file_write_local( $p_diskfile, $p_content ) {
3434

3535
function mci_file_add( $p_id, $p_name, $p_content, $p_file_type, $p_table, $p_title = '', $p_desc = '', $p_user_id = null ) {
3636
if( !file_type_check( $p_name ) ) {
37-
return new soap_fault( 'Client', '', 'File type not allowed.' );
37+
return SoapObjectsFactory::newSoapFault( 'Client', 'File type not allowed.' );
3838
}
3939
if( !file_is_name_unique( $p_name, $p_id ) ) {
40-
return new soap_fault( 'Client', '', 'Duplicate filename.' );
40+
return SoapObjectsFactory::newSoapFault( 'Client', 'Duplicate filename.' );
4141
}
4242

4343
$t_file_size = strlen( $p_content );
4444
$t_max_file_size = (int) min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get( 'max_file_size' ) );
4545
if( $t_file_size > $t_max_file_size ) {
46-
return new soap_fault( 'Client', '', 'File is too big.' );
46+
return SoapObjectsFactory::newSoapFault( 'Client', 'File is too big.' );
4747
}
4848

4949
if( 'bug' == $p_table ) {
@@ -93,7 +93,7 @@ function mci_file_add( $p_id, $p_name, $p_content, $p_file_type, $p_table, $p_ti
9393
case FTP:
9494
case DISK:
9595
if( !file_exists( $t_file_path ) || !is_dir( $t_file_path ) || !is_writable( $t_file_path ) || !is_readable( $t_file_path ) ) {
96-
return new soap_fault( 'Server', '', "Upload folder '{$t_file_path}' doesn't exist." );
96+
return SoapObjectsFactory::newSoapFault( 'Server', "Upload folder '{$t_file_path}' doesn't exist.");
9797
}
9898

9999
file_ensure_valid_upload_path( $t_file_path );
@@ -167,13 +167,13 @@ function mci_file_get( $p_file_id, $p_type, $p_user_id ) {
167167
WHERE id='$p_file_id'";
168168
break;
169169
default:
170-
return new soap_fault( 'Server', '', 'Invalid file type '.$p_type. ' .' );
170+
return SoapObjectsFactory::newSoapFault( 'Server', 'Invalid file type '.$p_type. ' .' );
171171
}
172172

173173
$result = db_query( $query );
174174

175175
if ( $result->EOF ) {
176-
return new soap_fault( 'Client', '', 'Unable to find an attachment with type ' . $p_type. ' and id ' . $p_file_id . ' .' );
176+
return SoapObjectsFactory::newSoapFault( 'Client', 'Unable to find an attachment with type ' . $p_type. ' and id ' . $p_file_id . ' .' );
177177
}
178178

179179
$row = db_fetch_array( $result );
@@ -212,7 +212,7 @@ function mci_file_get( $p_file_id, $p_type, $p_user_id ) {
212212
if( file_exists( $t_diskfile ) ) {
213213
return mci_file_read_local( $t_diskfile ) ;
214214
} else {
215-
return new soap_fault( 'Client', '', 'Unable to find an attachment with type ' . $p_type. ' and id ' . $p_file_id . ' .' );
215+
return SoapObjectsFactory::newSoapFault( 'Client', 'Unable to find an attachment with type ' . $p_type. ' and id ' . $p_file_id . ' .' );
216216
}
217217
case FTP:
218218
if( file_exists( $t_diskfile ) ) {

‎api/soap/mc_filter_api.php

+3-27
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function mc_filter_get_issues( $p_username, $p_password, $p_project_id, $p_filte
6464
$t_filter = filter_db_get_filter( $p_filter_id );
6565
$t_filter_detail = explode( '#', $t_filter, 2 );
6666
if( !isset( $t_filter_detail[1] ) ) {
67-
return new soap_fault( 'Server', '', 'Invalid Filter' );
67+
return SoapObjectsFactory::newSoapFault( 'Server', 'Invalid Filter' );
6868
}
6969
$t_filter = unserialize( $t_filter_detail[1] );
7070
$t_filter = filter_ensure_valid_filter( $t_filter );
@@ -108,7 +108,7 @@ function mc_filter_get_issue_headers( $p_username, $p_password, $p_project_id, $
108108
$t_filter = filter_db_get_filter( $p_filter_id );
109109
$t_filter_detail = explode( '#', $t_filter, 2 );
110110
if( !isset( $t_filter_detail[1] ) ) {
111-
return new soap_fault( 'Server', '', 'Invalid Filter' );
111+
return SoapObjectsFactory::newSoapFault( 'Server', 'Invalid Filter' );
112112
}
113113
$t_filter = unserialize( $t_filter_detail[1] );
114114
$t_filter = filter_ensure_valid_filter( $t_filter );
@@ -121,31 +121,7 @@ function mc_filter_get_issue_headers( $p_username, $p_password, $p_project_id, $
121121
return $t_result;
122122

123123
foreach( $t_rows as $t_issue_data ) {
124-
$t_id = $t_issue_data->id;
125-
126-
$t_issue = array();
127-
128-
$t_issue['id'] = $t_id;
129-
$t_issue['view_state'] = $t_issue_data->view_state;
130-
$t_issue['last_updated'] = timestamp_to_iso8601( $t_issue_data->last_updated, false );
131-
132-
$t_issue['project'] = $t_issue_data->project_id;
133-
$t_issue['category'] = mci_get_category( $t_issue_data->category_id );
134-
$t_issue['priority'] = $t_issue_data->priority;
135-
$t_issue['severity'] = $t_issue_data->severity;
136-
$t_issue['status'] = $t_issue_data->status;
137-
138-
$t_issue['reporter'] = $t_issue_data->reporter_id;
139-
$t_issue['summary'] = $t_issue_data->summary;
140-
if( !empty( $t_issue_data->handler_id ) ) {
141-
$t_issue['handler'] = $t_issue_data->handler_id;
142-
}
143-
$t_issue['resolution'] = $t_issue_data->resolution;
144-
145-
$t_issue['attachments_count'] = count( mci_issue_get_attachments( $t_issue_data->id ) );
146-
$t_issue['notes_count'] = count( mci_issue_get_notes( $t_issue_data->id ) );
147-
148-
$t_result[] = $t_issue;
124+
$t_result[] = mci_issue_data_as_header_array($t_issue_data);
149125
}
150126

151127
return $t_result;

‎api/soap/mc_issue_api.php

+80-73
Large diffs are not rendered by default.

‎api/soap/mc_issue_attachment_api.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ function mc_issue_attachment_get( $p_username, $p_password, $p_issue_attachment_
2323
}
2424

2525
$t_file = mci_file_get( $p_issue_attachment_id, 'bug', $t_user_id );
26-
if ( get_class( (object) $t_file ) == 'soap_fault' ) {
26+
if ( SoapObjectsFactory::isSoapFault( $t_file ) ) {
2727
return $t_file;
2828
}
29-
return base64_encode( $t_file );
29+
return SoapObjectsFactory::encodeBinary( $t_file );
3030
}
3131

3232
/**

‎api/soap/mc_project_api.php

+53-68
Large diffs are not rendered by default.

‎api/soap/mc_project_attachment_api.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ function mc_project_attachment_get( $p_username, $p_password, $p_project_attachm
2323
}
2424

2525
$t_file = mci_file_get( $p_project_attachment_id, 'doc', $t_user_id );
26-
if ( get_class( (object) $t_file ) == 'soap_fault' ) {
26+
if ( SoapObjectsFactory::isSoapFault( $t_file ) ) {
2727
return $t_file;
2828
}
29-
return base64_encode( $t_file );
29+
return SoapObjectsFactory::encodeBinary( $t_file );
3030
}
3131

3232
/**
@@ -56,7 +56,7 @@ function mc_project_attachment_add( $p_username, $p_password, $p_project_id, $p_
5656
return mci_soap_fault_access_denied( $t_user_id );
5757
}
5858
if( is_blank( $p_title ) ) {
59-
return new soap_fault( 'Client', '', 'Title must not be empty.' );
59+
return SoapObjectsFactory::newSoapFault( 'Client', '', 'Title must not be empty.' );
6060
}
6161
return mci_file_add( $p_project_id, $p_name, $p_content, $p_file_type, 'project', $p_title, $p_description, $t_user_id );
6262
}

‎api/soap/mc_tag_api.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ function mc_tag_get_all( $p_username, $p_password, $p_page_number, $p_per_page)
4444
'name' => $t_tag_row['name'],
4545
'description' => $t_tag_row['description'],
4646
'user_id' => mci_account_get_array_by_id ( $t_tag_row['user_id'] ),
47-
'date_created' => timestamp_to_iso8601($t_tag_row['date_created'], false),
48-
'date_updated' => timestamp_to_iso8601($t_tag_row['date_updated'], false)
47+
'date_created' => SoapObjectsFactory::newDateTimeVar($t_tag_row['date_created']),
48+
'date_updated' => SoapObjectsFactory::newDateTimeVar($t_tag_row['date_updated'])
4949

5050
);
5151
}
@@ -77,15 +77,17 @@ function mc_tag_add( $p_username, $p_password, $p_tag ) {
7777

7878
$t_valid_matches = array();
7979

80+
$p_tag = SoapObjectsFactory::unwrapObject( $p_tag );
81+
8082
$t_tag_name = $p_tag['name'];
8183
$t_tag_description = array_key_exists('description', $p_tag) ? $p_tag['description'] : '';
8284

8385
if ( !tag_name_is_valid($t_tag_name, $t_valid_matches))
84-
return new soap_fault('client', '', 'Invalid tag name : "' . $t_tag_name .'"' );
86+
return SoapObjectsFactory::newSoapFault('Client', 'Invalid tag name : "' . $t_tag_name .'"' );
8587

8688
$t_matching_by_name = tag_get_by_name( $t_tag_name);
8789
if ( $t_matching_by_name != false )
88-
return new soap_fault('client', '', 'A tag with the same name already exists , id: ' . $t_matching_by_name['id']);
90+
return SoapObjectsFactory::newSoapFault('Client', 'A tag with the same name already exists , id: ' . $t_matching_by_name['id']);
8991

9092
return tag_create($t_tag_name, $t_user_id, $t_tag_description);
9193
}
@@ -111,7 +113,7 @@ function mc_tag_delete( $p_username, $p_password, $p_tag_id ) {
111113
return mci_soap_fault_access_denied( $t_user_id );
112114

113115
if ( ! tag_exists( $p_tag_id ) )
114-
return new soap_fault('Client', '', 'No tag with id ' . $p_tag_id);
116+
return SoapObjectsFactory::newSoapFault('Client', 'No tag with id ' . $p_tag_id);
115117

116118
return tag_delete( $p_tag_id );
117119
}
@@ -128,6 +130,8 @@ function mci_tag_set_for_issue ( $p_issue_id, $p_tags, $p_user_id ) {
128130
$t_attached_tag_ids[] = $t_attached_tag['id'];
129131

130132
foreach ( $p_tags as $t_tag ) {
133+
134+
$t_tag = SoapObjectsFactory::unwrapObject( $t_tag );
131135

132136
$t_submitted_tag_ids[] = $t_tag['id'];
133137

‎docbook/Admin_Guide/en-US/Configuration.xml

+14
Original file line numberDiff line numberDiff line change
@@ -3476,6 +3476,20 @@
34763476

34773477
</variablelist>
34783478
</section>
3479+
3480+
<section id="admin.config.soap">
3481+
<title>SOAP API</title>
3482+
<para>These options are used to control the behaviour of the MantisBT SOAP API and are usually configured in <literal>api/soap/mc_config_inc.php</literal>.</para>
3483+
<variablelist>
3484+
<varlistentry>
3485+
<term>$g_mc_use_nusoap</term>
3486+
<listitem>
3487+
<para>
3488+
Flag controlling the library to use for SOAP communication. When the native PHP extension is available this flag default to OFF, which means that nusoap will not used. The native extension has the advantage of being faster, more memory efficient and maintained to work with recent versions on PHP. When the extension is not available MantisBT falls back to using nusoap.</para>
3489+
</listitem>
3490+
</varlistentry>
3491+
</variablelist>
3492+
</section>
34793493

34803494
<section id="admin.config.mantistouch">
34813495
<title>MantisTouch</title>

0 commit comments

Comments
 (0)
Please sign in to comment.