View Issue Details

IDProjectCategoryView StatusLast Update
0012613mantisbtapi soappublic2011-04-05 14:23
Reporternerville Assigned Torombert  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Versiongit trunk 
Target Version1.2.5Fixed in Version1.2.5 
Summary0012613: [patch]: Get list of subprojects ID for a specific project
Description

Please find as attachment a patch to add ability to get the list of subprojects ID for a specific project using SOAP API.

Currently, the SOAP API in master-1.2.x, neither master is not providing such functions.

My patch (git format) does not include PHPUnit tests. Because currently SOAP API does not offer capability to deal with hierarchy yet.

My patch is for master branch.

Tagspatch
Attached Files
api.soap.feature-get.subprojects.id-git.patch (2,199 bytes)   
From b29556ed579f1ae515310e7e9827418179c54918 Mon Sep 17 00:00:00 2001
From: Franck Villaume <franck.villaume@capgemini.com>
Date: Thu, 16 Dec 2010 11:25:59 +0100
Subject: [PATCH] new feature: get all subprojects Id of a specific project using SOAP API

---
 api/soap/mantisconnect.php  |   19 +++++++++++++++++--
 api/soap/mc_project_api.php |    9 +++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/api/soap/mantisconnect.php b/api/soap/mantisconnect.php
index 540e888..cfb5ea7 100644
--- a/api/soap/mantisconnect.php
+++ b/api/soap/mantisconnect.php
@@ -1269,8 +1269,7 @@ $l_oServer->register( 'mc_project_get_attachments',
 	'Get the attachments that belong to the specified project.'
 );
 
-## mc_project_get_custom_fields
-### mc_project_get_unreleased_versions
+### mc_project_get_custom_fields
 $l_oServer->register( 'mc_project_get_custom_fields',
 	array(
 		'username'		=>	'xsd:string',
@@ -1335,6 +1334,22 @@ $l_oServer->register( 'mc_project_attachment_delete',
 	'Delete the project attachment with the specified id.'
 );
 
+### mc_project_get_subprojects
+$l_oServer->register( 'mc_project_get_all_subprojects',
+    array(
+        'username'    =>  'xsd:string',
+        'password'    =>  'xsd:string',
+        'project_id'  =>  'xsd:integer'
+    ),
+    array(
+        'return'      =>  'tns:StringArray'
+    ),
+    $t_namespace,
+    false, false, false,
+    'Get the subprojects ID of a specific project.'
+);
+
+
 ###
 ###  PUBLIC METHODS (defined in mc_filter_api.php)
 ###
diff --git a/api/soap/mc_project_api.php b/api/soap/mc_project_api.php
index ff1f6dd..837ea73 100644
--- a/api/soap/mc_project_api.php
+++ b/api/soap/mc_project_api.php
@@ -639,6 +639,15 @@ function mc_project_get_attachments( $p_username, $p_password, $p_project_id ) {
 	return $t_result;
 }
 
+function mc_project_get_all_subprojects( $p_username, $p_password, $p_project_id ) {
+    $t_user_id = mci_check_login( $p_username, $p_password );
+
+   if( $t_user_id === false ) {
+       return new soap_fault( 'Client', '', 'Access Denied' );
+    }
+    return project_hierarchy_get_all_subprojects($p_project_id);
+}
+
 /**
  * Get a project definition.
  *
-- 
1.7.3

Activities

rombert

rombert

2010-12-16 06:14

reporter   ~0027616

Thanks for the patch.

Does the patch check if the user has access to see those projects?

As for tests, you could add at least a call to check that a call to the hierarchy returns just the project itself ( or no project, not sure what the current semantics are ).

nerville

nerville

2010-12-16 07:46

reporter   ~0027617

The patch use project_hierarchy_get_all_subprojects.
It can be replaced by user_get_all_accessible_subprojects
What is your opinion ?

About tests, I will follow your advice.

rombert

rombert

2010-12-16 18:53

reporter   ~0027623

user_get_all_accessible_subprojects looks fine to me. Please also check if the project exists and if the user has readonly soap access.

nerville

nerville

2010-12-17 09:31

reporter   ~0027635

why readonly soap access ?
Currently, soap api do a mci_check_login. Is it enough ? Or need something more ?
Or do you mean, user is project member check ?

nerville

nerville

2010-12-17 10:06

reporter   ~0027636

New patch uploaded including :

  • unit test
  • use of user_get_all_accessible_subprojects
  • check if project exists
  • check if user has readonly access.
rombert

rombert

2010-12-17 10:22

reporter   ~0027637

There is a check about SOAP readonly access, usually done in all other calls. This happens since there is a global access level which is enforced by the SOAP API.

nerville

nerville

2011-02-03 09:06

reporter   ~0028150

any update on this topic. My last patch should include all fixes needed.

rombert

rombert

2011-02-04 07:34

reporter   ~0028159

Sorry for not picking it up, but I'm really short on time right now. I will give it high priority when I have the time to process MantisBT patches.

Related Changesets

MantisBT: master-1.2.x d8d14a69

2010-12-16 05:25

nerville

Committer: rombert


Details Diff
New feature: get all subprojects Id of a specific project using SOAP API

Fixes 0012613 : Get list of subprojects ID for a specific project

Signed-off-by: Robert Munteanu <robert.munteanu@gmail.com>
Affected Issues
0012613
mod - api/soap/mc_project_api.php Diff File
mod - tests/soap/ProjectTest.php Diff File
mod - api/soap/mantisconnect.php Diff File

MantisBT: master d8864797

2010-12-16 05:25

nerville

Committer: rombert


Details Diff
New feature: get all subprojects Id of a specific project using SOAP API

Fixes 0012613 : Get list of subprojects ID for a specific project

Signed-off-by: Robert Munteanu <robert.munteanu@gmail.com>
Affected Issues
0012613
mod - tests/soap/ProjectTest.php Diff File
mod - api/soap/mc_project_api.php Diff File
mod - api/soap/mantisconnect.php Diff File