View Issue Details

IDProjectCategoryView StatusLast Update
0009026mantisbtapi soappublic2011-09-18 18:08
Reportercabal95 Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status acknowledgedResolutionopen 
PlatformiMacOSMac OS XOS Version10.5.2
Product Version1.1.1 
Summary0009026: Add new functionality to Soap API (assign issues, change status, custom filter)
Description

This patch provides new functionality to the api soap system. It also adds (as a pre-requisite some new functionality to the mantis internal filtering system), changes are outlined per file:

api/soap/mantisconnect.php:

  • Add 'IntegerArray' complex type
  • Add 'HistoryData' complex type
  • Add 'HistoryDataArray' complex type
  • Add 'CustomFilterData' complex type
  • Add 'history' field to IssueData complex type
  • Add 'mc_assign_issue' registration
  • Add 'mc_issue_change_status' registration
  • Add 'mc_custom_filter_get_issue_headers' registration

api/soap/mc_filter_api.php:

  • Reformatted 'mc_filter_get_issue_headers' function (so I could copy and paste the bulk of it, someday an mci_issue_to_headers function should be made so we don't have this in 4 or 5 places)
  • Add 'mc_custom_filter_get_issue_headers' function (User supplies a custom search filter in the form of mantis' internal filter structure)

api/soap/mc_issue_api.php:

  • Add history retrieval to 'mc_get_issue' function
  • Fix 'mc_issue_add' function's default priority/severity/view_state/reproducibility assignment ($v_priority is not used to set data, $t_priority_id is).
  • Add 'mc_issue_assign' function (Assign issue to given reporter with optional note)
  • Add 'mc_issue_change_status' function (Change the status of an issue. Require issue_id and status_id. Optional note, resolution_id and duplicate_id)
  • Add 'mci_issue_get_history' to build an array with the history of a bug (called by 'mc_get_issue').

core/filter_api.php:

  • Add 'show_issues' element (Show issues greater than or equal to date...)
  • Add 'hide_issues' element (Hide issues greater than or equal to date...)
  • Add 'last_updated' element (Show issues with an updated date greater than...)

I would love to find out "asap" if these changes will make it into a future version of Mantis and/or what API changes would need to be made. I have some changes to the CocoaMC project that rely upon this patch and would like to make sure those changes at least use the right API syntax (if a function needs to be renamed or whatever).

TagsNo tags attached.
Attached Files
mantis-1.1.1-api-rev1.patch (26,477 bytes)   
diff -ur /Users/daniel/Downloads/mantis-1.1.1/api/soap/mantisconnect.php ./api/soap/mantisconnect.php
--- /Users/daniel/Downloads/mantis-1.1.1/api/soap/mantisconnect.php	2007-07-17 23:53:10.000000000 -0700
+++ ./api/soap/mantisconnect.php	2008-03-29 14:44:43.000000000 -0700
@@ -58,6 +58,22 @@
 	);
 
 
+	### IntegerArray
+	$l_oServer->wsdl->addComplexType(
+		'IntegerArray',
+		'complexType',
+		'array',
+		'',
+		'SOAP-ENC:Array',
+		array(),
+		array(array(
+			'ref'				=> 'SOAP-ENC:arrayType',
+			'wsdl:arrayType'	=> 'xsd:integer[]'
+		)),
+		'xsd:integer'
+	);
+
+
 	### ObjectRef
 	$l_oServer->wsdl->addComplexType(
 		'ObjectRef',
@@ -218,6 +234,89 @@
 	);
 
 
+	### HistoryData
+	$l_oServer->wsdl->addComplexType(
+		'HistoryData',
+		'complexType',
+		'struct',
+		'all',
+		'',
+		array(
+			'date_modified'	=>	array( 'name' => 'date_modified',	'type' => 'xsd:dateTime',	'minOccurs' => '0'),
+			'user'		=>	array( 'name' => 'user',		'type' => 'tns:AccountData', 	'minOccurs' => '0'),
+			'note'		=>	array( 'name' => 'note',		'type' => 'xsd:string', 	'minOccurs' => '0'),
+			'change'	=>	array( 'name' => 'change',		'type' => 'xsd:string', 	'minOccurs' => '0')
+		)
+	);
+
+	### HistoryDataArray
+	$l_oServer->wsdl->addComplexType(
+		'HistoryDataArray',
+		'complexType',
+		'array',
+		'',
+		'SOAP-ENC:Array',
+		array(),
+		array(array(
+			'ref'				=> 'SOAP-ENC:arrayType',
+			'wsdl:arrayType'	=> 'tns:HistoryData[]'
+		)),
+		'tns:HistoryData'
+	);
+
+
+	### CustomFilterData
+	$l_oServer->wsdl->addComplexType(
+		'CustomFilterData',
+		'complexType',
+		'struct',
+		'all',
+		'',
+		array(
+			'search'		=>	array( 'name' => 'search',		'type' => 'xsd:string',		'minOccurs' => '0'),
+			'show_category'		=>	array( 'name' => 'show_category',	'type' => 'tns:StringArray',	'minOccurs' => '0'),
+			'show_severity'		=>	array( 'name' => 'show_severity',	'type' => 'tns:IntegerArray',	'minOccurs' => '0'),
+			'show_status'		=>	array( 'name' => 'show_status',		'type' => 'tns:IntegerArray',	'minOccurs' => '0'),
+			'show_priority'		=>	array( 'name' => 'show_priority',	'type' => 'tns:IntegerArray',	'minOccurs' => '0'),
+//UNUSED		'highlight_changed'	=>	array( 'name' => 'highlight_changed',	'type' => '',			'minOccurs' => '0'),
+			'reporter_id'		=>	array( 'name' => 'reporter_id',		'type' => 'tns:IntegerArray',	'minOccurs' => '0'),
+			'handler_id'		=>	array( 'name' => 'handler_id',		'type' => 'tns:IntegerArray',	'minOccurs' => '0'),
+			'project_id'		=>	array( 'name' => 'project_id',		'type' => 'tns:IntegerArray',	'minOccurs' => '0'),
+			'show_resolution'	=>	array( 'name' => 'show_resolution',	'type' => 'tns:IntegerArray',	'minOccurs' => '0'),
+			'show_build'		=>	array( 'name' => 'show_build',		'type' => 'tns:StringArray',	'minOccurs' => '0'),
+			'show_version'		=>	array( 'name' => 'show_version',	'type' => 'tns:StringArray',	'minOccurs' => '0'),
+			'user_monitor'		=>	array( 'name' => 'user_monitor',	'type' => 'tns:IntegerArray',	'minOccurs' => '0'),
+			'hide_status'		=>	array( 'name' => 'hide_status',		'type' => 'tns:IntegerArray',	'minOccurs' => '0'),
+			'sort'			=>	array( 'name' => 'sort',		'type' => 'xsd:string',		'minOccurs' => '0'),
+			'dir'			=>	array( 'name' => 'dir',			'type' => 'xsd:string',		'minOccurs' => '0'),
+			'sticky_issues'		=>	array( 'name' => 'sticky_issues',	'type' => 'xsd:string',		'minOccurs' => '0'),
+			'view_state'		=>	array( 'name' => 'view_state',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'fixed_in_version'	=>	array( 'name' => 'fixed_in_version',	'type' => 'tns:StringArray',	'minOccurs' => '0'),
+			'target_version'	=>	array( 'name' => 'target_version',	'type' => 'tns:StringArray',	'minOccurs' => '0'),
+			'per_page'		=>	array( 'name' => 'per_page',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'show_profile'		=>	array( 'name' => 'show_profile',	'type' => 'tns:IntegerArray',	'minOccurs' => '0'),
+			'platform'		=>	array( 'name' => 'platform',		'type' => 'tns:StringArray',	'minOccurs' => '0'),
+			'os'			=>	array( 'name' => 'os',			'type' => 'tns:StringArray',	'minOccurs' => '0'),
+			'os_build'		=>	array( 'name' => 'os_build',		'type' => 'tns:StringArray',	'minOccurs' => '0'),
+			'start_day'		=>	array( 'name' => 'start_day',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'start_month'		=>	array( 'name' => 'start_month',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'start_year'		=>	array( 'name' => 'start_year',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'end_day'		=>	array( 'name' => 'end_day',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'end_month'		=>	array( 'name' => 'end_month',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'end_year'		=>	array( 'name' => 'end_year',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+//UNUSED		'and_not_assigned'	=>	array( 'name' => 'and_not_assigned',	'type' => '',			'minOccurs' => '0'),
+			'do_filter_by_date'	=>	array( 'name' => 'do_filter_by_date',	'type' => 'xsd:string',		'minOccurs' => '0'),
+			'relationship_type'	=>	array( 'name' => 'relationship_type',	'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'relationship_bug'	=>	array( 'name' => 'relationship_bug',	'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'tag_string'		=>	array( 'name' => 'tag_string',		'type' => 'xsd:string',		'minOccurs' => '0'),
+			'tag_select'		=>	array( 'name' => 'tag_select',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'show_issues'		=>	array( 'name' => 'show_issues',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'hide_issues'		=>	array( 'name' => 'hide_issues',		'type' => 'xsd:integer',	'minOccurs' => '0'),
+			'last_updated'		=>	array( 'name' => 'last_updated',	'tyep' => 'xsd:dateTime',	'minOccurs' => '0')
+		)
+	);
+
+
 	### IssueNoteData
 	$l_oServer->wsdl->addComplexType(
 		'IssueNoteData',
@@ -296,7 +395,8 @@
 			'attachments'				=>	array( 'name' => 'attachments', 			'type' => 'tns:AttachmentDataArray', 	'minOccurs' => '0' ),
 			'relationships'				=>	array( 'name' => 'relationships',			'type' => 'tns:RelationshipDataArray', 	'minOccurs' => '0' ),
 			'notes'						=>	array( 'name' => 'notes',					'type' => 'tns:IssueNoteDataArray', 	'minOccurs' => '0' ),
-			'custom_fields'				=>  array( 'name' => 'custom_fields',			'type' => 'tns:CustomFieldValueForIssueDataArray', 	'minOccurs' => '0' )
+			'custom_fields'				=>  array( 'name' => 'custom_fields',			'type' => 'tns:CustomFieldValueForIssueDataArray', 	'minOccurs' => '0' ),
+			'history'		=>	array ( 'name' => 'history',		'type' => 'tns:HistoryDataArray',	'minOccurs' => '0' )
 		)
 	);
 
@@ -989,6 +1089,42 @@
 		'Get the data for the specified issue attachment.'
 	);
 
+	### mc_issue_assign
+ 	$l_oServer->register( 'mc_issue_assign',
+ 		array(
+			'username'	=>	'xsd:string',
+ 			'password'	=>	'xsd:string',
+ 			'issue_id'	=>	'xsd:integer',
+			'handler_id'	=>	'xsd:integer',
+ 			'note' 		=>	'tns:IssueNoteData'
+ 		),
+ 		array(
+			'return'	=>	'xsd:integer'
+		),
+ 		$t_namespace,
+		false, false, false,
+		'Assign the bug to the given user id, optionally provide a note.'
+ 	);
+
+	### mc_issue_change_status
+ 	$l_oServer->register( 'mc_issue_change_status',
+ 		array(
+			'username'	=>	'xsd:string',
+ 			'password'	=>	'xsd:string',
+ 			'issue_id'	=>	'xsd:integer',
+			'status_id'	=>	'xsd:integer',
+ 			'note' 		=>	'tns:IssueNoteData',
+			'resolution_id'	=>	'xsd:integer',
+			'duplicate_id'	=>	'xsd:integer'
+ 		),
+ 		array(
+			'return'	=>	'xsd:integer'
+		),
+ 		$t_namespace,
+		false, false, false,
+		'Update the status of the given issue_id.'
+ 	);
+
 
 	###
 	###  PUBLIC METHODS (defined in mc_project_api.php)
@@ -1332,6 +1468,23 @@
 		'Get the issue headers that match the specified filter and paging details.'
 	);
 
+	### mc_custom_filter_get_issue_headers
+	$l_oServer->register( 'mc_custom_filter_get_issue_headers',
+		array(
+			'username'		=>	'xsd:string',
+			'password'		=>	'xsd:string',
+			'filter'		=>	'tns:CustomFilterData',
+			'page_number'		=>	'xsd:integer',
+			'per_page'		=>	'xsd:integer'
+		),
+		array(
+			'return' => 'tns:IssueHeaderDataArray'
+		),
+		$t_namespace,
+		false, false, false,
+		'Get the issue headers that match the specified custom filter and paging details.'
+	);
+
 
 	### mc_config_get_string
 	$l_oServer->register( 'mc_config_get_string',
diff -ur /Users/daniel/Downloads/mantis-1.1.1/api/soap/mc_filter_api.php ./api/soap/mc_filter_api.php
--- /Users/daniel/Downloads/mantis-1.1.1/api/soap/mc_filter_api.php	2007-12-07 05:42:38.000000000 -0800
+++ ./api/soap/mc_filter_api.php	2008-03-28 16:03:17.000000000 -0700
@@ -157,33 +157,87 @@
 
 		$t_result = array();
 		$t_rows = filter_get_bug_rows( $p_page_number, $p_per_page, $t_page_count, $t_bug_count, $t_filter, $p_project_id );
-        foreach( $t_rows as $t_issue_data ) {
-            $t_id = $t_issue_data['id'];
-            
-            $t_issue = array();
-            
-            $t_issue['id'] = $t_id;
-            $t_issue['view_state'] = $t_issue_data['view_state'];
-            $t_issue['last_updated'] = timestamp_to_iso8601( $t_issue_data['last_updated'] );
-
-            $t_issue['project'] = $t_issue_data['project_id'];
-            $t_issue['category'] = mci_null_if_empty( $t_issue_data['category'] );
-            $t_issue['priority'] = $t_issue_data['priority'];
-            $t_issue['severity'] = $t_issue_data['severity'];
-            $t_issue['status'] = $t_issue_data['status'];
-
-            $t_issue['reporter'] = $t_issue_data['reporter_id'];
-            $t_issue['summary'] = $t_issue_data['summary'];
-            if( !empty( $t_issue_data['handler_id'] ) ) {
-                $t_issue['handler'] = $t_issue_data['handler_id'];
-            }
-            $t_issue['resolution'] = $t_issue_data['resolution'];
-            
-            $t_issue['attachments_count'] = count( mci_issue_get_attachments( $t_issue_data['id'] ) );
-            $t_issue['notes_count'] = count( mci_issue_get_notes( $t_issue_data['id'] ) );
+		foreach( $t_rows as $t_issue_data ) {
+			$t_id = $t_issue_data['id'];
 
-            $t_result[] = $t_issue;
-        }
+			$t_issue = array();
+
+			$t_issue['id'] = $t_id;
+			$t_issue['view_state'] = $t_issue_data['view_state'];
+			$t_issue['last_updated'] = timestamp_to_iso8601( $t_issue_data['last_updated'] );
+
+			$t_issue['project'] = $t_issue_data['project_id'];
+			$t_issue['category'] = mci_null_if_empty( $t_issue_data['category'] );
+			$t_issue['priority'] = $t_issue_data['priority'];
+			$t_issue['severity'] = $t_issue_data['severity'];
+			$t_issue['status'] = $t_issue_data['status'];
+
+			$t_issue['reporter'] = $t_issue_data['reporter_id'];
+			$t_issue['summary'] = $t_issue_data['summary'];
+			if( !empty( $t_issue_data['handler_id'] ) ) {
+				$t_issue['handler'] = $t_issue_data['handler_id'];
+			}
+			$t_issue['resolution'] = $t_issue_data['resolution'];
+
+			$t_issue['attachments_count'] = count( mci_issue_get_attachments( $t_issue_data['id'] ) );
+			$t_issue['notes_count'] = count( mci_issue_get_notes( $t_issue_data['id'] ) );
+
+			$t_result[] = $t_issue;
+		}
+
+		return $t_result;
+	}
+
+	/**
+	 * Get the issue headers that match the specified custom filter and paging details.
+	 *
+	 * @param string $p_username  The name of the user trying to access the filters.
+	 * @param string $p_password  The password of the user.
+	 * @param Array $p_filter  A CustomFilterData structure containing information about the filter.
+	 * @param integer $p_page_number  Start with the given page number (zero-based)
+	 * @param integer $p_per_page  Number of issues to display per page
+	 * @return Array that represents an IssueDataArray structure
+	 */
+	function mc_custom_filter_get_issue_headers( $p_username, $p_password, $p_filter, $p_page_number, $p_per_page ) {
+		$t_user_id = mci_check_login( $p_username, $p_password );
+		if ( $t_user_id === false ) {
+			return new soap_fault( 'Client', '', 'Access Denied' );
+		}
+
+		$t_page_count = 0;
+		$t_bug_count = 0;
+		$p_filter['_view_type'] = 'advanced';
+		$t_filter = filter_ensure_valid_filter( $p_filter );
+
+		$t_result = array();
+		$t_rows = filter_get_bug_rows( $p_page_number, $p_per_page, $t_page_count, $t_bug_count, $t_filter );
+		foreach( $t_rows as $t_issue_data ) {
+			$t_id = $t_issue_data['id'];
+
+			$t_issue = array();
+
+			$t_issue['id'] = $t_id;
+			$t_issue['view_state'] = $t_issue_data['view_state'];
+			$t_issue['last_updated'] = timestamp_to_iso8601( $t_issue_data['last_updated'] );
+
+			$t_issue['project'] = $t_issue_data['project_id'];
+			$t_issue['category'] = mci_null_if_empty( $t_issue_data['category'] );
+			$t_issue['priority'] = $t_issue_data['priority'];
+			$t_issue['severity'] = $t_issue_data['severity'];
+			$t_issue['status'] = $t_issue_data['status'];
+
+			$t_issue['reporter'] = $t_issue_data['reporter_id'];
+			$t_issue['summary'] = $t_issue_data['summary'];
+			if( !empty( $t_issue_data['handler_id'] ) ) {
+				$t_issue['handler'] = $t_issue_data['handler_id'];
+			}
+			$t_issue['resolution'] = $t_issue_data['resolution'];
+
+			$t_issue['attachments_count'] = count( mci_issue_get_attachments( $t_issue_data['id'] ) );
+			$t_issue['notes_count'] = count( mci_issue_get_notes( $t_issue_data['id'] ) );
+
+			$t_result[] = $t_issue;
+		}
 
 		return $t_result;
 	}
diff -ur /Users/daniel/Downloads/mantis-1.1.1/api/soap/mc_issue_api.php ./api/soap/mc_issue_api.php
--- /Users/daniel/Downloads/mantis-1.1.1/api/soap/mc_issue_api.php	2007-12-07 05:42:38.000000000 -0800
+++ ./api/soap/mc_issue_api.php	2008-03-27 17:28:23.000000000 -0700
@@ -106,6 +106,8 @@
 		$t_issue_data['notes'] = mci_issue_get_notes( $p_issue_id );
 		$t_issue_data['custom_fields'] = mci_issue_get_custom_fields( $p_issue_id );
 
+		$t_issue_data['history'] = mci_issue_get_history( $p_issue_id, $t_user_id );
+
 		return $t_issue_data;
 	}
 
@@ -473,19 +475,19 @@
 		}
 
 		if ( $v_priority == 0 ) {
-			$v_priority = config_get( 'default_bug_priority' );
+			$t_priority_id = config_get( 'default_bug_priority' );
 		}
 
 		if ( $v_severity == 0 ) {
-			$v_severity = config_get( 'default_bug_severity' );
+			$t_severity_id = config_get( 'default_bug_severity' );
 		}
 
 		if ( $v_view_state == 0 ) {
-			$v_view_state = config_get( 'default_bug_view_status' );
+			$t_view_state_id = config_get( 'default_bug_view_status' );
 		}
 
 		if ( $v_reproducibility == 0 ) {
-			$v_reproducibility = 10;
+			$t_reproducibility_id = confg_get( 'default_bug_reproducibility' );
 		}
 
 		$t_bug_data = new BugData;
@@ -983,4 +985,181 @@
 
 		return true;
 	}
+
+ 	/**
+	 * Assign the bug to the given user id, optionally provide a note.
+	 *
+	 * @param string $p_username  The name of the user trying to access the issue.
+	 * @param string $p_password  The password of the user.
+	 * @param integer $p_issue_id The id of the issue to assign
+	 * @param integer $p_handler_id  The id of the user to assign the issue to.
+	 * @param IssueNoteData $p_note  The note to add.
+	 * @return boolean  true success, false : failure
+	 */
+	function mc_issue_assign( $p_username, $p_password, $p_issue_id, $p_handler_id, $p_note = '') {
+		$t_user_id = mci_check_login( $p_username, $p_password );
+		if ( $t_user_id === false ) {
+			return new soap_fault( 'Client', '', 'Access Denied' );
+		}
+
+		if ( !bug_exists( $p_issue_id ) ) {
+ 			return new soap_fault( 'Client', '', "Issue '$p_issue_id' not found." );
+		}
+
+		$t_project_id = bug_get_field( $p_issue_id, 'project_id' );
+		if ( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) {
+			return new soap_fault( 'Client', '', 'Access Denied' );
+		}
+
+		if ( bug_is_readonly( $p_issue_id ) ) {
+			return new soap_fault( 'Client', '', "Issue '$p_issue_id' is readonly." );
+		}
+
+		$t_access = config_get( 'update_bug_assign_threshold', config_get( 'update_bug_threshold' ) );
+		if ( !access_has_bug_level( $t_access, $p_issue_id, $t_user_id) ) {
+			return new soap_fault( 'Client', '', "User '$t_user_id' does not have access right to assign issues." );
+		}
+
+		if ( $p_handler_id != NO_USER ) {
+			if ( !user_exists( $p_handler_id ) ) {
+				return new soap_fault( 'Client', '', "User '$p_handler_id' does not exist." );
+			}
+
+			if ( !access_has_bug_level( config_get( 'handle_bug_threshold' ), $p_issue_id, $p_handler_id ) ) {
+				return new soap_fault( 'Client', '', "User '$p_handler_id' does not have access right to handle issues." );
+			}
+		}
+
+		if ( isset( $p_note ) && is_array( $p_note ) && isset( $p_note['text'] ) ) {
+			if ( !access_has_bug_level( config_get( 'add_bugnote_threshold' ), $p_issue_id, $t_user_id ) ) {
+				return new soap_fault( 'Client', '', "User '$t_user_id' does not have access right to add notes to this issue." );
+			}
+
+			$t_note_text = $p_note['text'];
+
+			if ( isset( $p_note['view_state'] ) ) {
+				$t_view_state = $p_note['view_state'];
+			} else {
+				$t_view_state = config_get( 'default_bug_view_status' );
+			}
+
+		} else {
+			$t_note_text = '';
+			$t_view_state = config_get( 'default_bug_view_status' );
+		}
+
+		$t_view_state_id = mci_get_enum_id_from_objectref( 'view_state', $t_view_state );
+		return bug_assign( $p_issue_id, $p_handler_id, $t_note_text, $t_view_state_id == VS_PRIVATE );
+	}
+
+ 	/**
+	 * Update the status of the given issue_id.
+	 *
+	 * @param string $p_username  The name of the user trying to access the issue.
+	 * @param string $p_password  The password of the user.
+	 * @param integer $p_issue_id The id of the issue to assign
+	 * @param integer $p_status_id  The id of the status to assign.
+	 * @param IssueNoteData $p_note  The note to add.
+	 * @param integer $p_resolution_id  The id of the resolution to use when $p_status_id == resolved.
+	 * @param integer $p_duplicate_id  The id of the duplicate bug when $p_resolution_id == duplicate.
+	 * @return boolean  true success, false : failure
+	 */
+	function mc_issue_change_status( $p_username, $p_password, $p_issue_id, $p_status_id, $p_note = '', $p_resolution_id = '', $p_duplicate_id = '') {
+		$t_user_id = mci_check_login( $p_username, $p_password );
+		if ( $t_user_id === false ) {
+			return new soap_fault( 'Client', '', 'Access Denied' );
+		}
+
+		if ( !bug_exists( $p_issue_id ) ) {
+ 			return new soap_fault( 'Client', '', "Issue '$p_issue_id' not found." );
+		}
+
+		$t_project_id = bug_get_field( $p_issue_id, 'project_id' );
+		if ( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) {
+			return new soap_fault( 'Client', '', 'Access Denied' );
+		}
+
+		if ( bug_is_readonly( $p_issue_id ) ) {
+			return new soap_fault( 'Client', '', "Issue '$p_issue_id' is readonly." );
+		}
+
+		$t_access = access_get_status_threshold( $p_status_id, bug_get_field( $p_issue_id, 'project_id' ) );
+		if ( !access_has_bug_level( $t_access, $p_issue_id, $t_user_id) ) {
+			return new soap_fault( 'Client', '', "User '$t_user_id' does not have access right to set status level." );
+		}
+
+		if ( !access_has_bug_level( config_get( 'update_bug_threshold' ), $p_issue_id, $t_user_id) ) {
+			return new soap_fault( 'Client', '', "User '$t_user_id' does not have access right to update bug." );
+		}
+
+		if ( isset( $p_note ) && is_array( $p_note ) && isset( $p_note['text'] ) ) {
+			if ( !access_has_bug_level( config_get( 'add_bugnote_threshold' ), $p_issue_id, $t_user_id ) ) {
+				return new soap_fault( 'Client', '', "User '$t_user_id' does not have access right to add notes to this issue." );
+			}
+
+			$t_note_text = $p_note['text'];
+
+			if ( isset( $p_note['view_state'] ) ) {
+				$t_view_state = $p_note['view_state'];
+			} else {
+				$t_view_state = config_get( 'default_bug_view_status' );
+			}
+
+		} else {
+			$t_note_text = '';
+			$t_view_state = config_get( 'default_bug_view_status' );
+		}
+		$t_view_state_id = mci_get_enum_id_from_objectref( 'view_state', $t_view_state );
+
+		switch ( $p_status_id ) {
+			case CLOSED:
+				bug_close( $p_issue_id, $t_note_text, $t_view_state_id == VS_PRIVATE, '0:00' );
+				break;
+
+			case config_get( 'bug_resolved_status_threshold' ):
+				bug_resolve( $p_issue_id, $p_resolution_id, '', $t_note_text, $p_duplicate_id,
+						bug_get_field( $p_issue_id, 'handler_id' ), $t_view_state_id == VS_PRIVATE, '0:00' );
+				break;
+
+			case config_get( 'bug_reopen_status' ):
+				if ( bug_get_field( $p_issue_id, 'status' ) >= config_get( 'bug_resolved_status_threshold' ) ) {
+					bug_reopen( $p_issue_id, $t_note_text, '0:00', $t_view_state_id == VS_PRIVATE );
+				}
+				// Else fall through to default.
+
+			default:
+				bug_set_field( $p_issue_id, 'status', $p_status_id );
+				if ( !is_blank( $t_note_text ) ) {
+					bugnote_add( $p_issue_id, $t_note_text, '0:00', $t_view_state_id == VS_PRIVATE, '', $t_user_id );
+				}
+				break;
+		}
+
+		return true;
+	}
+
+	/**
+	 * Get the history of an issue.
+	 *
+	 * @param integer $p_issue_id  The id of the issue to retrieve the history for.
+	 * @param integer $p_user_id  The id of the user requesting the history.
+	 * @return Array that represents an HistoryData structure
+	 */
+	function mci_issue_get_history( $p_issue_id, $p_user_id ) {
+		$t_histories = array();
+
+		if ( access_has_bug_level( config_get( 'view_history_threshold' ), $p_issue_id, $p_user_id ) ) {
+			$t_src_histories = history_get_raw_events_array( $p_issue_id );
+			foreach( $t_src_histories as $t_history_row) {
+				$t_history = history_localize_item( $t_history_row['field'], $t_history_row['type'], $t_history_row['old_value'], $t_history_row['new_value'] );
+				$t_history['date_modified'] = timestamp_to_iso8601( $t_history_row['date'] );
+				$t_history['user'] = mci_account_get_array_by_id( $t_history_row['userid'] );
+
+				$t_histories[] = $t_history;
+			}
+		}
+
+		return $t_histories;
+	}
+
 ?>
diff -ur /Users/daniel/Downloads/mantis-1.1.1/core/filter_api.php ./core/filter_api.php
--- /Users/daniel/Downloads/mantis-1.1.1/core/filter_api.php	2008-01-04 22:58:22.000000000 -0800
+++ ./core/filter_api.php	2008-03-29 14:49:43.000000000 -0700
@@ -71,6 +71,9 @@
 	define( 'FILTER_PROPERTY_RELATIONSHIP_BUG', 'relationship_bug' );
 	define( 'FILTER_PROPERTY_TAG_STRING', 'tag_string' );
 	define( 'FILTER_PROPERTY_TAG_SELECT', 'tag_select' );
+	define( 'FILTER_PROPERTY_SHOW_ISSUES', 'show_issues' );
+	define( 'FILTER_PROPERTY_HIDE_ISSUES', 'hide_issues' );
+	define( 'FILTER_PROPERTY_LAST_UPDATED', 'last_updated' );
 
 	###########################################################################
 	# Filter Query Parameter Names
@@ -113,6 +116,9 @@
 	define( 'FILTER_SEARCH_RELATIONSHIP_BUG', 'relationship_bug' );
 	define( 'FILTER_SEARCH_TAG_STRING', 'tag_string' );
 	define( 'FILTER_SEARCH_TAG_SELECT', 'tag_select' );
+	define( 'FILTER_SEARCH_SHOW_ISSUES', 'show_issues' );
+	define( 'FILTER_SEARCH_HIDE_ISSUES', 'hide_issues' );
+	define( 'FILTER_SEARCH_LAST_UPDATED', 'last_updated' );
 
 	# Checks the supplied value to see if it is an ANY value.
 	# $p_field_value - The value to check.
@@ -331,6 +337,18 @@
 			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_TAG_SELECT, $p_custom_filter[FILTER_PROPERTY_TAG_SELECT] );
 		}
 
+		if ( !filter_str_field_is_any( $p_custom_filter[FILTER_PROPERTY_SHOW_ISSUES] ) ) {
+			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_SHOW_ISSUES, $p_custom_filter[FILTER_PROPERTY_SHOW_ISSUES] );
+		}
+
+		if ( !filter_str_field_is_any( $p_custom_filter[FILTER_PROPERTY_HIDE_ISSUES] ) ) {
+			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_HIDE_ISSUES, $p_custom_filter[FILTER_PROPERTY_HIDE_ISSUES] );
+		}
+
+		if ( !filter_str_field_is_any( $p_custom_filter[FILTER_PROPERTY_LAST_UPDATED] ) ) {
+			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_LAST_UPDATED, $p_custom_filter[FILTER_PROPERTY_LAST_UPDATED] );
+		}
+
 		if ( isset( $p_custom_filter['custom_fields'] ) ) {
 			foreach( $p_custom_filter['custom_fields'] as $t_custom_field_id => $t_custom_field_values ) {
 				if ( !filter_str_field_is_any( $t_custom_field_values ) ) {
@@ -1140,6 +1158,39 @@
 			}	
 		}
 
+		# show issues greater than or equal to...
+		$t_any_found = false;
+		$c_issue_id = $t_filter['show_issues'];
+		if ( 0 == $c_issue_id ) {
+			$t_any_found = true;
+		}
+		if ( !$t_any_found ) {
+			$t_show_issues = db_prepare_int( $c_issue_id );
+			array_push( $t_where_clauses, "($t_bug_table.id>='$t_show_issues')" );
+		}
+
+		# hide issues greater than or equal to (show less than)...
+		$t_any_found = false;
+		$c_issue_id = $t_filter['hide_issues'];
+		if ( 0 == $c_issue_id ) {
+			$t_any_found = true;
+		}
+		if ( !$t_any_found ) {
+			$t_hide_issues = db_prepare_int( $c_issue_id );
+			array_push( $t_where_clauses, "($t_bug_table.id<'$t_hide_issues')" );
+		}
+
+		# show issues with a updated date greater than...
+		$t_any_found = false;
+		$c_last_updated = $t_filter['last_updated'];
+		if ( 0 == $c_last_updated ) {
+			$t_any_found = true;
+		}
+		if ( !$t_any_found ) {
+			$t_last_updated = db_date( $c_last_updated );
+			array_push( $t_where_clauses, "($t_bug_table.last_updated>'$t_last_updated')" );
+		}
+
 		# custom field filters
 		if( ON == config_get( 'filter_by_custom_fields' ) ) {
 			# custom field filtering
@@ -3123,6 +3174,15 @@
 		if ( !isset( $p_filter_arr['tag_select'] ) ) {
 			$p_filter_arr['tag_select'] = gpc_get_string( 'tag_select', '' );
 		}
+		if ( !isset( $p_filter_arr['show_issues'] ) ) {
+			$p_filter_arr['show_issues'] = gpc_get_int( 'show_issues', 0 );
+		}
+		if ( !isset( $p_filter_arr['hide_issues'] ) ) {
+			$p_filter_arr['hide_issues'] = gpc_get_int( 'hide_issues', 0 );
+		}
+		if ( !isset( $p_filter_arr['last_updated'] ) ) {
+			$p_filter_arr['last_updated'] = gpc_get_int( 'last_updated', 0 );
+		}
 
 		$t_custom_fields 		= custom_field_get_ids(); # @@@ (thraxisp) This should really be the linked ids, but we don't know the project
 		$f_custom_fields_data 	= array();
mantis-1.1.1-api-rev1.patch (26,477 bytes)   

Activities

grangeway

grangeway

2008-05-04 19:07

reporter   ~0017769

Reminder sent to: daryn

Daryn,

Could you have a look at the filter_api.php changes component of this whilst working on filter api?

Paul

cabal95

cabal95

2008-11-20 19:24

reporter   ~0019959

Not to be a pest, but ping? If there is anything I can do to help move this along I would be happy to. Update patch, add features, make changes, etc. ?

vboctor

vboctor

2008-11-20 19:46

manager   ~0019960

It would be helpful for you (to keep your changes updated) and for us if you can provide a git repository with your changes. See the link below for details:

http://tinyurl.com/6k2e5s

cabal95

cabal95

2008-11-20 20:04

reporter   ~0019961

Never really used git before, though I have used cvs and svn quite a bit so I know the concepts, but just to clarify:
I'm creating a local git clone of the latest development branch. I am also creating a public git repository for others to track the changes I have made (for me, via one of those public git servers the doc mentioned). Then I just need to post "my" public git url back for you and others to be able to track. Thanks.

thE_iNviNciblE

thE_iNviNciblE

2009-02-17 11:25

reporter   ~0020872

this is a cool idea functionality to Soap API :-)