View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0012360 | mantisbt | api soap | public | 2010-09-16 07:59 | 2010-12-17 04:37 |
Reporter | petertc | Assigned To | rombert | ||
Priority | normal | Severity | feature | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Product Version | 1.2.3 | ||||
Target Version | 1.2.4 | Fixed in Version | 1.2.4 | ||
Summary | 0012360: [PATCH] Get id of project with specified name via SOAP API | ||||
Description | This patch add ability to get project id from project name. Without this patch, people who want to check whether the project is exist need using mc_projects_get_user_accessible to get all projects and using for loop to check. It exhaust much memory and is slow. Attach is my patch in git format. | ||||
Tags | No tags attached. | ||||
Attached Files | feature_branch.patch (2,651 bytes)
From 20ace2c5b351e59185fcbccd2c0ade042bcf41fd Mon Sep 17 00:00:00 2001 From: petertc <petertc.chu@gmail.com> Date: Thu, 16 Sep 2010 19:45:19 +0800 Subject: [PATCH] Get the id of project with the specified name via SOAP API --- api/soap/mantisconnect.php | 15 +++++++++++++++ api/soap/mc_project_api.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-) diff --git a/api/soap/mantisconnect.php b/api/soap/mantisconnect.php index cbe655a..5505a6c 100644 --- a/api/soap/mantisconnect.php +++ b/api/soap/mantisconnect.php @@ -1017,6 +1017,21 @@ $l_oServer->register( 'mc_project_update', 'Update a specific project to the tracker (must have admin privileges)' ); +### mc_project_get_id_from_name +$l_oServer->register( 'mc_project_get_id_from_name', + array( + 'username' => 'xsd:string', + 'password' => 'xsd:string', + 'project_name' => 'xsd:string' + ), + array( + 'return' => 'xsd:integer' + ), + $t_namespace, + false, false, false, + 'Get the id of the project with the specified name.' +); + ### mc_project_get_issues $l_oServer->register( 'mc_project_get_issues', array( diff --git a/api/soap/mc_project_api.php b/api/soap/mc_project_api.php index 42388ad..2bdc1c7 100644 --- a/api/soap/mc_project_api.php +++ b/api/soap/mc_project_api.php @@ -652,6 +652,38 @@ function mci_project_as_array_by_id( $p_project_id ) { return $t_result; } +/** + * Get the id of a project via the project's name. + * + * @param string $p_username The name of the user trying to access the versions. + * @param string $p_password The password of the user. + * @param string $p_project_name The name of the project to retrieve. + * @return integer The id of the project with the given name, -1 if there is no such project. + */ +function mc_project_get_id_from_name( $p_username, $p_password, $p_project_name ) { + $t_user_id = mci_check_login( $p_username, $p_password ); + if( $t_user_id === false ) { + return mci_soap_fault_login_failed(); + } + + $t_project_table = db_get_table( 'mantis_project_table' ); + + $query = "SELECT id + FROM $t_project_table + WHERE name = " . db_param(); + + $result = db_query_bound( $query, Array( $p_project_name ), 1 ); + + if( db_num_rows( $result ) == 0 ) { + return -1; + } else { + $row = db_fetch_array( $result ); + $t_project_id = (int) $row['id']; + return $t_project_id; + } +} + + ### MantisConnect Administrative Webservices ### /** -- 1.7.0.4 | ||||
Thanks for the patch. Can you please add a test as well? See tests/soap for some examples. |
|
I add a test case in the second attach. |
|
Applied, with a couple of fixes:
Sorry for the delay. |
|
MantisBT: master ec53b72a 2010-09-16 07:45 Committer: rombert Details Diff |
Get the id of project with the specified name via SOAP API Fixes 0012360: [PATCH] Get id of project with specified name via SOAP API Signed-off-by: Robert Munteanu <robert.munteanu@gmail.com> |
Affected Issues 0012360 |
|
mod - api/soap/mantisconnect.php | Diff File | ||
mod - tests/soap/ProjectTest.php | Diff File | ||
mod - api/soap/mc_project_api.php | Diff File | ||
MantisBT: master-1.2.x a9b22d80 2010-09-16 07:45 Committer: rombert Details Diff |
Get the id of project with the specified name via SOAP API Fixes 0012360: [PATCH] Get id of project with specified name via SOAP API Signed-off-by: Robert Munteanu <robert.munteanu@gmail.com> |
Affected Issues 0012360 |
|
mod - api/soap/mantisconnect.php | Diff File | ||
mod - tests/soap/ProjectTest.php | Diff File | ||
mod - api/soap/mc_project_api.php | Diff File |