|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
|
|
|
4c79b5 |
# Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Mantis is free software: you can redistribute it and/or modify
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# GNU General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# along with Mantis. If not, see <http://www.gnu.org/licenses/>.
|
|
|
4c79b5 |
|
|
|
4c79b5 |
#------------------------------
|
|
|
4c79b5 |
# $Revision: 2643 $
|
|
|
4c79b5 |
# $Author: al $
|
|
|
4c79b5 |
# $Date: 2009-06-18 19:06:27 -0400 (Thu, 18 Jun 2009) $
|
|
|
4c79b5 |
#------------------------------
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Update bug data then redirect to the appropriate viewing page
|
|
|
4c79b5 |
|
|
|
4c79b5 |
require_once( 'core.php' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_core_path = config_get( 'core_path' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
require_once( $t_core_path.'bug_api.php' );
|
|
|
4c79b5 |
require_once( $t_core_path.'bugnote_api.php' );
|
|
|
4c79b5 |
require_once( $t_core_path.'custom_field_api.php' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
form_security_validate( 'bug_update' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$f_bug_id = gpc_get_int( 'bug_id' );
|
|
|
4c79b5 |
$f_update_mode = gpc_get_bool( 'update_mode', FALSE );
|
|
|
4c79b5 |
$f_new_status = gpc_get_int( 'status', bug_get_field( $f_bug_id, 'status' ) );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_bug_data = bug_get( $f_bug_id, true );
|
|
|
4c79b5 |
if( $t_bug_data->project_id != helper_get_current_project() ) {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$g_project_override = $t_bug_data->project_id;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( ! (
|
|
|
4c79b5 |
( access_has_bug_level( access_get_status_threshold( $f_new_status, bug_get_field( $f_bug_id, 'project_id' ) ), $f_bug_id ) ) ||
|
|
|
4c79b5 |
( access_has_bug_level( config_get( 'update_bug_threshold' ) , $f_bug_id ) ) ||
|
|
|
4c79b5 |
( ( bug_get_field( $f_bug_id, 'reporter_id' ) == auth_get_current_user_id() ) &&
|
|
|
4c79b5 |
( ( ON == config_get( 'allow_reporter_reopen' ) ) ||
|
|
|
4c79b5 |
( ON == config_get( 'allow_reporter_close' ) ) ) )
|
|
|
4c79b5 |
) ) {
|
|
|
4c79b5 |
access_denied();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# extract current extended information
|
|
|
4c79b5 |
$t_old_bug_status = $t_bug_data->status;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_bug_data->reporter_id = gpc_get_int( 'reporter_id', $t_bug_data->reporter_id );
|
|
|
4c79b5 |
$t_bug_data->handler_id = gpc_get_int( 'handler_id', $t_bug_data->handler_id );
|
|
|
4c79b5 |
$t_bug_data->duplicate_id = gpc_get_int( 'duplicate_id', $t_bug_data->duplicate_id );
|
|
|
4c79b5 |
$t_bug_data->priority = gpc_get_int( 'priority', $t_bug_data->priority );
|
|
|
4c79b5 |
$t_bug_data->severity = gpc_get_int( 'severity', $t_bug_data->severity );
|
|
|
4c79b5 |
$t_bug_data->reproducibility = gpc_get_int( 'reproducibility', $t_bug_data->reproducibility );
|
|
|
4c79b5 |
$t_bug_data->status = gpc_get_int( 'status', $t_bug_data->status );
|
|
|
4c79b5 |
$t_bug_data->resolution = gpc_get_int( 'resolution', $t_bug_data->resolution );
|
|
|
4c79b5 |
$t_bug_data->projection = gpc_get_int( 'projection', $t_bug_data->projection );
|
|
|
4c79b5 |
$t_bug_data->category = gpc_get_string( 'category', $t_bug_data->category );
|
|
|
4c79b5 |
$t_bug_data->eta = gpc_get_int( 'eta', $t_bug_data->eta );
|
|
|
4c79b5 |
$t_bug_data->os = gpc_get_string( 'os', $t_bug_data->os );
|
|
|
4c79b5 |
$t_bug_data->os_build = gpc_get_string( 'os_build', $t_bug_data->os_build );
|
|
|
4c79b5 |
$t_bug_data->platform = gpc_get_string( 'platform', $t_bug_data->platform );
|
|
|
4c79b5 |
$t_bug_data->version = gpc_get_string( 'version', $t_bug_data->version );
|
|
|
4c79b5 |
$t_bug_data->build = gpc_get_string( 'build', $t_bug_data->build );
|
|
|
4c79b5 |
$t_bug_data->fixed_in_version = gpc_get_string( 'fixed_in_version', $t_bug_data->fixed_in_version );
|
|
|
4c79b5 |
$t_bug_data->target_version = gpc_get_string( 'target_version', $t_bug_data->target_version );
|
|
|
4c79b5 |
$t_bug_data->view_state = gpc_get_int( 'view_state', $t_bug_data->view_state );
|
|
|
4c79b5 |
$t_bug_data->summary = gpc_get_string( 'summary', $t_bug_data->summary );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_bug_data->description = gpc_get_string( 'description', $t_bug_data->description );
|
|
|
4c79b5 |
$t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', $t_bug_data->steps_to_reproduce );
|
|
|
4c79b5 |
$t_bug_data->additional_information = gpc_get_string( 'additional_information', $t_bug_data->additional_information );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$f_private = gpc_get_bool( 'private' );
|
|
|
4c79b5 |
$f_bugnote_text = gpc_get_string( 'bugnote_text', '' );
|
|
|
4c79b5 |
$f_time_tracking = gpc_get_string( 'time_tracking', '0:00' );
|
|
|
4c79b5 |
$f_close_now = gpc_get_string( 'close_now', false );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Handle auto-assigning
|
|
|
4c79b5 |
if ( ( NEW_ == $t_bug_data->status )
|
|
|
4c79b5 |
&& ( 0 != $t_bug_data->handler_id )
|
|
|
4c79b5 |
&& ( ON == config_get( 'auto_set_status_to_assigned' ) ) ) {
|
|
|
4c79b5 |
$t_bug_data->status = config_get( 'bug_assigned_status' );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bugnote_text ) );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_resolved = config_get( 'bug_resolved_status_threshold' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_custom_status_label = "update";
|
|
|
4c79b5 |
if ( $t_bug_data->status == $t_resolved ) {
|
|
|
4c79b5 |
$t_custom_status_label = "resolved";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if ( $t_bug_data->status == CLOSED ) {
|
|
|
4c79b5 |
$t_custom_status_label = "closed";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id );
|
|
|
4c79b5 |
foreach( $t_related_custom_field_ids as $t_id ) {
|
|
|
4c79b5 |
$t_def = custom_field_get_definition( $t_id );
|
|
|
4c79b5 |
$t_custom_field_value = gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], null );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Only update the field if it would have been display for editing
|
|
|
4c79b5 |
if( !( ( ! $f_update_mode && $t_def['require_' . $t_custom_status_label] ) ||
|
|
|
4c79b5 |
( ! $f_update_mode && $t_def['display_' . $t_custom_status_label] && in_array( $t_custom_status_label, array( "resolved", "closed" ) ) ) ||
|
|
|
4c79b5 |
( $f_update_mode && $t_def['display_update'] ) ||
|
|
|
4c79b5 |
( $f_update_mode && $t_def['require_update'] ) ) ) {
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Only update the field if it is posted
|
|
|
4c79b5 |
# ( will fail in custom_field_set_value(), if it was required )
|
|
|
4c79b5 |
if ( $t_custom_field_value === null ) {
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Do not set custom field value if user has no write access.
|
|
|
4c79b5 |
if( !custom_field_has_write_access( $t_id, $f_bug_id ) ) {
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $t_def['require_' . $t_custom_status_label] && ( gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], '' ) == '' ) ) {
|
|
|
4c79b5 |
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
|
|
|
4c79b5 |
trigger_error( ERROR_EMPTY_FIELD, ERROR );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if ( !custom_field_set_value( $t_id, $f_bug_id, $t_custom_field_value ) ) {
|
|
|
4c79b5 |
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
|
|
|
4c79b5 |
trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_notify = true;
|
|
|
4c79b5 |
$t_bug_note_set = false;
|
|
|
4c79b5 |
if ( ( $t_old_bug_status != $t_bug_data->status ) && ( FALSE == $f_update_mode ) ) {
|
|
|
4c79b5 |
# handle status transitions that come from pages other than bug_*update_page.php
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ( $t_bug_data->status ) {
|
|
|
4c79b5 |
case $t_resolved:
|
|
|
4c79b5 |
# bug_resolve updates the status, fixed_in_version, resolution, handler_id and bugnote and sends message
|
|
|
4c79b5 |
bug_resolve( $f_bug_id, $t_bug_data->resolution, $t_bug_data->fixed_in_version,
|
|
|
4c79b5 |
$f_bugnote_text, $t_bug_data->duplicate_id, $t_bug_data->handler_id,
|
|
|
4c79b5 |
$f_private, $f_time_tracking );
|
|
|
4c79b5 |
$t_notify = false;
|
|
|
4c79b5 |
$t_bug_note_set = true;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $f_close_now ) {
|
|
|
4c79b5 |
bug_set_field( $f_bug_id, 'status', CLOSED );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// update bug data with fields that may be updated inside bug_resolve(), otherwise changes will be overwritten
|
|
|
4c79b5 |
// in bug_update() call below.
|
|
|
4c79b5 |
$t_bug_data->handler_id = bug_get_field( $f_bug_id, 'handler_id' );
|
|
|
4c79b5 |
$t_bug_data->status = bug_get_field( $f_bug_id, 'status' );
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case CLOSED:
|
|
|
4c79b5 |
# bug_close updates the status and bugnote and sends message
|
|
|
4c79b5 |
bug_close( $f_bug_id, $f_bugnote_text, $f_private, $f_time_tracking );
|
|
|
4c79b5 |
$t_notify = false;
|
|
|
4c79b5 |
$t_bug_note_set = true;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case config_get( 'bug_reopen_status' ):
|
|
|
4c79b5 |
if ( $t_old_bug_status >= $t_resolved ) {
|
|
|
4c79b5 |
bug_set_field( $f_bug_id, 'handler_id', $t_bug_data->handler_id );
|
|
|
4c79b5 |
# bug_reopen updates the status and bugnote and sends message
|
|
|
4c79b5 |
bug_reopen( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private );
|
|
|
4c79b5 |
$t_notify = false;
|
|
|
4c79b5 |
$t_bug_note_set = true;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// update bug data with fields that may be updated inside bug_resolve(), otherwise changes will be overwritten
|
|
|
4c79b5 |
// in bug_update() call below.
|
|
|
4c79b5 |
$t_bug_data->status = bug_get_field( $f_bug_id, 'status' );
|
|
|
4c79b5 |
$t_bug_data->resolution = bug_get_field( $f_bug_id, 'resolution' );
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
} # else fall through to default
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Add a bugnote if there is one
|
|
|
4c79b5 |
if ( !$t_bug_note_set ) {
|
|
|
4c79b5 |
bugnote_add( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private, 0, '', NULL, FALSE );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
bug_update( $f_bug_id, $t_bug_data, true, ( false == $t_notify ) );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
helper_call_custom_function( 'issue_update_notify', array( $f_bug_id ) );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
print_successful_redirect_to_bug( $f_bug_id );
|
|
|
4c79b5 |
?>
|