Skip to content

Commit

Permalink
relationship_delete() to trigger emails
Browse files Browse the repository at this point in the history
Trigger the emails from within the API rather than depending on the caller.
  • Loading branch information
vboctor committed Feb 20, 2017
1 parent 9cf0ca7 commit 8c22cbb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 39 deletions.
19 changes: 0 additions & 19 deletions api/soap/mc_issue_api.php
Expand Up @@ -1482,29 +1482,10 @@ function mc_issue_relationship_delete( $p_username, $p_password, $p_issue_id, $p
}
}

$t_bug_relationship_data = relationship_get( $p_relationship_id );
$t_rel_type = $t_bug_relationship_data->type;

# delete relationship from the DB
log_event( LOG_WEBSERVICE, 'deleting relationship id \'' . $p_relationship_id . '\'' );
relationship_delete( $p_relationship_id );

# set the rel_type for both bug and dest_bug based on $t_rel_type and on who is the dest bug
if( $p_issue_id == $t_bug_relationship_data->src_bug_id ) {
$t_bug_rel_type = $t_rel_type;
$t_dest_bug_rel_type = relationship_get_complementary_type( $t_rel_type );
} else {
$t_bug_rel_type = relationship_get_complementary_type( $t_rel_type );
$t_dest_bug_rel_type = $t_rel_type;
}

# send email and update the history for the src issue
email_relationship_deleted( $p_issue_id, $t_dest_issue_id, $t_bug_rel_type );

if( bug_exists( $t_dest_issue_id ) ) {
email_relationship_deleted( $t_dest_issue_id, $p_issue_id, $t_dest_bug_rel_type );
}

return true;
}

Expand Down
20 changes: 0 additions & 20 deletions bug_relationship_delete.php
Expand Up @@ -94,28 +94,8 @@

helper_ensure_confirmed( lang_get( 'delete_relationship_sure_msg' ), lang_get( 'delete_relationship_button' ) );

$t_bug_relationship_data = relationship_get( $f_rel_id );
$t_rel_type = $t_bug_relationship_data->type;

# delete relationship from the DB
relationship_delete( $f_rel_id );

# set the rel_type for both bug and dest_bug based on $t_rel_type and on who is the dest bug
if( $f_bug_id == $t_bug_relationship_data->src_bug_id ) {
$t_bug_rel_type = $t_rel_type;
$t_dest_bug_rel_type = relationship_get_complementary_type( $t_rel_type );
} else {
$t_bug_rel_type = relationship_get_complementary_type( $t_rel_type );
$t_dest_bug_rel_type = $t_rel_type;
}

# send email and update the history for the src issue
email_relationship_deleted( $f_bug_id, $t_dest_bug_id, $t_bug_rel_type );

if( bug_exists( $t_dest_bug_id ) ) {
email_relationship_deleted( $t_dest_bug_id, $f_bug_id, $t_dest_bug_rel_type );
}

form_security_purge( 'bug_relationship_delete' );

print_header_redirect_view( $f_bug_id );
3 changes: 3 additions & 0 deletions core/relationship_api.php
Expand Up @@ -335,13 +335,16 @@ function relationship_delete( $p_relationship_id ) {

# send email and update the history for the src issue
history_log_event_special( $t_src_bug_id, BUG_DEL_RELATIONSHIP, $t_rel_type, $t_dest_bug_id );
email_relationship_deleted( $t_src_bug_id, $t_dest_bug_id, $t_rel_type );

if( bug_exists( $t_dest_bug_id ) ) {
history_log_event_special(
$t_dest_bug_id,
BUG_DEL_RELATIONSHIP,
relationship_get_complementary_type( $t_rel_type ),
$t_src_bug_id );

email_relationship_deleted( $t_dest_bug_id, $t_src_bug_id, $t_rel_type );
}
}

Expand Down

0 comments on commit 8c22cbb

Please sign in to comment.