| Attached Files | patch-wepl.zip [^] (40,192 bytes) 2009-04-20 16:18
mantisbt-1.2.1-wepl-10349.diff [^] (16,253 bytes) 2010-05-01 16:27 [Show Content] [Hide Content]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 );
|