From ecab64156faf072cb5b5f859f031ef2773c79543 Mon Sep 17 00:00:00 2001 From: Dominik Blunk Date: Thu, 27 May 2010 11:44:33 +0200 Subject: [PATCH 03/19] SOAP Improvements: check for category id added and fix for access right (field target_version) --- api/soap/mc_api.php | 6 ++++++ api/soap/mc_issue_api.php | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/api/soap/mc_api.php b/api/soap/mc_api.php index bcd8cc4..6d795ad 100644 --- a/api/soap/mc_api.php +++ b/api/soap/mc_api.php @@ -228,6 +228,12 @@ function translate_category_name_to_id( $p_category_name, $p_project_id ) { return $t_category_row['id']; } } + // 2010-05-27 Dominik: no category found by name - check if we have already a valid category id given + foreach( $t_cat_array as $t_category_row ) { + if( $t_category_row['id'] == $p_category_name ) { + return $t_category_row['id']; + } + } return 0; } diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index f62a925..6ddb903 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -450,9 +450,9 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) { } $t_project = $p_issue['project']; - + $t_project_id = mci_get_project_id( $t_project ); - + if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) { return mci_soap_fault_access_denied( $t_user_id ); } @@ -567,8 +567,12 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) { } else { $t_bug_data->due_date = date_get_null(); } - + if( access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id, $t_user_id ) ) { + $GLOBALS['msg'][] = sprintf('$t_bug_data->target_version', ''); + // 2010-05-27 Dominik: because access rights for target version are checked again in BugData->__set() but no + // current project id may be determined via helper_get_current_project() it is required to set the project id here + $GLOBALS['g_project_override'] = $t_bug_data->project_id; $t_bug_data->target_version = isset( $p_issue['target_version'] ) ? $p_issue['target_version'] : ''; } @@ -579,7 +583,7 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) { $t_bug_data->description = $t_description; $t_bug_data->steps_to_reproduce = isset( $p_issue['steps_to_reproduce'] ) ? $p_issue['steps_to_reproduce'] : ''; $t_bug_data->additional_information = isset( $p_issue['additional_information'] ) ? $p_issue['additional_information'] : ''; - + # submit the issue $t_issue_id = $t_bug_data->create(); -- 1.7.0.2.msysgit.0 From 0095c702f977a510ed3426b9e87dedf8c565ac97 Mon Sep 17 00:00:00 2001 From: Dominik Blunk Date: Thu, 27 May 2010 16:34:51 +0200 Subject: [PATCH 04/19] Improvements in handling due date --- api/soap/mc_issue_api.php | 29 +++++++++++++++++++---------- config_inc.php | 15 +++++++++++---- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index 6ddb903..8eb4b9a 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -569,7 +569,6 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) { } if( access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id, $t_user_id ) ) { - $GLOBALS['msg'][] = sprintf('$t_bug_data->target_version', ''); // 2010-05-27 Dominik: because access rights for target version are checked again in BugData->__set() but no // current project id may be determined via helper_get_current_project() it is required to set the project id here $GLOBALS['g_project_override'] = $t_bug_data->project_id; @@ -1089,15 +1088,25 @@ function mc_issue_checkin( $p_username, $p_password, $p_issue_id, $p_comment, $p * @return int the timestamp */ function mci_iso8601_to_timestamp( $p_date ) { - - // retrieve the offset, seems to be lost by nusoap - $t_utc_date = new DateTime( $p_date, new DateTimeZone( 'UTC' ) ); - $t_timezone = new DateTimeZone( date_default_timezone_get() ); - $t_offset = $t_timezone->getOffset( $t_utc_date ); - - $t_raw_timestamp = iso8601_to_timestamp( $p_date ); - - return $t_raw_timestamp - $t_offset; + // 2010-05-27 Dominik: if p_date is empty we return default null date (otherwise we'll get current date) + if ( empty($p_date) ) { + return date_get_null(); + } + // 2010-05-27 Dominik: correction of time zone configurable + if ( config_get( 'due_date_timezone_correction' ) ) { + // retrieve the offset, seems to be lost by nusoap + $t_utc_date = new DateTime( $p_date, new DateTimeZone( 'UTC' ) ); + $t_timezone = new DateTimeZone( date_default_timezone_get() ); + $t_offset = $t_timezone->getOffset( $t_utc_date ); + $t_raw_timestamp = iso8601_to_timestamp( $p_date ); + $t_final_timestamp = $t_raw_timestamp - $t_offset; + } + else { + $t_final_timestamp = new DateTime( $p_date ); + $t_final_timestamp = $t_final_timestamp->format('U'); + } + // 2010-05-27 Dominik: if timestamp is <= 0 we return default null date (otherwise we'll get unix zero date which is 1970-01-01) + return $t_final_timestamp <= 0 ? date_get_null() : $t_final_timestamp; }