diff --git a/bug_update.php b/bug_update.php index 6d0fd71930..d8fbc9fcfd 100644 --- a/bug_update.php +++ b/bug_update.php @@ -311,6 +311,7 @@ if ( $t_bug_note->note && config_get( 'reassign_on_feedback' ) && $t_existing_bug->status === config_get( 'bug_feedback_status' ) && + $t_updated_bug->status <= config_get( 'bug_feedback_status' ) && $t_updated_bug->reporter_id === auth_get_current_user_id() ) { if ( $t_updated_bug->handler_id !== NO_USER ) { $t_updated_bug->status = config_get( 'bug_assigned_status' ); diff --git a/bugnote_add.php b/bugnote_add.php index 377c915cff..6c2dd326c0 100644 --- a/bugnote_add.php +++ b/bugnote_add.php @@ -63,25 +63,40 @@ $g_project_override = $t_bug->project_id; } -if ( bug_is_readonly( $f_bug_id ) ) { - error_parameters( $f_bug_id ); +if ( bug_is_readonly( $t_bug->id ) ) { + error_parameters( $t_bug->id ); trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR ); } -access_ensure_bug_level( config_get( 'add_bugnote_threshold' ), $f_bug_id ); +access_ensure_bug_level( config_get( 'add_bugnote_threshold' ), $t_bug->id ); if ( $f_private ) { - access_ensure_bug_level( config_get( 'set_view_status_threshold' ), $f_bug_id ); + access_ensure_bug_level( config_get( 'set_view_status_threshold' ), $t_bug->id ); } // We always set the note time to BUGNOTE, and the API will overwrite it with TIME_TRACKING // if $f_time_tracking is not 0 and the time tracking feature is enabled. -$t_bugnote_id = bugnote_add( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private, BUGNOTE ); +$t_bugnote_id = bugnote_add( $t_bug->id, $f_bugnote_text, $f_time_tracking, $f_private, BUGNOTE ); if ( !$t_bugnote_id ) { error_parameters( lang_get( 'bugnote' ) ); trigger_error( ERROR_EMPTY_FIELD, ERROR ); } +# Handle the reassign on feedback feature. Note that this feature generally +# won't work very well with custom workflows as it makes a lot of assumptions +# that may not be true. It assumes you don't have any statuses in the workflow +# between 'bug_submit_status' and 'bug_feedback_status'. It assumes you only +# have one feedback, assigned and submitted status. +if ( config_get( 'reassign_on_feedback' ) && + $t_bug->status === config_get( 'bug_feedback_status' ) && + $t_bug->reporter_id === auth_get_current_user_id() ) { + if ( $t_bug->handler_id !== NO_USER ) { + bug_set_field( $t_bug->id, 'status', config_get( 'bug_assigned_status' ) ); + } else { + bug_set_field( $t_bug->id, 'status', config_get( 'bug_submit_status' ) ); + } +} + form_security_purge( 'bugnote_add' ); -print_successful_redirect_to_bug( $f_bug_id ); +print_successful_redirect_to_bug( $t_bug->id ); diff --git a/core/bugnote_api.php b/core/bugnote_api.php index 2b046a78ea..4f90004fd6 100644 --- a/core/bugnote_api.php +++ b/core/bugnote_api.php @@ -210,18 +210,6 @@ function bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_ # log new bug history_log_event_special( $p_bug_id, BUGNOTE_ADDED, bugnote_format_id( $t_bugnote_id ) ); - # if it was FEEDBACK its NEW_ now - if ( config_get( 'reassign_on_feedback' ) && - bug_get_field( $p_bug_id, 'status' ) == config_get( 'bug_feedback_status' ) && - bug_get_field( $p_bug_id, 'reporter_id' ) == $c_user_id ) { - - if ( bug_get_field( $p_bug_id, 'handler_id') == 0 ) { - bug_set_field( $p_bug_id, 'status', config_get( 'bug_submit_status' ) ); - } else { - bug_set_field( $p_bug_id, 'status', config_get( 'bug_assigned_status' ) ); - } - } - # Event integration event_signal( 'EVENT_BUGNOTE_ADD', array( $p_bug_id, $t_bugnote_id ) );