View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0009936 | mantisbt | api soap | public | 2008-12-04 09:20 | 2019-08-04 19:57 |
Reporter | laurentb | Assigned To | rombert | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Platform | All | OS | All | ||
Product Version | 1.1.2 | ||||
Target Version | 1.2.16 | Fixed in Version | 1.2.16 | ||
Summary | 0009936: add history information | ||||
Description | Hi, I've been using Mantisconnect for some project. So i had to develop this feature of php webservice based on latest version services concernes are : mc_issue_get Now that is done and it works fine to me, and in view of the fact that Anyway, here is the archive of code modifications in attached file. Because it has been not modified, the archive doesn't contains "nusoap" | ||||
Tags | patch | ||||
Attached Files | ticket_0009936.patch (5,235 bytes)
From 6ef67892ba907cffb9d0190e8e4c100401ce4610 Mon Sep 17 00:00:00 2001 From: Wojciech Matusiak <wmatusiak@gmail.com> Date: Fri, 8 Jun 2012 02:21:03 +0200 Subject: [PATCH] Fixed #0009936: add history information - reapply code on 1.2.x --- api/soap/mantisconnect.php | 33 ++++++++++++++++++++++++++++++- api/soap/mc_issue_api.php | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/api/soap/mantisconnect.php b/api/soap/mantisconnect.php index 819dced..86ae370 100644 --- a/api/soap/mantisconnect.php +++ b/api/soap/mantisconnect.php @@ -241,6 +241,36 @@ $l_oServer->wsdl->addComplexType( 'tns:IssueNoteData' ); +### HistoryData +$l_oServer->wsdl->addComplexType( + 'HistoryData', + 'complexType', + 'struct', + 'all', + '', + array( + 'date_modified' => array( 'name' => 'date_modified', 'type' => 'xsd:dateTime'), + 'username' => array( 'name' => 'username', 'type' => 'xsd:string'), + 'field' => array( 'name' => 'field', 'type' => 'xsd:string'), + 'change' => array( 'name' => 'change', 'type' => 'xsd:string'), + ) +); + +### HistoryDataArray +$l_oServer->wsdl->addComplexType( + 'HistoryDataArray', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array( + 'ref' => 'SOAP-ENC:arrayType', + 'wsdl:arrayType' => 'tns:HistoryData[]' + )), + 'tns:HistoryData' +); + ### IssueData $l_oServer->wsdl->addComplexType( 'IssueData', @@ -290,7 +320,8 @@ $l_oServer->wsdl->addComplexType( 'due_date' => array( 'name' => 'due_date', 'type' => 'xsd:dateTime', 'minOccurs' => '0' ), 'monitors' => array( 'name' => 'monitors', 'type' => 'tns:AccountDataArray', 'minOccurs' => '0'), 'sticky' => array( 'name' => 'sticky', 'type' => 'xsd:boolean', 'minOccurs' => '0'), - 'tags' => array( 'name' => 'tags', 'type' => 'tns:ObjectRefArray', 'minOccurs' => '0') + 'tags' => array( 'name' => 'tags', 'type' => 'tns:ObjectRefArray', 'minOccurs' => '0'), + 'histories' => array( 'name' => 'histories', 'type' => 'tns:HistoryDataArray', 'minOccurs' => '0' ) ) ); diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index 251b12d..3b51885 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -112,6 +112,7 @@ function mc_issue_get( $p_username, $p_password, $p_issue_id ) { $t_issue_data['relationships'] = mci_issue_get_relationships( $p_issue_id, $t_user_id ); $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['histories'] = mci_issue_get_histories( $p_issue_id ); $t_issue_data['monitors'] = mci_account_get_array_by_ids( bug_get_monitors ( $p_issue_id ) ); $t_issue_data['tags'] = mci_issue_get_tags_for_bug_id( $p_issue_id , $t_user_id ); @@ -1390,6 +1391,7 @@ function mci_issue_data_as_array( $p_issue_data, $p_user_id, $p_lang ) { $t_issue['relationships'] = mci_issue_get_relationships( $p_issue_data->id, $p_user_id ); $t_issue['notes'] = mci_issue_get_notes( $p_issue_data->id ); $t_issue['custom_fields'] = mci_issue_get_custom_fields( $p_issue_data->id ); + $t_issue['histories'] = mci_issue_get_histories( $p_issue_data->id ); $t_issue['tags'] = mci_issue_get_tags_for_bug_id( $p_issue_data->id, $p_user_id ); return $t_issue; @@ -1447,3 +1449,48 @@ function mci_issue_data_as_header_array( $p_issue_data ) { return $t_issue; } + + +/** + * Get the histories of an issue. + * + * @param integer $p_issue_id The id of the issue to retrieve the histories for + * @return Array that represents an HistoryData structure + */ +function mci_issue_get_histories( $p_issue_id ) { + $t_history_rows = mci_history_get_events_array( $p_issue_id ); + $t_result = array(); + + foreach( $t_history_rows as $t_history_row ) { + $t_history = array(); + $t_history['date_modified'] = timestamp_to_iso8601( $t_history_row['date'] ); + $t_history['username'] = user_get_name($t_history_row['userid']); + $t_history['field'] = $t_history_row['note']; + $t_history['change'] = $t_history_row['change']; + $t_result[] = $t_history; + } + + return $t_result; +} + +# -------------------- +# Retrieves the history events for the specified bug id and returns it in an array +# The array is indexed from 0 to N-1. The second dimension is: 'date', 'username', +# 'note', 'change'. +function mci_history_get_events_array( $p_bug_id, $p_user_id = null ) { + $t_normal_date_format = config_get( 'normal_date_format' ); + + $raw_history = history_get_raw_events_array( $p_bug_id, $p_user_id ); + $raw_history_count = count( $raw_history ); + $history = array(); + + for ( $i=0; $i < $raw_history_count; $i++ ) { + $history[$i] = history_localize_item( $raw_history[$i]['field'], $raw_history[$i]['type'], $raw_history[$i]['old_value'], $raw_history[$i]['new_value'] ); + # get Date with db_unixtimestamp format + $history[$i]['date'] = $raw_history[$i]['date']; + $history[$i]['userid'] = $raw_history[$i]['userid']; + $history[$i]['username'] = $raw_history[$i]['username']; + } + + return ( $history ); +} -- 1.7.9.5 mantis_history_SOAP.patch (5,251 bytes)
diff --git a/api/soap/mantisconnect.wsdl b/api/soap/mantisconnect.wsdl index 1e3faac..7d5f2ce 100644 --- a/api/soap/mantisconnect.wsdl +++ b/api/soap/mantisconnect.wsdl @@ -164,6 +164,24 @@ </xsd:restriction> </xsd:complexContent> </xsd:complexType> + <xsd:complexType name="HistoryData"> + <xsd:all> + <xsd:element name="date" type="xsd:integer" minOccurs="0"/> + <xsd:element name="userid" type="xsd:integer" minOccurs="0"/> + <xsd:element name="username" type="xsd:string" minOccurs="0"/> + <xsd:element name="field" type="xsd:string" minOccurs="0"/> + <xsd:element name="type" type="xsd:integer" minOccurs="0"/> + <xsd:element name="old_value" type="xsd:integer" minOccurs="0"/> + <xsd:element name="new_value" type="xsd:integer" minOccurs="0"/> + </xsd:all> + </xsd:complexType> + <xsd:complexType name="HistoryDataArray"> + <xsd:complexContent> + <xsd:restriction base="SOAP-ENC:Array"> + <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:HistoryData[]"/> + </xsd:restriction> + </xsd:complexContent> + </xsd:complexType> <xsd:complexType name="IssueHeaderData"> <xsd:all> <xsd:element name="id" type="xsd:integer"/> @@ -435,6 +453,12 @@ <part name="issue_id" type="xsd:integer" /></message> <message name="mc_issue_getResponse"> <part name="return" type="tns:IssueData" /></message> +<message name="mc_issue_get_historyRequest"> + <part name="username" type="xsd:string" /> + <part name="password" type="xsd:string" /> + <part name="issue_id" type="xsd:integer" /></message> +<message name="mc_issue_get_historyResponse"> + <part name="return" type="tns:HistoryDataArray" /></message> <message name="mc_issue_get_biggest_idRequest"> <part name="username" type="xsd:string" /> <part name="password" type="xsd:string" /> @@ -843,6 +867,11 @@ <input message="tns:mc_issue_getRequest"/> <output message="tns:mc_issue_getResponse"/> </operation> + <operation name="mc_issue_get_history"> + <documentation>Get the history of the issue with the specified id.</documentation> + <input message="tns:mc_issue_get_historyRequest"/> + <output message="tns:mc_issue_get_historyResponse"/> + </operation> <operation name="mc_issue_get_biggest_id"> <documentation>Get the latest submitted issue in the specified project.</documentation> <input message="tns:mc_issue_get_biggest_idRequest"/> @@ -1171,6 +1200,11 @@ <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_issue_get_history"> + <soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_issue_get_history" 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_issue_get_biggest_id"> <soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_issue_get_biggest_id" style="rpc"/> <input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input> diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index 410705a..a3e7693 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -45,7 +45,7 @@ * @return Array that represents an IssueData structure */ function mc_issue_get( $p_username, $p_password, $p_issue_id ) { - + $t_user_id = mci_check_login( $p_username, $p_password ); if( $t_user_id === false ) { return mci_soap_fault_login_failed(); @@ -120,6 +120,42 @@ } /** +* Get history details about an issue. +* +* @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 retrieve. +* @return Array that represents a HistoryDataArray structure +*/ +function mc_issue_get_history( $p_username, $p_password, $p_issue_id ) { + + $t_user_id = mci_check_login( $p_username, $p_password ); + if( $t_user_id === false ) { + return mci_soap_fault_login_failed(); + } + + $t_lang = mci_get_user_lang( $t_user_id ); + + if( !bug_exists( $p_issue_id ) ) { + return SoapObjectsFactory::newSoapFault('Client', 'Issue does not exist'); + } + + $t_project_id = bug_get_field( $p_issue_id, 'project_id' ); + if( !mci_has_readonly_access( $t_user_id, $t_project_id ) ) { + return mci_soap_fault_access_denied( $t_user_id ); + } + + if( !access_has_bug_level( VIEWER, $p_issue_id, $t_user_id ) ){ + return mci_soap_fault_access_denied( $t_user_id ); + } + + $t_bug_history = history_get_raw_events_array($p_issue_id, $t_user_id); + + return $t_bug_history; + +} + +/** * Returns the category name, possibly null if no category is assigned * * @param int $p_category_id | ||||
It would be great if you can provide a patch against 1.2.8 release / latest code in master-1.2.x branch. If you are a user of github, then sending a pull request for your change will even be better. |
|
Hello This should also work with 1.3 but not test it. |
|
I had a quick look, here are some comments:
|
|
btw, thanks for the contribution. |
|
This looks good overall, thanks. I have one design comment - we should move this history information to a different soap call. Adding it to the existing one can greatly increase the data transfer required when querying for issues , which I think is not what we want. I suggest that we make a separate API call: mc_issue_get_history ( username, password, issue_id ) or whatever fits your use case. A nitpick - you're calling config_get( 'normal_date_format' ) but not using it at all. |
|
I only get code from zip and reapply it on never version. I think I'd find some time to implement it and provide better patch ;) |
|
(In reply to comment 0009936:0032064)
That would be great! If you need help in development please ask in this ticket or subscribe to https://lists.sourceforge.net/lists/listinfo/mantisbt-soap-dev - whichever feels most comfortable to you. |
|
Hi I was looking for the same functionality. Please have a look at the attached patch (mantis_history_SOAP.patch) based on the "latest code in master-1.2.x branch" (commit id: deb45ecd7701e77439f7c10806f1a15c728def8a). It creates a new API function called mc_issue_get_history( username, password, issue_id ). |
|
(In reply to comment 0009936:0034450)
Hi and thanks for the patch! I'd like to include this in the next release. I have a couple of comments
I'll add some soap tests if that's not something you can easily do now once you update your contribution. |
|
Hi I added the requested security check and created the pull request with the title "New function added to retrieve bug history via API." [1] [1] http://www.mantisbt.org/bugs/view.php?id=9936 EDIT: dregad added link to PR |
|
Hi, how can I get your latest patch? what's a pull request? where can i find it? |
|
mangtas, have a look at https://github.com/mantisbt/mantisbt/pulls |
|
MantisBT: master-1.2.x f65336ce 2013-04-06 04:27 Committer: rombert Details Diff |
New function added to retrieve bug history via API. Fixes 0009936: add history information Signed-off-by: Laszlo Kovacs <winston01@freemail.hu> Signed-off-by: Robert Munteanu <robert@lmn.ro> |
Affected Issues 0009936 |
|
mod - api/soap/mantisconnect.wsdl | Diff File | ||
mod - api/soap/mc_issue_api.php | Diff File | ||
MantisBT: master 4308b1f0 2013-04-06 04:27 Committer: rombert Details Diff |
New function added to retrieve bug history via API. Fixes 0009936: add history information Signed-off-by: Laszlo Kovacs <winston01@freemail.hu> Signed-off-by: Robert Munteanu <robert@lmn.ro> |
Affected Issues 0009936 |
|
mod - api/soap/mantisconnect.wsdl | Diff File | ||
mod - api/soap/mc_issue_api.php | Diff File | ||
MantisBT: master 120257b5 2013-04-20 05:00 Details Diff |
soap api: add tests for the mc_issue_get_history call Affects 0009936: add history information |
Affected Issues 0009936 |
|
mod - tests/soap/AllTests.php | Diff File | ||
add - tests/soap/IssueHistoryTest.php | Diff File |