2014-12-22 20:31 EST

View Issue Details Jump to Notes ] Wiki ]
IDProjectCategoryView StatusLast Update
0010349mantisbtapi soappublic2014-01-23 17:51
ReporterWepl 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusconfirmedResolutionopen 
Product Version1.2.0a3 
Target VersionFixed in Version 
Summary0010349: additions to api soap, user add, sub projects
Descriptionfor importing a lot of bugs collected in plain text files the api soap should be used to get them info mantisbt
some functions were missing, some function missed functionality

this is a request that the changes made could be included into next mantisbt release

the following changes were made (with files modified):

- new soap-api function mc_account_add to add user accounts
        api/soap/mantisconnect.php
        api/soap/mc_account_api.php

- new soap-api function mc_project_add_user to add a user to a project with access level
        api/soap/mantisconnect.php
        api/soap/mc_project_api.php

- new soap-api function mc_projects_get_names_user_accessible to get a list of projects, but in difference to mc_projects_get_user_accessible it returns only the name and id for the projects, this was necessary because the original function caused 'out of memory' errors with the required amount of >2000 projects
        api/soap/mantisconnect.php
        api/soap/mc_api.php
        api/soap/mc_project_api.php

- possebility added to set the date_submitted via the function mc_issue_add, previously this was always set to db_now()
        api/soap/mc_issue_api.php
        core/bug_api.php

- error handling fixed in mc_issue_add, now it returns an error if adding custom fields have failed, previously this was unhandled
        api/soap/mc_issue_api.php

- function mc_project_add now supports to add a project as a sub project
        api/soap/mc_project_api.php

