View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0012009 | mantisbt | api soap | public | 2010-06-08 12:02 | 2018-05-20 06:58 |
| Reporter | dominik | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | feedback | Resolution | open | ||
| Product Version | 1.2.1 | ||||
| Summary | 0012009: Some improvements in SOAP API | ||||
| Description | Attached a patch file with some SOAP API improvements... Unfortunately I had private files in theses commits so I had to manually remove files -> if you have problems to apply the patch please let me know (or if you know how I can exlude files when creating patches please let me know as well ;-)) Improvements done: translate_category_name_to_id(): check for category added - this allows to submit issues (mc_issue_add()) with category_id instead of category Fixed bug with access rights when adding issues with target_versions Added correction of time zone for due dates as config switch (in my installation the "correction" actually lead to wrong due dates)... | ||||
| Tags | patch | ||||
| Attached Files | 2010-06-08_soap_improvements.patch (5,333 bytes)
From ecab64156faf072cb5b5f859f031ef2773c79543 Mon Sep 17 00:00:00 2001
From: Dominik Blunk <dominik@blunk.ch>
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 <dominik@blunk.ch>
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;
} 2010-06-09_relationships_for_mc_issue_add.patch (1,101 bytes)
From 675bdf31c79bc85d3c448cfc9e1632695ba1a2bd Mon Sep 17 00:00:00 2001
From: Dominik Blunk <dominik@blunk.ch>
Date: Tue, 1 Jun 2010 12:40:31 +0200
Subject: [PATCH 07/19] Added relationships to mc_issue_add()
---
api/soap/mc_issue_api.php | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php
index 8eb4b9a..b4d25d1 100644
--- a/api/soap/mc_issue_api.php
+++ b/api/soap/mc_issue_api.php
@@ -587,6 +587,13 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) {
$t_issue_id = $t_bug_data->create();
mci_issue_set_custom_fields( $t_issue_id, $p_issue['custom_fields'], false );
+
+ // 2010-05-30 Dominik: add relationship
+ if ( is_array( $p_issue['relationships'] ) && count( $p_issue['relationships'] ) > 0 ) {
+ foreach ($p_issue['relationships'] as &$relationship) {
+ mc_issue_relationship_add( $p_username, $p_password, $t_issue_id, $relationship );
+ }
+ }
if( isset( $t_notes ) && is_array( $t_notes ) ) {
foreach( $t_notes as $t_note ) {
--
1.7.0.2.msysgit.0 | ||||
|
Thanks! I'll take a look during the next week. |
|
|
Just added another small patch which allows to submit relationships when calling mc_issue_add() (no need to add relationships separately afterwards)... Thanks for looking into the code! |
|
|
Hi Dominik, Sorry for the late reply, here are my comments:
Please reply with any questions you might have. Thanks, Robert |
|
|
Unassigned after a long time of inactivity. |
|