diff -rU5 mantisbt-1.2.14/api/soap/mantisconnect.wsdl mantisbt-1.2.14-wepl/api/soap/mantisconnect.wsdl
--- mantisbt-1.2.14/api/soap/mantisconnect.wsdl 2013-01-22 15:07:11.000000000 +0100
+++ mantisbt-1.2.14-wepl/api/soap/mantisconnect.wsdl 2013-02-01 20:12:07.000000000 +0100
@@ -28,10 +28,11 @@
+
@@ -190,10 +191,11 @@
+
@@ -756,10 +758,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1081,10 +1103,25 @@
Deletes a tag.
+
+ Add a new user to the tracker (must have admin privileges).
+
+
+
+
+ Add a user to a project with access level.
+
+
+
+
+ Get the list of name/id of projects that are accessible to the logged in user.
+
+
+
@@ -1409,12 +1446,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff -rU5 mantisbt-1.2.14/api/soap/mc_account_api.php mantisbt-1.2.14-wepl/api/soap/mc_account_api.php
--- mantisbt-1.2.14/api/soap/mc_account_api.php 2013-01-22 15:07:11.000000000 +0100
+++ mantisbt-1.2.14-wepl/api/soap/mc_account_api.php 2013-02-02 12:32:50.000000000 +0100
@@ -35,5 +35,45 @@
$t_result[] = mci_account_get_array_by_id( $t_user_id );
}
return $t_result;
}
+
+/**
+* Add a new user.
+*
+* @param string $p_username The name of the user trying to create an account.
+* @param string $p_password The password of the user.
+* @param Array $p_user A new AccountData structure
+* @return integer The new users's users_id
+*/
+function mc_account_add( $p_username, $p_password, $p_user, $p_pass ) {
+ $t_user_id = mci_check_login( $p_username, $p_password );
+ if ( $t_user_id === false ) {
+ return mci_soap_fault_login_failed();
+ }
+ if ( !mci_has_administrator_access( $t_user_id ) ) {
+ return mci_soap_fault_access_denied( $t_user_id );
+ }
+
+ $p_user = SoapObjectsFactory::unwrapObject( $p_user );
+
+ // validate user attributes
+ if ( is_blank($p_user['name']) ) return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field "name" was missing');
+ if ( is_blank($p_user['real_name']) ) return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field "real_name" was missing');
+ if ( is_blank($p_user['email']) ) return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field "email" was missing');
+
+ if ( !user_is_name_valid( $p_user['name'] ) ) return SoapObjectsFactory::newSoapFault( 'Client', 'user name invalid');
+ if ( !user_is_name_unique( $p_user['name'] ) ) return SoapObjectsFactory::newSoapFault( 'Client', 'user name exists');
+ if ( !user_is_realname_valid( $p_user['real_name'] ) ) return SoapObjectsFactory::newSoapFault( 'Client', 'real name invalid');
+
+ // set defaults
+ if ( is_null( $p_user['access'] ) ) $p_user['access'] = VIEWER;
+
+ // create user account
+ if ( !user_create($p_user['name'], $p_pass, $p_user['email'], $p_user['access'], false, true, $p_user['real_name']))
+ return SoapObjectsFactory::newSoapFault( 'Client', 'user could not be created');
+
+ // return id of new user back to caller
+ return user_get_id_by_name($p_user['name']);
+}
+
diff -rU5 mantisbt-1.2.14/api/soap/mc_api.php mantisbt-1.2.14-wepl/api/soap/mc_api.php
--- mantisbt-1.2.14/api/soap/mc_api.php 2013-01-22 15:07:11.000000000 +0100
+++ mantisbt-1.2.14-wepl/api/soap/mc_api.php 2013-02-01 18:19:44.000000000 +0100
@@ -351,10 +351,24 @@
}
return $t_result;
}
+# Gets the name/id of all sub-projects that are accessible to the specified user / project.
+function mci_user_get_names_accessible_subprojects( $p_user_id, $p_parent_project_id ) {
+ $t_result = array();
+ foreach( user_get_accessible_subprojects( $p_user_id, $p_parent_project_id ) as $t_subproject_id ) {
+ $t_subproject_row = project_cache_row( $t_subproject_id );
+ $t_subproject = array();
+ $t_subproject['id'] = $t_subproject_id;
+ $t_subproject['name'] = $t_subproject_row['name'];
+ $t_subproject['subprojects'] = mci_user_get_names_accessible_subprojects( $p_user_id, $t_subproject_id );
+ $t_result[] = $t_subproject;
+ }
+ return $t_result;
+}
+
function translate_category_name_to_id( $p_category_name, $p_project_id ) {
if ( !isset( $p_category_name ) ) {
return 0;
}
diff -rU5 mantisbt-1.2.14/api/soap/mc_project_api.php mantisbt-1.2.14-wepl/api/soap/mc_project_api.php
--- mantisbt-1.2.14/api/soap/mc_project_api.php 2013-01-22 15:07:11.000000000 +0100
+++ mantisbt-1.2.14-wepl/api/soap/mc_project_api.php 2013-02-01 20:56:52.000000000 +0100
@@ -78,10 +78,42 @@
return $t_result;
}
/**
+ * Get (only) the id and name for all projects accessible by the given user.
+ *
+ * @param string $p_username The name of the user trying to access the project list.
+ * @param string $p_password The password of the user.
+ * @return Array suitable to be converted into a ProjectDataArray
+ */
+function mc_projects_get_names_user_accessible( $p_username, $p_password ) {
+ $t_user_id = mci_check_login( $p_username, $p_password );
+ if( $t_user_id === false ) {
+ return mci_soap_fault_login_failed();
+ }
+
+ if( !mci_has_readonly_access( $t_user_id ) ) {
+ return mci_soap_fault_access_denied( $t_user_id );
+ }
+
+ $t_lang = mci_get_user_lang( $t_user_id );
+
+ $t_result = array();
+ foreach( user_get_accessible_projects( $t_user_id ) as $t_project_id ) {
+ $t_project_row = project_cache_row( $t_project_id );
+ $t_project = array();
+ $t_project['id'] = $t_project_id;
+ $t_project['name'] = $t_project_row['name'];
+ $t_project['subprojects'] = mci_user_get_names_accessible_subprojects( $t_user_id, $t_project_id, $t_lang );
+ $t_result[] = $t_project;
+ }
+
+ return $t_result;
+}
+
+/**
* Get all categories of a project.
*
* @param string $p_username The name of the user trying to access the categories.
* @param string $p_password The password of the user.
* @param integer $p_project_id The id of the project to retrieve the categories for.
@@ -739,20 +771,41 @@
$t_inherit_global = $p_project['inherit_global'];
} else {
$t_inherit_global = true;
}
+ if ( isset( $p_project['parent_id'] ) ) {
+ $t_parent_id = $p_project['parent_id'];
+ if ( !project_exists( $t_parent_id ) ) {
+ return SoapObjectsFactory::newSoapFault( 'Client', 'Parent project does not exist');
+ }
+ } else {
+ $t_parent_id = false;
+ }
+
// check to make sure project doesn't already exist
if( !project_is_name_unique( $t_name ) ) {
return SoapObjectsFactory::newSoapFault( 'Client', 'Project name exists');
}
$t_project_status = mci_get_project_status_id( $t_status );
$t_project_view_state = mci_get_project_view_state_id( $t_view_state );
// project_create returns the new project's id, spit that out to webservice caller
- return project_create( $t_name, $t_description, $t_project_status, $t_project_view_state, $t_file_path, $t_enabled, $t_inherit_global );
+ $t_project_id = project_create( $t_name, $t_description, $t_project_status, $t_project_view_state, $t_file_path, $t_enabled, $t_inherit_global );
+
+ // link new project to a parent project, if one has been specified
+ if ( $t_parent_id ) {
+ // link to parent
+ project_hierarchy_add($t_project_id, $t_parent_id);
+
+ // copy custom fields from parent
+ project_copy_custom_fields($t_project_id, $t_parent_id);
+ }
+
+ // return id of new project back to caller
+ return $t_project_id;
}
/**
* Update a project
*
@@ -888,10 +941,43 @@
return $t_result;
}
/**
+ * Link a user to a project with a specified access level.
+ *
+ * @param string $p_username The name of the user trying to add the user (must be administrator)
+ * @param string $p_password The password of the user.
+ * @param integer $p_project_id The id of the project to link user to.
+ * @param integer $p_user_id The id of the user to link to the project.
+ * @param integer $p_access access level.
+ * @return bool returns true or false depending on the success of the action
+ */
+function mc_project_add_user( $p_username, $p_password, $p_project_id, $p_user_id, $p_access ) {
+ $t_user_id = mci_check_login( $p_username, $p_password );
+ if( $t_user_id === false ) {
+ return mci_soap_fault_login_failed();
+ }
+
+ if( !mci_has_administrator_access( $t_user_id ) ) {
+ return mci_soap_fault_access_denied( $t_user_id );
+ }
+
+ if ( !project_exists( $p_project_id ) ) {
+ return SoapObjectsFactory::newSoapFault( 'Client', "Project '$p_project_id' does not exist." );
+ }
+ if ( !user_exists( $p_user_id ) ) {
+ return SoapObjectsFactory::newSoapFault( 'Client', "User '$p_user_id' does not exist." );
+ }
+
+ // add the user to the project
+ $t_status = project_set_user_access( $p_project_id, $p_user_id, $p_access );
+
+ return $t_status;
+}
+
+/**
* Get appropriate users assigned to a project by access level.
*
* @param string $p_username The name of the user trying to access the versions.
* @param string $p_password The password of the user.
* @param integer $p_project_id The id of the project to retrieve the users for.