the attached file contains a diff, a list of changes and all changed files derived from release 1.2.0a3
Tagspatch
Attached Files
  • zip file icon patch-wepl.zip (40,192 bytes) 2009-04-20 16:18
  • diff file icon mantisbt-1.2.1-wepl-10349.diff (16,253 bytes) 2010-05-01 16:27 - 
    diff -rU5 mantisbt-1.2.1/api/soap/mantisconnect.php mantisbt-1.2.1-wepl/api/soap/mantisconnect.php
    --- mantisbt-1.2.1/api/soap/mantisconnect.php	2010-04-23 20:28:34.000000000 +0200
    +++ mantisbt-1.2.1-wepl/api/soap/mantisconnect.php	2010-05-01 20:11:00.000000000 +0200
    @@ -82,11 +82,12 @@
     	'',
     	array(
     		'id'		=>	array( 'name' => 'id',			'type' => 'xsd:integer',	'minOccurs' => '0'),
     		'name'		=>	array( 'name' => 'name',		'type' => 'xsd:string',	'minOccurs' => '0'),
     		'real_name'	=>	array( 'name' => 'real_name',	'type' => 'xsd:string',	'minOccurs' => '0'),
    -		'email'		=>	array( 'name' => 'email',		'type' => 'xsd:string',	'minOccurs' => '0')
    +		'email'		=>	array( 'name' => 'email',		'type' => 'xsd:string',	'minOccurs' => '0'),
    +		'access'	=>	array( 'name' => 'access',		'type' => 'xsd:integer','minOccurs' => '0')
     	)
     );
     
     ### AccountDataArray
     $l_oServer->wsdl->addComplexType(
    @@ -347,10 +348,11 @@
     	'struct',
     	'all',
     	'',
     	array(
     		'id'			=>	array( 'name' => 'id',			'type' => 'xsd:integer',	'minOccurs' => '0' ),
    +		'parent_id'		=>	array( 'name' => 'parent_id',	'type' => 'xsd:integer',	'minOccurs' => '0' ),
     		'name'			=>	array( 'name' => 'name',		'type' => 'xsd:string',	'minOccurs' => '0' ),
     		'status'		=>	array( 'name' => 'status',		'type' => 'tns:ObjectRef',	'minOccurs' => '0' ),
     		'enabled'		=>	array( 'name' => 'enabled',		'type' => 'xsd:boolean',	'minOccurs' => '0' ),
     		'view_state'	=>	array( 'name' => 'view_state',	'type' => 'tns:ObjectRef',	'minOccurs' => '0' ),
     		'access_min'	=>	array( 'name' => 'access_min',	'type' => 'tns:ObjectRef',	'minOccurs' => '0' ),
    @@ -960,10 +962,30 @@
     	false, false, false,
     	'Get the data for the specified issue attachment.'
     );
     
     ###
    +###  PUBLIC METHODS (defined in mc_account_api.php)
    +###
    +
    +### mc_account_add
    +$l_oServer->register( 'mc_account_add',
    +	array(
    +		'username' => 'xsd:string',
    +		'password' => 'xsd:string',
    +		'account' => 'tns:AccountData',
    +		'account_password' => 'xsd:string'
    +	),
    +	array(
    +		'return' => 'xsd:integer'
    +	),
    +	$t_namespace,
    +	false, false, false,
    +	'Add a new user to the tracker (must have admin privileges)'
    +);
    +
    +###
     ###  PUBLIC METHODS (defined in mc_project_api.php)
     ###
     
     ### mc_project_add
     $l_oServer->register( 'mc_project_add',
    @@ -1027,10 +1049,27 @@
     	$t_namespace,
     	false, false, false,
     	'Get the issue headers that match the specified project id and paging details.'
     );
     
    +### mc_project_add_user
    +$l_oServer->register( 'mc_project_add_user',
    +	array(
    +		'username'	=>	'xsd:string',
    +		'password'	=>	'xsd:string',
    +		'project_id'	=>	'xsd:integer',
    +		'user_id'	=>	'xsd:integer',
    +		'access'	=>	'xsd:integer'
    +	),
    +	array(
    +		'return'	=>	'xsd:integer'
    +	),
    +	$t_namespace,
    +	false, false, false,
    +	'Add a user to a project with access level.'
    +);
    +
     ### mc_project_get_users
     $l_oServer->register( 'mc_project_get_users',
     	array(
     		'username'	=>	'xsd:string',
     		'password'	=>	'xsd:string',
    @@ -1057,10 +1096,24 @@
     	$t_namespace,
     	false, false, false,
     	'Get the list of projects that are accessible to the logged in user.'
     );
     
    +### mc_projects_get_names_user_accessible
    +$l_oServer->register( 'mc_projects_get_names_user_accessible',
    +	array(
    +		'username'	=>	'xsd:string',
    +		'password'	=>	'xsd:string'
    +	),
    +	array(
    +		'return'	=>	'tns:ProjectDataArray'
    +	),
    +	$t_namespace,
    +	false, false, false,
    +	'Get the list of name/id of projects that are accessible to the logged in user.'
    +);
    +
     ### mc_project_get_categories
     $l_oServer->register( 'mc_project_get_categories',
     	array(
     		'username'		=>	'xsd:string',
     		'password'		=>	'xsd:string',
    diff -rU5 mantisbt-1.2.1/api/soap/mc_account_api.php mantisbt-1.2.1-wepl/api/soap/mc_account_api.php
    --- mantisbt-1.2.1/api/soap/mc_account_api.php	2010-04-23 20:28:33.000000000 +0200
    +++ mantisbt-1.2.1-wepl/api/soap/mc_account_api.php	2010-05-01 20:11:00.000000000 +0200
    @@ -24,5 +24,46 @@
     			$t_result['email'] = $t_dummy;
     		}
     	}
     	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 new soap_fault( 'Client', '', 'Access Denied', 'Username/password combination was incorrect');
    +	}
    +
    +	if ( !mci_has_administrator_access( $t_user_id ) ) {
    +		return new soap_fault( 'Client', '', 'Access Denied', 'User does not have administrator access');
    +	}
    +
    +	extract( $p_user, EXTR_PREFIX_ALL, 'v');
    +
    +	// validate user object
    +	if ( is_blank($v_name) ) return new soap_fault('Client', '', 'Mandatory field "name" was missing');
    +	if ( is_blank($v_real_name) ) return new soap_fault('Client', '', 'Mandatory field "real_name" was missing');
    +	if ( is_blank($v_email) ) return new soap_fault('Client', '', 'Mandatory field "email" was missing');
    +
    +	if ( !user_is_name_valid( $v_name ) ) return new soap_fault( 'Client', '', 'user name invalid');
    +	if ( !user_is_name_unique( $v_name ) ) return new soap_fault( 'Client', '', 'user name exists');
    +	if ( !user_is_realname_valid( $v_real_name ) ) return new soap_fault( 'Client', '', 'real name invalid');
    +
    +	// set defaults
    +	if ( is_null( $v_access ) ) $v_access = VIEWER;
    +
    +	// create user account and get it's id
    +	user_create($v_name, $p_pass, $v_email, $v_access, false, true, $v_real_name);
    +	$t_user_id = user_get_id_by_name($v_name);
    +
    +	// return id of new user back to caller
    +	return $t_user_id;
    +}
    +
    diff -rU5 mantisbt-1.2.1/api/soap/mc_api.php mantisbt-1.2.1-wepl/api/soap/mc_api.php
    --- mantisbt-1.2.1/api/soap/mc_api.php	2010-04-23 20:28:34.000000000 +0200
    +++ mantisbt-1.2.1-wepl/api/soap/mc_api.php	2010-05-01 20:11:00.000000000 +0200
    @@ -215,10 +215,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.1/api/soap/mc_issue_api.php mantisbt-1.2.1-wepl/api/soap/mc_issue_api.php
    --- mantisbt-1.2.1/api/soap/mc_issue_api.php	2010-04-23 20:28:34.000000000 +0200
    +++ mantisbt-1.2.1-wepl/api/soap/mc_issue_api.php	2010-05-01 20:11:00.000000000 +0200
    @@ -515,11 +515,12 @@
     			return new soap_fault( 'Client', '', "Category '" . $p_issue['category'] . "' not found for project '$t_project_id'." );
     		}
     	}
     
     	if ( isset( $p_issue['version'] ) && !is_blank( $p_issue['version'] ) && !version_get_id( $p_issue['version'], $t_project_id ) ) {
    -		$t_version = $p_issue['version'];
    +		$t_date_submitted = $p_issue['date_submitted'];
    +		$t_version = isset($p_issue['version']) ? $p_issue['version'] : '';
     
     		$t_error_when_version_not_found = config_get( 'mc_error_when_version_not_found' );
     		if( $t_error_when_version_not_found == ON ) {
     			$t_project_name = project_get_name( $t_project_id );
     			return new soap_fault( 'Client', '', "Version '$t_version' does not exist in project '$t_project_name'." );
    @@ -581,11 +582,14 @@
     	$t_bug_data->additional_information = isset( $p_issue['additional_information'] ) ? $p_issue['additional_information'] : '';
     
     	# submit the issue
     	$t_issue_id = $t_bug_data->create();
     
    -	mci_issue_set_custom_fields( $t_issue_id, $p_issue['custom_fields'], false );
    +	$t_fault = mci_issue_set_custom_fields( $t_issue_id, $p_issue['custom_fields'], false );
    +    if ($t_fault) {
    +		return new soap_fault( 'Client', '', "mci_issue_set_custom_fields failed" . $t_fault );
    +    }
     
     	if( isset( $t_notes ) && is_array( $t_notes ) ) {
     		foreach( $t_notes as $t_note ) {
     			if( isset( $t_note['view_state'] ) ) {
     				$t_view_state = $t_note['view_state'];
    @@ -725,11 +729,11 @@
     	$t_bug_data->reproducibility = $t_reproducibility_id;
     	$t_bug_data->status = $t_status_id;
     	$t_bug_data->resolution = $t_resolution_id;
     	$t_bug_data->projection = $t_projection_id;
     	$t_bug_data->category_id = $t_category_id;
    -	$t_bug_data->date_submitted = isset( $v_date_submitted ) ? $v_date_submitted : '';
    +	$t_bug_data->date_submitted = $t_date_submitted;
     	$t_bug_data->last_updated = isset( $v_last_updated ) ? $v_last_updated : '';
     	$t_bug_data->eta = $t_eta_id;
     	$t_bug_data->os = $t_os;
     	$t_bug_data->os_build = $t_os_build;
     	$t_bug_data->platform = $t_platform;
    diff -rU5 mantisbt-1.2.1/api/soap/mc_project_api.php mantisbt-1.2.1-wepl/api/soap/mc_project_api.php
    --- mantisbt-1.2.1/api/soap/mc_project_api.php	2010-04-23 20:28:34.000000000 +0200
    +++ mantisbt-1.2.1-wepl/api/soap/mc_project_api.php	2010-05-01 20:11:00.000000000 +0200
    @@ -72,10 +72,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 new soap_fault( 'Client', '', 'Access Denied' );
    +	}
    +
    +	if( !mci_has_readonly_access( $t_user_id ) ) {
    +		return new soap_fault( 'Client', '', 'Access Denied' );
    +	}
    +
    +	$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.
    @@ -616,20 +648,42 @@
     		$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 new soap_fault( '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 new soap_fault( 'Client', '', 'Project name exists', 'The project name you attempted to add exists already' );
     	}
     
     	$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 );
    +	// project_create returns the new project's id
    +	$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;
    +
     }
     
     /**
      * Delete a project.
      *
    @@ -704,10 +758,42 @@
     
     	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 new soap_fault( 'Client', '', 'Access Denied' );
    +	}
    +	if ( !mci_has_administrator_access( $t_user_id ) ) {
    +		return new soap_fault( 'Client', '', 'Access Denied', 'User does not have administrator access');
    +	}
    +
    +	if ( !project_exists( $p_project_id ) ) {
    +		return new soap_fault( 'Client', '', "Project '$p_project_id' does not exist." );
    +	}
    +	if ( !user_exists( $p_user_id ) ) {
    +		return new soap_fault( '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.
    diff -rU5 mantisbt-1.2.1/core/bug_api.php mantisbt-1.2.1-wepl/core/bug_api.php
    --- mantisbt-1.2.1/core/bug_api.php	2010-04-23 20:28:34.000000000 +0200
    +++ mantisbt-1.2.1-wepl/core/bug_api.php	2010-05-01 20:11:00.000000000 +0200
    @@ -345,10 +345,12 @@
     			$t_status = config_get( 'bug_assigned_status' );
     		} else {
     			$t_status = $this->status;
     		}
     
    +		$c_date_submitted = !is_blank( $this->date_submitted ) ? $this->date_submitted : db_now();
    +
     		# Insert the rest of the data
     		$query = "INSERT INTO $t_bug_table
     					    ( project_id,reporter_id, handler_id,duplicate_id,
     					      priority,severity, reproducibility,status,
     					      resolution,projection, category_id,date_submitted,
    @@ -364,11 +366,11 @@
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ')';
     
    -		db_query_bound( $query, Array( $this->project_id, $this->reporter_id, $this->handler_id, $this->duplicate_id, $this->priority, $this->severity, $this->reproducibility, $t_status, $this->resolution, $this->projection, $this->category_id, db_now(), db_now(), $this->eta, $t_text_id, $this->os, $this->os_build, $this->platform, $this->version, $this->build, $this->profile_id, $this->summary, $this->view_state, $this->sponsorship_total, $this->sticky, $this->fixed_in_version, $this->target_version, $this->due_date ) );
    +		db_query_bound( $query, Array( $this->project_id, $this->reporter_id, $this->handler_id, $this->duplicate_id, $this->priority, $this->severity, $this->reproducibility, $t_status, $this->resolution, $this->projection, $this->category_id, $c_date_submitted, db_now(), $this->eta, $t_text_id, $this->os, $this->os_build, $this->platform, $this->version, $this->build, $this->profile_id, $this->summary, $this->view_state, $this->sponsorship_total, $this->sticky, $this->fixed_in_version, $this->target_version, $this->due_date ) );
     
     		$this->id = db_insert_id( $t_bug_table );
     
     		# log new bug
     		history_log_event_special( $this->id, NEW_BUG );
    
    diff file icon mantisbt-1.2.1-wepl-10349.diff (16,253 bytes) 2010-05-01 16:27 + 
  • diff file icon mantisbt-1.2.5-wepl-10349.diff (16,323 bytes) 2011-04-13 17:08 - 
    diff -rU5 mantisbt-1.2.5/api/soap/mantisconnect.php mantisbt-1.2.5-wepl/api/soap/mantisconnect.php
    --- mantisbt-1.2.5/api/soap/mantisconnect.php	2011-04-05 20:24:17.000000000 +0200
    +++ mantisbt-1.2.5-wepl/api/soap/mantisconnect.php	2011-04-12 09:17:29.000000000 +0200
    @@ -88,11 +88,12 @@
     	'',
     	array(
     		'id'		=>	array( 'name' => 'id',			'type' => 'xsd:integer',	'minOccurs' => '0'),
     		'name'		=>	array( 'name' => 'name',		'type' => 'xsd:string',	'minOccurs' => '0'),
     		'real_name'	=>	array( 'name' => 'real_name',	'type' => 'xsd:string',	'minOccurs' => '0'),
    -		'email'		=>	array( 'name' => 'email',		'type' => 'xsd:string',	'minOccurs' => '0')
    +		'email'		=>	array( 'name' => 'email',		'type' => 'xsd:string',	'minOccurs' => '0'),
    +		'access'	=>	array( 'name' => 'access',		'type' => 'xsd:integer','minOccurs' => '0')
     	)
     );
     
     ### AccountDataArray
     $l_oServer->wsdl->addComplexType(
    @@ -354,10 +355,11 @@
     	'struct',
     	'all',
     	'',
     	array(
     		'id'			=>	array( 'name' => 'id',			'type' => 'xsd:integer',	'minOccurs' => '0' ),
    +		'parent_id'		=>	array( 'name' => 'parent_id',	'type' => 'xsd:integer',	'minOccurs' => '0' ),
     		'name'			=>	array( 'name' => 'name',		'type' => 'xsd:string',	'minOccurs' => '0' ),
     		'status'		=>	array( 'name' => 'status',		'type' => 'tns:ObjectRef',	'minOccurs' => '0' ),
     		'enabled'		=>	array( 'name' => 'enabled',		'type' => 'xsd:boolean',	'minOccurs' => '0' ),
     		'view_state'	=>	array( 'name' => 'view_state',	'type' => 'tns:ObjectRef',	'minOccurs' => '0' ),
     		'access_min'	=>	array( 'name' => 'access_min',	'type' => 'tns:ObjectRef',	'minOccurs' => '0' ),
    @@ -968,10 +970,30 @@
     	false, false, false,
     	'Get the data for the specified issue attachment.'
     );
     
     ###
    +###  PUBLIC METHODS (defined in mc_account_api.php)
    +###
    +
    +### mc_account_add
    +$l_oServer->register( 'mc_account_add',
    +	array(
    +		'username' => 'xsd:string',
    +		'password' => 'xsd:string',
    +		'account' => 'tns:AccountData',
    +		'account_password' => 'xsd:string'
    +	),
    +	array(
    +		'return' => 'xsd:integer'
    +	),
    +	$t_namespace,
    +	false, false, false,
    +	'Add a new user to the tracker (must have admin privileges)'
    +);
    +
    +###
     ###  PUBLIC METHODS (defined in mc_project_api.php)
     ###
     
     ### mc_project_add
     $l_oServer->register( 'mc_project_add',
    @@ -1066,10 +1088,27 @@
     	$t_namespace,
     	false, false, false,
     	'Get the issue headers that match the specified project id and paging details.'
     );
     
    +### mc_project_add_user
    +$l_oServer->register( 'mc_project_add_user',
    +	array(
    +		'username'	=>	'xsd:string',
    +		'password'	=>	'xsd:string',
    +		'project_id'	=>	'xsd:integer',
    +		'user_id'	=>	'xsd:integer',
    +		'access'	=>	'xsd:integer'
    +	),
    +	array(
    +		'return'	=>	'xsd:integer'
    +	),
    +	$t_namespace,
    +	false, false, false,
    +	'Add a user to a project with access level.'
    +);
    +
     ### mc_project_get_users
     $l_oServer->register( 'mc_project_get_users',
     	array(
     		'username'	=>	'xsd:string',
     		'password'	=>	'xsd:string',
    @@ -1096,10 +1135,24 @@
     	$t_namespace,
     	false, false, false,
     	'Get the list of projects that are accessible to the logged in user.'
     );
     
    +### mc_projects_get_names_user_accessible
    +$l_oServer->register( 'mc_projects_get_names_user_accessible',
    +	array(
    +		'username'	=>	'xsd:string',
    +		'password'	=>	'xsd:string'
    +	),
    +	array(
    +		'return'	=>	'tns:ProjectDataArray'
    +	),
    +	$t_namespace,
    +	false, false, false,
    +	'Get the list of name/id of projects that are accessible to the logged in user.'
    +);
    +
     ### mc_project_get_categories
     $l_oServer->register( 'mc_project_get_categories',
     	array(
     		'username'		=>	'xsd:string',
     		'password'		=>	'xsd:string',
    diff -rU5 mantisbt-1.2.5/api/soap/mc_account_api.php mantisbt-1.2.5-wepl/api/soap/mc_account_api.php
    --- mantisbt-1.2.5/api/soap/mc_account_api.php	2011-04-05 20:24:16.000000000 +0200
    +++ mantisbt-1.2.5-wepl/api/soap/mc_account_api.php	2011-04-12 09:17:29.000000000 +0200
    @@ -35,5 +35,46 @@
             $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 new soap_fault( 'Client', '', 'Access Denied', 'Username/password combination was incorrect');
    +	}
    +
    +	if ( !mci_has_administrator_access( $t_user_id ) ) {
    +		return new soap_fault( 'Client', '', 'Access Denied', 'User does not have administrator access');
    +	}
    +
    +	extract( $p_user, EXTR_PREFIX_ALL, 'v');
    +
    +	// validate user object
    +	if ( is_blank($v_name) ) return new soap_fault('Client', '', 'Mandatory field "name" was missing');
    +	if ( is_blank($v_real_name) ) return new soap_fault('Client', '', 'Mandatory field "real_name" was missing');
    +	if ( is_blank($v_email) ) return new soap_fault('Client', '', 'Mandatory field "email" was missing');
    +
    +	if ( !user_is_name_valid( $v_name ) ) return new soap_fault( 'Client', '', 'user name invalid');
    +	if ( !user_is_name_unique( $v_name ) ) return new soap_fault( 'Client', '', 'user name exists');
    +	if ( !user_is_realname_valid( $v_real_name ) ) return new soap_fault( 'Client', '', 'real name invalid');
    +
    +	// set defaults
    +	if ( is_null( $v_access ) ) $v_access = VIEWER;
    +
    +	// create user account and get it's id
    +	user_create($v_name, $p_pass, $v_email, $v_access, false, true, $v_real_name);
    +	$t_user_id = user_get_id_by_name($v_name);
    +
    +	// return id of new user back to caller
    +	return $t_user_id;
    +}
    +
    diff -rU5 mantisbt-1.2.5/api/soap/mc_api.php mantisbt-1.2.5-wepl/api/soap/mc_api.php
    --- mantisbt-1.2.5/api/soap/mc_api.php	2011-04-05 20:24:17.000000000 +0200
    +++ mantisbt-1.2.5-wepl/api/soap/mc_api.php	2011-04-12 09:17:29.000000000 +0200
    @@ -207,10 +207,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.5/api/soap/mc_issue_api.php mantisbt-1.2.5-wepl/api/soap/mc_issue_api.php
    --- mantisbt-1.2.5/api/soap/mc_issue_api.php	2011-04-05 20:24:17.000000000 +0200
    +++ mantisbt-1.2.5-wepl/api/soap/mc_issue_api.php	2011-04-12 09:17:29.000000000 +0200
    @@ -576,11 +576,12 @@
     			return new soap_fault( 'Client', '', "Category '" . $p_issue['category'] . "' not found for project '$t_project_id'." );
     		}
     	}
     
     	if ( isset( $p_issue['version'] ) && !is_blank( $p_issue['version'] ) && !version_get_id( $p_issue['version'], $t_project_id ) ) {
    -		$t_version = $p_issue['version'];
    +		$t_date_submitted = $p_issue['date_submitted'];
    +		$t_version = isset($p_issue['version']) ? $p_issue['version'] : '';
     
     		$t_error_when_version_not_found = config_get( 'mc_error_when_version_not_found' );
     		if( $t_error_when_version_not_found == ON ) {
     			$t_project_name = project_get_name( $t_project_id );
     			return new soap_fault( 'Client', '', "Version '$t_version' does not exist in project '$t_project_name'." );
    @@ -642,11 +643,14 @@
     	$t_bug_data->additional_information = isset( $p_issue['additional_information'] ) ? $p_issue['additional_information'] : '';
     
     	# submit the issue
     	$t_issue_id = $t_bug_data->create();
     
    -	mci_issue_set_custom_fields( $t_issue_id, $p_issue['custom_fields'], false );
    +	$t_fault = mci_issue_set_custom_fields( $t_issue_id, $p_issue['custom_fields'], false );
    +    if ($t_fault) {
    +		return new soap_fault( 'Client', '', "mci_issue_set_custom_fields failed" . $t_fault );
    +    }
     	if ( isset ( $p_issue['monitors'] ) )
     	    mci_issue_set_monitors( $t_issue_id , $t_user_id, $p_issue['monitors'] );
     
     	if( isset( $t_notes ) && is_array( $t_notes ) ) {
     		foreach( $t_notes as $t_note ) {
    @@ -788,11 +792,11 @@
     	$t_bug_data->reproducibility = $t_reproducibility_id;
     	$t_bug_data->status = $t_status_id;
     	$t_bug_data->resolution = $t_resolution_id;
     	$t_bug_data->projection = $t_projection_id;
     	$t_bug_data->category_id = $t_category_id;
    -	$t_bug_data->date_submitted = isset( $v_date_submitted ) ? $v_date_submitted : '';
    +	$t_bug_data->date_submitted = $t_date_submitted;
     	$t_bug_data->last_updated = isset( $v_last_updated ) ? $v_last_updated : '';
     	$t_bug_data->eta = $t_eta_id;
     	$t_bug_data->os = $t_os;
     	$t_bug_data->os_build = $t_os_build;
     	$t_bug_data->platform = $t_platform;
    diff -rU5 mantisbt-1.2.5/api/soap/mc_project_api.php mantisbt-1.2.5-wepl/api/soap/mc_project_api.php
    --- mantisbt-1.2.5/api/soap/mc_project_api.php	2011-04-05 20:24:17.000000000 +0200
    +++ mantisbt-1.2.5-wepl/api/soap/mc_project_api.php	2011-04-12 09:17:29.000000000 +0200
    @@ -72,10 +72,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 new soap_fault( 'Client', '', 'Access Denied' );
    +	}
    +
    +	if( !mci_has_readonly_access( $t_user_id ) ) {
    +		return new soap_fault( 'Client', '', 'Access Denied' );
    +	}
    +
    +	$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.
    @@ -748,20 +780,42 @@
     		$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 new soap_fault( '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 new soap_fault( 'Client', '', 'Project name exists', 'The project name you attempted to add exists already' );
     	}
     
     	$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 );
    +	// project_create returns the new project's id
    +	$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
      *
    @@ -914,10 +968,42 @@
     
     	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 new soap_fault( 'Client', '', 'Access Denied' );
    +	}
    +	if ( !mci_has_administrator_access( $t_user_id ) ) {
    +		return new soap_fault( 'Client', '', 'Access Denied', 'User does not have administrator access');
    +	}
    +
    +	if ( !project_exists( $p_project_id ) ) {
    +		return new soap_fault( 'Client', '', "Project '$p_project_id' does not exist." );
    +	}
    +	if ( !user_exists( $p_user_id ) ) {
    +		return new soap_fault( '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.
    diff -rU5 mantisbt-1.2.5/core/bug_api.php mantisbt-1.2.5-wepl/core/bug_api.php
    --- mantisbt-1.2.5/core/bug_api.php	2011-04-05 20:24:17.000000000 +0200
    +++ mantisbt-1.2.5-wepl/core/bug_api.php	2011-04-12 09:17:29.000000000 +0200
    @@ -345,10 +345,12 @@
     			$t_status = config_get( 'bug_assigned_status' );
     		} else {
     			$t_status = $this->status;
     		}
     
    +		$c_date_submitted = !is_blank( $this->date_submitted ) ? $this->date_submitted : db_now();
    +
     		# Insert the rest of the data
     		$query = "INSERT INTO $t_bug_table
     					    ( project_id,reporter_id, handler_id,duplicate_id,
     					      priority,severity, reproducibility,status,
     					      resolution,projection, category_id,date_submitted,
    @@ -364,11 +366,11 @@
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ')';
     
    -		db_query_bound( $query, Array( $this->project_id, $this->reporter_id, $this->handler_id, $this->duplicate_id, $this->priority, $this->severity, $this->reproducibility, $t_status, $this->resolution, $this->projection, $this->category_id, db_now(), db_now(), $this->eta, $t_text_id, $this->os, $this->os_build, $this->platform, $this->version, $this->build, $this->profile_id, $this->summary, $this->view_state, $this->sponsorship_total, $this->sticky, $this->fixed_in_version, $this->target_version, $this->due_date ) );
    +		db_query_bound( $query, Array( $this->project_id, $this->reporter_id, $this->handler_id, $this->duplicate_id, $this->priority, $this->severity, $this->reproducibility, $t_status, $this->resolution, $this->projection, $this->category_id, $c_date_submitted, db_now(), $this->eta, $t_text_id, $this->os, $this->os_build, $this->platform, $this->version, $this->build, $this->profile_id, $this->summary, $this->view_state, $this->sponsorship_total, $this->sticky, $this->fixed_in_version, $this->target_version, $this->due_date ) );
     
     		$this->id = db_insert_id( $t_bug_table );
     
     		# log new bug
     		history_log_event_special( $this->id, NEW_BUG );
    
    diff file icon mantisbt-1.2.5-wepl-10349.diff (16,323 bytes) 2011-04-13 17:08 + 
  • diff file icon mantisbt-1.2.8-wepl-10349.diff (14,962 bytes) 2011-11-04 16:01 - 
    diff -rU5 mantisbt-1.2.8/api/soap/mantisconnect.php mantisbt-1.2.8-wepl/api/soap/mantisconnect.php
    --- mantisbt-1.2.8/api/soap/mantisconnect.php	2011-09-06 16:23:10.000000000 +0200
    +++ mantisbt-1.2.8-wepl/api/soap/mantisconnect.php	2011-09-11 19:41:48.000000000 +0200
    @@ -88,11 +88,12 @@
     	'',
     	array(
     		'id'		=>	array( 'name' => 'id',			'type' => 'xsd:integer',	'minOccurs' => '0'),
     		'name'		=>	array( 'name' => 'name',		'type' => 'xsd:string',	'minOccurs' => '0'),
     		'real_name'	=>	array( 'name' => 'real_name',	'type' => 'xsd:string',	'minOccurs' => '0'),
    -		'email'		=>	array( 'name' => 'email',		'type' => 'xsd:string',	'minOccurs' => '0')
    +		'email'		=>	array( 'name' => 'email',		'type' => 'xsd:string',	'minOccurs' => '0'),
    +		'access'	=>	array( 'name' => 'access',		'type' => 'xsd:integer','minOccurs' => '0')
     	)
     );
     
     ### AccountDataArray
     $l_oServer->wsdl->addComplexType(
    @@ -358,10 +359,11 @@
     	'struct',
     	'all',
     	'',
     	array(
     		'id'			=>	array( 'name' => 'id',			'type' => 'xsd:integer',	'minOccurs' => '0' ),
    +		'parent_id'		=>	array( 'name' => 'parent_id',	'type' => 'xsd:integer',	'minOccurs' => '0' ),
     		'name'			=>	array( 'name' => 'name',		'type' => 'xsd:string',	'minOccurs' => '0' ),
     		'status'		=>	array( 'name' => 'status',		'type' => 'tns:ObjectRef',	'minOccurs' => '0' ),
     		'enabled'		=>	array( 'name' => 'enabled',		'type' => 'xsd:boolean',	'minOccurs' => '0' ),
     		'view_state'	=>	array( 'name' => 'view_state',	'type' => 'tns:ObjectRef',	'minOccurs' => '0' ),
     		'access_min'	=>	array( 'name' => 'access_min',	'type' => 'tns:ObjectRef',	'minOccurs' => '0' ),
    @@ -988,10 +990,30 @@
     	false, false, false,
     	'Get the data for the specified issue attachment.'
     );
     
     ###
    +###  PUBLIC METHODS (defined in mc_account_api.php)
    +###
    +
    +### mc_account_add
    +$l_oServer->register( 'mc_account_add',
    +	array(
    +		'username' => 'xsd:string',
    +		'password' => 'xsd:string',
    +		'account' => 'tns:AccountData',
    +		'account_password' => 'xsd:string'
    +	),
    +	array(
    +		'return' => 'xsd:integer'
    +	),
    +	$t_namespace,
    +	false, false, false,
    +	'Add a new user to the tracker (must have admin privileges)'
    +);
    +
    +###
     ###  PUBLIC METHODS (defined in mc_project_api.php)
     ###
     
     ### mc_project_add
     $l_oServer->register( 'mc_project_add',
    @@ -1086,10 +1108,27 @@
     	$t_namespace,
     	false, false, false,
     	'Get the issue headers that match the specified project id and paging details.'
     );
     
    +### mc_project_add_user
    +$l_oServer->register( 'mc_project_add_user',
    +	array(
    +		'username'	=>	'xsd:string',
    +		'password'	=>	'xsd:string',
    +		'project_id'	=>	'xsd:integer',
    +		'user_id'	=>	'xsd:integer',
    +		'access'	=>	'xsd:integer'
    +	),
    +	array(
    +		'return'	=>	'xsd:integer'
    +	),
    +	$t_namespace,
    +	false, false, false,
    +	'Add a user to a project with access level.'
    +);
    +
     ### mc_project_get_users
     $l_oServer->register( 'mc_project_get_users',
     	array(
     		'username'	=>	'xsd:string',
     		'password'	=>	'xsd:string',
    @@ -1116,10 +1155,24 @@
     	$t_namespace,
     	false, false, false,
     	'Get the list of projects that are accessible to the logged in user.'
     );
     
    +### mc_projects_get_names_user_accessible
    +$l_oServer->register( 'mc_projects_get_names_user_accessible',
    +	array(
    +		'username'	=>	'xsd:string',
    +		'password'	=>	'xsd:string'
    +	),
    +	array(
    +		'return'	=>	'tns:ProjectDataArray'
    +	),
    +	$t_namespace,
    +	false, false, false,
    +	'Get the list of name/id of projects that are accessible to the logged in user.'
    +);
    +
     ### mc_project_get_categories
     $l_oServer->register( 'mc_project_get_categories',
     	array(
     		'username'		=>	'xsd:string',
     		'password'		=>	'xsd:string',
    diff -rU5 mantisbt-1.2.8/api/soap/mc_account_api.php mantisbt-1.2.8-wepl/api/soap/mc_account_api.php
    --- mantisbt-1.2.8/api/soap/mc_account_api.php	2011-09-06 16:23:09.000000000 +0200
    +++ mantisbt-1.2.8-wepl/api/soap/mc_account_api.php	2011-09-11 19:41:48.000000000 +0200
    @@ -35,5 +35,46 @@
             $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 new soap_fault( 'Client', '', 'Access Denied', 'Username/password combination was incorrect');
    +	}
    +
    +	if ( !mci_has_administrator_access( $t_user_id ) ) {
    +		return new soap_fault( 'Client', '', 'Access Denied', 'User does not have administrator access');
    +	}
    +
    +	extract( $p_user, EXTR_PREFIX_ALL, 'v');
    +
    +	// validate user object
    +	if ( is_blank($v_name) ) return new soap_fault('Client', '', 'Mandatory field "name" was missing');
    +	if ( is_blank($v_real_name) ) return new soap_fault('Client', '', 'Mandatory field "real_name" was missing');
    +	if ( is_blank($v_email) ) return new soap_fault('Client', '', 'Mandatory field "email" was missing');
    +
    +	if ( !user_is_name_valid( $v_name ) ) return new soap_fault( 'Client', '', 'user name invalid');
    +	if ( !user_is_name_unique( $v_name ) ) return new soap_fault( 'Client', '', 'user name exists');
    +	if ( !user_is_realname_valid( $v_real_name ) ) return new soap_fault( 'Client', '', 'real name invalid');
    +
    +	// set defaults
    +	if ( is_null( $v_access ) ) $v_access = VIEWER;
    +
    +	// create user account and get it's id
    +	user_create($v_name, $p_pass, $v_email, $v_access, false, true, $v_real_name);
    +	$t_user_id = user_get_id_by_name($v_name);
    +
    +	// return id of new user back to caller
    +	return $t_user_id;
    +}
    +
    diff -rU5 mantisbt-1.2.8/api/soap/mc_api.php mantisbt-1.2.8-wepl/api/soap/mc_api.php
    --- mantisbt-1.2.8/api/soap/mc_api.php	2011-09-06 16:23:10.000000000 +0200
    +++ mantisbt-1.2.8-wepl/api/soap/mc_api.php	2011-09-11 19:41:48.000000000 +0200
    @@ -207,10 +207,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.8/api/soap/mc_issue_api.php mantisbt-1.2.8-wepl/api/soap/mc_issue_api.php
    --- mantisbt-1.2.8/api/soap/mc_issue_api.php	2011-09-06 16:23:10.000000000 +0200
    +++ mantisbt-1.2.8-wepl/api/soap/mc_issue_api.php	2011-09-11 20:13:12.000000000 +0200
    @@ -645,11 +645,14 @@
     	$t_bug_data->additional_information = isset( $p_issue['additional_information'] ) ? $p_issue['additional_information'] : '';
     
     	# submit the issue
     	$t_issue_id = $t_bug_data->create();
     
    -	mci_issue_set_custom_fields( $t_issue_id, $p_issue['custom_fields'], false );
    +	$t_fault = mci_issue_set_custom_fields( $t_issue_id, $p_issue['custom_fields'], false );
    +    if ($t_fault) {
    +		return new soap_fault( 'Client', '', "mci_issue_set_custom_fields failed" . $t_fault );
    +    }
     	if ( isset ( $p_issue['monitors'] ) )
     	    mci_issue_set_monitors( $t_issue_id , $t_user_id, $p_issue['monitors'] );
     
     	if( isset( $t_notes ) && is_array( $t_notes ) ) {
     		foreach( $t_notes as $t_note ) {
    diff -rU5 mantisbt-1.2.8/api/soap/mc_project_api.php mantisbt-1.2.8-wepl/api/soap/mc_project_api.php
    --- mantisbt-1.2.8/api/soap/mc_project_api.php	2011-09-06 16:23:10.000000000 +0200
    +++ mantisbt-1.2.8-wepl/api/soap/mc_project_api.php	2011-09-11 19:41:48.000000000 +0200
    @@ -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 new soap_fault( 'Client', '', 'Access Denied' );
    +	}
    +
    +	if( !mci_has_readonly_access( $t_user_id ) ) {
    +		return new soap_fault( 'Client', '', 'Access Denied' );
    +	}
    +
    +	$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.
    @@ -732,20 +764,42 @@
     		$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 new soap_fault( '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 new soap_fault( 'Client', '', 'Project name exists', 'The project name you attempted to add exists already' );
     	}
     
     	$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 );
    +	// project_create returns the new project's id
    +	$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
      *
    @@ -903,10 +957,42 @@
     
     	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 new soap_fault( 'Client', '', 'Access Denied' );
    +	}
    +	if ( !mci_has_administrator_access( $t_user_id ) ) {
    +		return new soap_fault( 'Client', '', 'Access Denied', 'User does not have administrator access');
    +	}
    +
    +	if ( !project_exists( $p_project_id ) ) {
    +		return new soap_fault( 'Client', '', "Project '$p_project_id' does not exist." );
    +	}
    +	if ( !user_exists( $p_user_id ) ) {
    +		return new soap_fault( '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.
    diff -rU5 mantisbt-1.2.8/core/bug_api.php mantisbt-1.2.8-wepl/core/bug_api.php
    --- mantisbt-1.2.8/core/bug_api.php	2011-09-06 16:23:10.000000000 +0200
    +++ mantisbt-1.2.8-wepl/core/bug_api.php	2011-09-11 19:41:48.000000000 +0200
    @@ -345,10 +345,12 @@
     			$t_status = config_get( 'bug_assigned_status' );
     		} else {
     			$t_status = $this->status;
     		}
     
    +		$c_date_submitted = !is_blank( $this->date_submitted ) ? $this->date_submitted : db_now();
    +
     		# Insert the rest of the data
     		$query = "INSERT INTO $t_bug_table
     					    ( project_id,reporter_id, handler_id,duplicate_id,
     					      priority,severity, reproducibility,status,
     					      resolution,projection, category_id,date_submitted,
    @@ -364,11 +366,11 @@
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",
     					      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ')';
     
    -		db_query_bound( $query, Array( $this->project_id, $this->reporter_id, $this->handler_id, $this->duplicate_id, $this->priority, $this->severity, $this->reproducibility, $t_status, $this->resolution, $this->projection, $this->category_id, db_now(), db_now(), $this->eta, $t_text_id, $this->os, $this->os_build, $this->platform, $this->version, $this->build, $this->profile_id, $this->summary, $this->view_state, $this->sponsorship_total, $this->sticky, $this->fixed_in_version, $this->target_version, $this->due_date ) );
    +		db_query_bound( $query, Array( $this->project_id, $this->reporter_id, $this->handler_id, $this->duplicate_id, $this->priority, $this->severity, $this->reproducibility, $t_status, $this->resolution, $this->projection, $this->category_id, $c_date_submitted, db_now(), $this->eta, $t_text_id, $this->os, $this->os_build, $this->platform, $this->version, $this->build, $this->profile_id, $this->summary, $this->view_state, $this->sponsorship_total, $this->sticky, $this->fixed_in_version, $this->target_version, $this->due_date ) );
     
     		$this->id = db_insert_id( $t_bug_table );
     
     		# log new bug
     		history_log_event_special( $this->id, NEW_BUG );
    
    diff file icon mantisbt-1.2.8-wepl-10349.diff (14,962 bytes) 2011-11-04 16:01 + 
  • diff file icon mantisbt-1.2.14-wepl-10349.diff (14,670 bytes) 2013-02-02 10:56 - 
    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 @@
       <xsd:all>
        <xsd:element name="id" type="xsd:integer" minOccurs="0"/>
        <xsd:element name="name" type="xsd:string" minOccurs="0"/>
        <xsd:element name="real_name" type="xsd:string" minOccurs="0"/>
        <xsd:element name="email" type="xsd:string" minOccurs="0"/>
    +   <xsd:element name="access" type="xsd:integer" minOccurs="0"/>
       </xsd:all>
      </xsd:complexType>
      <xsd:complexType name="UserData">
       <xsd:all>
        <xsd:element name="account_data" type="tns:AccountData" minOccurs="0"/>
    @@ -190,10 +191,11 @@
       </xsd:complexContent>
      </xsd:complexType>
      <xsd:complexType name="ProjectData">
       <xsd:all>
        <xsd:element name="id" type="xsd:integer" minOccurs="0"/>
    +   <xsd:element name="parent_id" type="xsd:integer" minOccurs="0"/>
        <xsd:element name="name" type="xsd:string" minOccurs="0"/>
        <xsd:element name="status" type="tns:ObjectRef" minOccurs="0"/>
        <xsd:element name="enabled" type="xsd:boolean" minOccurs="0"/>
        <xsd:element name="view_state" type="tns:ObjectRef" minOccurs="0"/>
        <xsd:element name="access_min" type="tns:ObjectRef" minOccurs="0"/>
    @@ -756,10 +758,30 @@
       <part name="username" type="xsd:string" />
       <part name="password" type="xsd:string" />
       <part name="tag_id" type="xsd:integer" /></message>
     <message name="mc_tag_deleteResponse">
       <part name="return" type="xsd:boolean" /></message>
    +<message name="mc_account_addRequest">
    +  <part name="username" type="xsd:string" />
    +  <part name="password" type="xsd:string" />
    +  <part name="account" type="tns:AccountData" />
    +  <part name="account_password" type="xsd:string" /></message>
    +<message name="mc_account_addResponse">
    +  <part name="return" type="xsd:integer" /></message>
    +<message name="mc_project_add_userRequest">
    +  <part name="username" type="xsd:string" />
    +  <part name="password" type="xsd:string" />
    +  <part name="project_id" type="xsd:integer" />
    +  <part name="user_id" type="xsd:integer" />
    +  <part name="access" type="xsd:integer" /></message>
    +<message name="mc_project_add_userResponse">
    +  <part name="return" type="xsd:integer" /></message>
    +<message name="mc_projects_get_names_user_accessibleRequest">
    +  <part name="username" type="xsd:string" />
    +  <part name="password" type="xsd:string" /></message>
    +<message name="mc_projects_get_names_user_accessibleResponse">
    +  <part name="return" type="tns:ProjectDataArray" /></message>
     <portType name="MantisConnectPortType">
       <operation name="mc_version">
         <input message="tns:mc_versionRequest"/>
         <output message="tns:mc_versionResponse"/>
       </operation>
    @@ -1081,10 +1103,25 @@
       <operation name="mc_tag_delete">
         <documentation>Deletes a tag.</documentation>
         <input message="tns:mc_tag_deleteRequest"/>
         <output message="tns:mc_tag_deleteResponse"/>
       </operation>
    +  <operation name="mc_account_add">
    +    <documentation>Add a new user to the tracker (must have admin privileges).</documentation>
    +    <input message="tns:mc_account_addRequest"/>
    +    <output message="tns:mc_account_addResponse"/>
    +  </operation>
    +  <operation name="mc_project_add_user">
    +    <documentation>Add a user to a project with access level.</documentation>
    +    <input message="tns:mc_project_add_userRequest"/>
    +    <output message="tns:mc_project_add_userResponse"/>
    +  </operation>
    +  <operation name="mc_projects_get_names_user_accessible">
    +    <documentation>Get the list of name/id of projects that are accessible to the logged in user.</documentation>
    +    <input message="tns:mc_projects_get_names_user_accessibleRequest"/>
    +    <output message="tns:mc_projects_get_names_user_accessibleResponse"/>
    +  </operation>
     </portType>
     <binding name="MantisConnectBinding" type="tns:MantisConnectPortType">
       <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
       <operation name="mc_version">
         <soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_version" style="rpc"/>
    @@ -1409,12 +1446,27 @@
       <operation name="mc_tag_delete">
         <soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_tag_delete" style="rpc"/>
         <input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
         <output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
       </operation>
    +  <operation name="mc_account_add">
    +    <soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_account_add" style="rpc"/>
    +    <input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
    +    <output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
    +  </operation>
    +  <operation name="mc_project_add_user">
    +    <soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_project_add_user" style="rpc"/>
    +    <input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
    +    <output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
    +  </operation>
    +  <operation name="mc_projects_get_names_user_accessible">
    +    <soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_projects_get_names_user_accessible" style="rpc"/>
    +    <input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
    +    <output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
    +  </operation>
     </binding>
     <service name="MantisConnect">
       <port name="MantisConnectPort" binding="tns:MantisConnectBinding">
         <soap:address location="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php"/>
       </port>
     </service>
    -</definitions>
    \ No newline at end of file
    +</definitions>
    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.
    
    diff file icon mantisbt-1.2.14-wepl-10349.diff (14,670 bytes) 2013-02-02 10:56 + 

- Relationships
has duplicate 0014540closedatrol Create a account with a web service mantis 
+ Relationships

-  Notes
User avatar

~0021606

giallu (developer)

Did not examine the patch (anyway, much appreciated) but I'd like to know whether you noticed/considered to use the new import/export plugin, which is included in 1.2.0a3, and expand its codebase to grok plain text files.
User avatar

~0021612

Wepl (reporter)

sorry, don't know anything about import/export plugin, where can I find infos?
but if it must be used on the same machine as mantis or can't be scripted I cannot use it anyway, I need list of users, projects and depending on this have to create new users, projects
is it planned to drop api/soap?
User avatar

~0021624

giallu (developer)

no, we don't drop the SOAP API, we just implemented an extendable method for exporting issues (right now in XML format) and importing them back.

To activate it, browse to the "Manage Plugins" page.

Anyway yes, I doubt you can turn it into scriptable stuff.
User avatar

~0021704

Wepl (reporter)

is there a chance that the changes will go into 1.2.0a4?
User avatar

~0022271

vboctor (administrator)

I've marked the issue as acknowledged with the plan to go through your changes and take some of them into the core SOAP API.
User avatar

~0025361

Wepl (reporter)

attached a patch which applies to release 1.2.1
User avatar

~0027024

smcclanahan (reporter)

Any update to the inclusion of this? I really like the add user to project stuff and I will be extending it today for user removal. Would be great to have this upstream.
User avatar

~0028609

adam.leyshon (reporter)

I'd really love to see this come to a release soon as we'd really like it for our automated software deployment system.
User avatar

~0030157

schlauch (reporter)

+1
I also would like to see theses functions in one of the upcoming releases.
User avatar

~0032473

tifou (reporter)

that this API is compatible with mantis 1.2.10?
User avatar

~0036784

vboctor (administrator)

Please submit a github pull request for review.
User avatar

~0036921

Wepl (reporter)

is there a guide how to provide a pull request?
User avatar

~0036926

dregad (developer)

http://lmgtfy.com/?q=how+to+submit+a+pull+request&l=1 [^]
User avatar

~0037165

Wepl (reporter)

have sent https://github.com/mantisbt/mantisbt/pull/88 [^]
hope this correct as I'm not familiar with that stuff ;)
+  Notes

- Issue History
Date Modified Username Field Change
2009-04-20 16:18 Wepl New Issue
2009-04-20 16:18 Wepl File Added: patch-wepl.zip
2009-04-21 02:40 giallu Note Added: 0021606
2009-04-21 17:45 Wepl Note Added: 0021612
2009-04-22 10:14 giallu Note Added: 0021624
2009-04-27 16:49 Wepl Note Added: 0021704
2009-06-26 12:15 vboctor Tag Attached: patch
2009-06-26 12:16 vboctor Note Added: 0022271
2009-06-26 12:16 vboctor Status new => acknowledged
2010-05-01 16:27 Wepl File Added: mantisbt-1.2.1-wepl-10349.diff
2010-05-01 16:28 Wepl Note Added: 0025361
2010-10-14 09:07 smcclanahan Note Added: 0027024
2011-04-13 04:40 adam.leyshon Note Added: 0028609
2011-04-13 17:08 Wepl File Added: mantisbt-1.2.5-wepl-10349.diff
2011-11-04 05:43 schlauch Note Added: 0030157
2011-11-04 16:01 Wepl File Added: mantisbt-1.2.8-wepl-10349.diff
2012-08-01 05:56 atrol Relationship added has duplicate 0014540
2012-08-06 10:37 tifou Note Added: 0032473
2013-02-02 10:56 Wepl File Added: mantisbt-1.2.14-wepl-10349.diff
2013-05-04 04:37 vboctor Note Added: 0036784
2013-05-21 08:48 Wepl Note Added: 0036921
2013-05-21 11:21 dregad Note Added: 0036926
2013-06-11 17:18 Wepl Note Added: 0037165
2013-07-11 17:28 rombert Reproducibility always => N/A
2013-07-11 17:28 rombert Status acknowledged => confirmed
2013-07-11 17:28 rombert Target Version => 1.2.16
2013-07-11 17:28 rombert Description Updated View Revisions
2014-01-23 17:51 atrol Target Version 1.2.16 =>
2014-01-23 17:51 atrol Description Updated View Revisions
+ Issue History