Skip to content

Commit

Permalink
New function added to retrieve bug history via API.
Browse files Browse the repository at this point in the history
Fixes #9936: add history information

Signed-off-by: Laszlo Kovacs <winston01@freemail.hu>
Signed-off-by: Robert Munteanu <robert@lmn.ro>
  • Loading branch information
winston01 authored and rombert committed Jun 30, 2013
1 parent c9c0341 commit 4308b1f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
37 changes: 36 additions & 1 deletion api/soap/mantisconnect.wsdl
Expand Up @@ -165,6 +165,25 @@
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="HistoryData">
<xsd:all>
<xsd:element name="date" type="xsd:integer"/>
<xsd:element name="userid" type="xsd:integer"/>
<xsd:element name="username" type="xsd:string"/>
<xsd:element name="field" type="xsd:string"/>
<xsd:element name="type" type="xsd:integer"/>
<xsd:element name="old_value" type="xsd:string"/>
<xsd:element name="new_value" type="xsd:string"
/>
</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"/>
Expand Down Expand Up @@ -436,6 +455,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" />
Expand Down Expand Up @@ -854,6 +879,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"/>
Expand Down Expand Up @@ -1187,6 +1217,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>
Expand Down Expand Up @@ -1438,4 +1473,4 @@
<soap:address location="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php"/>
</port>
</service>
</definitions>
</definitions>
42 changes: 42 additions & 0 deletions api/soap/mc_issue_api.php
Expand Up @@ -121,6 +121,48 @@ function mc_issue_get( $p_username, $p_password, $p_issue_id ) {
return $t_issue_data;
}

/**
* 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 ) {
global $g_project_override;

$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 );
}
$g_project_override = $t_project_id;

if( !access_has_bug_level( VIEWER, $p_issue_id, $t_user_id ) ){
return mci_soap_fault_access_denied( $t_user_id );
}

$t_user_access_level = user_get_access_level( $t_user_id, $t_project_id );
if( !access_compare_level( $t_user_access_level, config_get( 'view_history_threshold' ) ) ){
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
*
Expand Down

0 comments on commit 4308b1f

Please sign in to comment.