Permalink
Browse files

soap api: set $g_project_override for all applicable mc_issue and

mc_project methods

Fixes #16028: Adding note via webservice generates wrong email content
for assigned user 

Conflicts:
	api/soap/mc_issue_api.php
  • Loading branch information...
1 parent c4f2d6c commit c9c034119d3e9a96958a9fb61f95c3b3a9b1c90a @rombert rombert committed Jun 30, 2013
Showing with 95 additions and 9 deletions.
  1. +32 −3 api/soap/mc_issue_api.php
  2. +63 −6 api/soap/mc_project_api.php
@@ -45,6 +45,7 @@ function mc_issue_exists( $p_username, $p_password, $p_issue_id ) {
* @return Array that represents an IssueData structure
*/
function mc_issue_get( $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 ) {
@@ -58,6 +59,7 @@ function mc_issue_get( $p_username, $p_password, $p_issue_id ) {
}
$t_project_id = bug_get_field( $p_issue_id, 'project_id' );
+ $g_project_override = $t_project_id;
if( !mci_has_readonly_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}
@@ -406,6 +408,8 @@ function mci_issue_set_monitors( $p_issue_id , $p_requesting_user_id, $p_monitor
* @return integer The biggest used issue id.
*/
function mc_issue_get_biggest_id( $p_username, $p_password, $p_project_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();
@@ -460,6 +464,7 @@ function mc_issue_get_biggest_id( $p_username, $p_password, $p_project_id ) {
if( $t_project_id == -1 ) {
$t_project_id = helper_get_current_project();
}
+ $g_project_override = $t_project_id;
if(( $t_project_id > 0 ) && !project_exists( $t_project_id ) ) {
return SoapObjectsFactory::newSoapFault( 'Client', "Project '$t_project_id' does not exist." );
@@ -486,6 +491,8 @@ function mc_issue_get_biggest_id( $p_username, $p_password, $p_project_id ) {
* @return integer The id of the issue with the given summary, 0 if there is no such issue.
*/
function mc_issue_get_id_from_summary( $p_username, $p_password, $p_summary ) {
+ 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();
@@ -505,6 +512,7 @@ function mc_issue_get_id_from_summary( $p_username, $p_password, $p_summary ) {
while(( $row = db_fetch_array( $result ) ) !== false ) {
$t_issue_id = (int) $row['id'];
$t_project_id = bug_get_field( $t_issue_id, 'project_id' );
+ $g_project_override = $t_project_id;
if( mci_has_readonly_access( $t_user_id, $t_project_id ) &&
access_has_bug_level( VIEWER, $t_issue_id, $t_user_id ) ) {
@@ -934,7 +942,8 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) {
}
function mc_issue_set_tags ( $p_username, $p_password, $p_issue_id, $p_tags ) {
-
+ 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();
@@ -945,6 +954,7 @@ function mc_issue_set_tags ( $p_username, $p_password, $p_issue_id, $p_tags ) {
}
$t_project_id = bug_get_field( $p_issue_id, 'project_id' );
+ $g_project_override = $t_project_id;
if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
@@ -968,6 +978,8 @@ function mc_issue_set_tags ( $p_username, $p_password, $p_issue_id, $p_tags ) {
* @return boolean True if the issue has been deleted successfully, false otherwise.
*/
function mc_issue_delete( $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();
@@ -978,6 +990,8 @@ function mc_issue_delete( $p_username, $p_password, $p_issue_id ) {
}
$t_project_id = bug_get_field( $p_issue_id, 'project_id' );
+ $g_project_override = $t_project_id;
+
if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}
@@ -999,6 +1013,8 @@ function mc_issue_delete( $p_username, $p_password, $p_issue_id ) {
* @return integer The id of the added note.
*/
function mc_issue_note_add( $p_username, $p_password, $p_issue_id, $p_note ) {
+ 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();
@@ -1019,6 +1035,8 @@ function mc_issue_note_add( $p_username, $p_password, $p_issue_id, $p_note ) {
}
$t_project_id = bug_get_field( $p_issue_id, 'project_id' );
+ $g_project_override = $t_project_id;
+
if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}
@@ -1056,6 +1074,8 @@ function mc_issue_note_add( $p_username, $p_password, $p_issue_id, $p_note ) {
* @return true: success, false: failure
*/
function mc_issue_note_delete( $p_username, $p_password, $p_issue_note_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();
@@ -1071,6 +1091,7 @@ function mc_issue_note_delete( $p_username, $p_password, $p_issue_note_id ) {
$t_issue_id = bugnote_get_field( $p_issue_note_id, 'bug_id' );
$t_project_id = bug_get_field( $t_issue_id, 'project_id' );
+ $g_project_override = $t_project_id;
if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}
@@ -1104,6 +1125,8 @@ function mc_issue_note_delete( $p_username, $p_password, $p_issue_note_id ) {
* @return true on success, false on failure
*/
function mc_issue_note_update( $p_username, $p_password, $p_note ) {
+ global $g_project_override;
+
$t_user_id = mci_check_login( $p_username, $p_password );
if ( $t_user_id === false ) {
@@ -1128,6 +1151,7 @@ function mc_issue_note_update( $p_username, $p_password, $p_note ) {
$t_issue_id = bugnote_get_field( $t_issue_note_id, 'bug_id' );
$t_project_id = bug_get_field( $t_issue_id, 'project_id' );
+ $g_project_override = $t_project_id;
if ( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
@@ -1176,7 +1200,8 @@ function mc_issue_note_update( $p_username, $p_password, $p_note ) {
* @return integer The id of the added relationship.
*/
function mc_issue_relationship_add( $p_username, $p_password, $p_issue_id, $p_relationship ) {
- $t_user_id = mci_check_login( $p_username, $p_password );
+ global $g_project_override;
+ $t_user_id = mci_check_login( $p_username, $p_password );
$p_relationship = SoapObjectsFactory::unwrapObject( $p_relationship );
@@ -1188,6 +1213,7 @@ function mc_issue_relationship_add( $p_username, $p_password, $p_issue_id, $p_re
}
$t_project_id = bug_get_field( $p_issue_id, 'project_id' );
+ $g_project_override = $t_project_id;
if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}
@@ -1254,13 +1280,16 @@ function mc_issue_relationship_add( $p_username, $p_password, $p_issue_id, $p_re
* @return true: success, false: failure
*/
function mc_issue_relationship_delete( $p_username, $p_password, $p_issue_id, $p_relationship_id ) {
- $t_user_id = mci_check_login( $p_username, $p_password );
+ 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_project_id = bug_get_field( $p_issue_id, 'project_id' );
+ $g_project_override = $t_project_id;
if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}
Oops, something went wrong.

0 comments on commit c9c0341

Please sign in to comment.