Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5ccae29
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9e3d771
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Dec 5, 2011

  1. Allow getting/setting tags as part of the mc_issue(get/set/add) methods

    Fixes #13446: Add tags support to soap api
    rombert committed Dec 5, 2011

    Verified

    This commit was signed with the committer’s verified signature.
    anthonyfok Anthony Fok
    Copy the full SHA
    617fba5 View commit details
  2. Copy the full SHA
    5882a62 View commit details
  3. SOAP API: tag fixes

    - add mc_issue_set_tags
    - use proper access checks when attaching and detaching tags
    
    Fixes #13446: Add tags support to soap api
    rombert committed Dec 5, 2011
    Copy the full SHA
    9e3d771 View commit details
Showing with 76 additions and 8 deletions.
  1. +16 −0 api/soap/mantisconnect.php
  2. +24 −2 api/soap/mc_issue_api.php
  3. +11 −5 api/soap/mc_tag_api.php
  4. +25 −1 tests/soap/TagTest.php
16 changes: 16 additions & 0 deletions api/soap/mantisconnect.php
Original file line number Diff line number Diff line change
@@ -898,6 +898,22 @@
'Update Issue method.'
);

$l_oServer->register( 'mc_issue_set_tags',
array(
'username' => 'xsd:string',
'password' => 'xsd:string',
'issue_id' => 'xsd:integer',
'tags' => 'tns:TagDataArray'
),
array(
'return' => 'xsd:boolean'
),
$t_namespace,
false, false, false,
'Sets the tags for a specified issue.'
);


### mc_issue_delete
$l_oServer->register( 'mc_issue_delete',
array(
26 changes: 24 additions & 2 deletions api/soap/mc_issue_api.php
Original file line number Diff line number Diff line change
@@ -672,7 +672,7 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) {
}

if ( isset ( $p_issue['tags']) && is_array ( $p_issue['tags']) ) {
mci_tag_set_for_issue( $t_issue_id, $p_issue['tags'] );
mci_tag_set_for_issue( $t_issue_id, $p_issue['tags'], $t_user_id );
}

email_new_bug( $t_issue_id );
@@ -879,14 +879,36 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) {
}

if ( isset ( $p_issue['tags']) && is_array ( $p_issue['tags']) ) {
mci_tag_set_for_issue( $p_issue_id, $p_issue['tags'] );
mci_tag_set_for_issue( $p_issue_id, $p_issue['tags'] , $t_user_id );
}

# submit the issue
return $t_bug_data->update( /* update_extended */ true, /* bypass_email */ true );

}

function mc_issue_set_tags ( $p_username, $p_password, $p_issue_id, $p_tags ) {

$t_user_id = mci_check_login( $p_username, $p_password );
if( $t_user_id === false ) {
return mci_soap_fault_login_failed();
}

if( !bug_exists( $p_issue_id ) ) {
return new soap_fault( 'Client', '', "Issue '$p_issue_id' does not exist." );
}

$t_project_id = bug_get_field( $p_issue_id, 'project_id' );

if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}

mci_tag_set_for_issue( $p_issue_id, $p_tags, $t_user_id );

return true;
}

/**
* Delete the specified issue.
*
16 changes: 11 additions & 5 deletions api/soap/mc_tag_api.php
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ function mc_tag_delete( $p_username, $p_password, $p_tag_id ) {
return tag_delete( $p_tag_id );
}

function mci_tag_set_for_issue ( $p_issue_id, $p_tags ) {
function mci_tag_set_for_issue ( $p_issue_id, $p_tags, $p_user_id ) {

$t_tag_ids_to_attach = array();
$t_tag_ids_to_detach = array();
@@ -147,9 +147,15 @@ function mci_tag_set_for_issue ( $p_issue_id, $p_tags ) {
}
}

foreach ( $t_tag_ids_to_detach as $t_tag_id )
tag_bug_detach( $t_tag_id, $p_issue_id, true);
foreach ( $t_tag_ids_to_detach as $t_tag_id ) {
if ( access_has_bug_level ( config_get('tag_detach_threshold'), $p_issue_id, $p_user_id ) ) {
tag_bug_detach( $t_tag_id, $p_issue_id, true);
}
}

foreach ( $t_tag_ids_to_attach as $t_tag_id )
tag_bug_attach( $t_tag_id, $p_issue_id, true);
foreach ( $t_tag_ids_to_attach as $t_tag_id ) {
if ( access_has_bug_level ( config_get('tag_attach_threshold'), $p_issue_id, $p_user_id ) ) {
tag_bug_attach( $t_tag_id, $p_issue_id, true);
}
}
}
26 changes: 25 additions & 1 deletion tests/soap/TagTest.php
Original file line number Diff line number Diff line change
@@ -132,8 +132,32 @@ public function testCreateTagWithExistingName() {
$this->client->mc_tag_add ( $this->userName, $this->password, $tagToCreate );
self::fail("Expected an error");
} catch ( SoapFault $e ) {
echo 'Testing';
$this->assertContains( "A tag with the same name already exists", $e->getMessage() );
}
}

/**
* Tests that setting tags on issues works
*/
public function testSetTagsOnIssue() {

// create tag
$tagToCreate = array (
'name' => 'TagTest.testCreateTagWithExistingName'
);
$tagId = $this->client->mc_tag_add ( $this->userName, $this->password, $tagToCreate );
$this->deleteTagAfterRun( $tagId );

// create issue
$issueToCreate = $this->getIssueToAdd('testTestTagsOnIssue');
$issueId = $this->client->mc_issue_add ( $this->userName, $this->password, $issueToCreate );
$this->deleteAfterRun( $issueId );

// set tags
$this->client->mc_issue_set_tags ( $this->userName, $this->password, $issueId, array ( array ( 'id' => $tagId ) ) );

$issue = $this->client->mc_issue_get( $this->userName, $this->password, $issueId );

self::assertEquals( 1, count ( $issue->tags ) );
}
}