From a4144388ea654cd7d5b6d9d014fa7a18c36dbee4 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Sat, 13 Oct 2012 00:37:06 +0200 Subject: [PATCH] Manage config workflow page does not reflect actual config The code did not properly reflect the configuration state when building the Access Levels form, if the minimum access level was defined using update_bug_status_threshold and set_status_threshold wass empty, showing 'viewer' for each status except 'new'. Consequently, saving the page without changes would cause the config to be saved with all access levels as 'viewer'. Fixes #14496 --- manage_config_workflow_page.php | 7 ++++--- manage_config_workflow_set.php | 28 ++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/manage_config_workflow_page.php b/manage_config_workflow_page.php index 5847bcf7ed..4aba20f44d 100644 --- a/manage_config_workflow_page.php +++ b/manage_config_workflow_page.php @@ -287,9 +287,10 @@ function access_row() { } } } else { - $t_level = ( isset( $t_project_set[$t_status] ) ? $t_project_set[$t_status] : 0 ); - $t_level_global = ( isset( $t_global_set[$t_status] ) ? $t_global_set[$t_status] : 0 ); - $t_level_file = ( isset( $t_file_set[$t_status] ) ? $t_file_set[$t_status] : 0 ); + $t_level_file = ( isset( $t_file_set[$t_status] ) ? $t_file_set[$t_status] : false ); + $t_level_global = ( isset( $t_global_set[$t_status] ) ? $t_global_set[$t_status] : $t_level_file ); + $t_level = ( isset( $t_project_set[$t_status] ) ? $t_project_set[$t_status] : $t_level_global ); + $t_can_change = ( $t_access >= config_get_access( 'set_status_threshold' ) ); $t_colour = ''; if ( $t_level_global != $t_level_file ) { diff --git a/manage_config_workflow_set.php b/manage_config_workflow_set.php index 4d8b8fa717..db30000fd9 100644 --- a/manage_config_workflow_set.php +++ b/manage_config_workflow_set.php @@ -87,8 +87,8 @@ list( $t_from, $t_to ) = explode( ':', $t_transition ); $t_matrix[$t_from][$t_to] = ''; } - $t_statuses = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) ); - foreach( $t_statuses as $t_state => $t_label) { + $t_enum_status = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) ); + foreach( $t_enum_status as $t_state => $t_label) { $t_workflow_row = ''; $t_default = gpc_get_int( 'default_' . $t_state ); if ( isset( $t_matrix[$t_state] ) && isset( $t_matrix[$t_state][$t_default] ) ) { @@ -124,22 +124,38 @@ # get changes to access level to change these values $f_access = gpc_get( 'status_access' ); + # Build default + $t_file_set = config_get_global( 'set_status_threshold' ); + $t_bug_submit_status = config_get( 'bug_submit_status' ); + foreach ( $t_enum_status as $t_status => $t_status_label) { + if ( !isset( $t_file_set[$t_status] ) ) { + if ( $t_bug_submit_status == $t_status ) { + $t_file_set[$t_status] = config_get_global('report_bug_threshold'); + } else { + $t_file_set[$t_status] = config_get_global('update_bug_status_threshold'); + } + } + } + # walk through the status labels to set the status threshold - $t_enum_status = explode( ',', config_get( 'status_enum_string' ) ); $t_set_status = array(); - foreach( $t_statuses as $t_status_id => $t_status_label) { + foreach( $t_enum_status as $t_status_id => $t_status_label) { $f_level = gpc_get( 'access_change_' . $t_status_id ); if ( config_get( 'bug_submit_status' ) == $t_status_id ) { if ( (int)$f_level != config_get( 'report_bug_threshold' ) ) { config_set( 'report_bug_threshold', (int)$f_level, ALL_USERS, $t_project, $f_access ); } + unset( $t_file_set[$t_status_id] ); } else { $t_set_status[$t_status_id] = (int)$f_level; } } - if ( ( $t_set_status != config_get( 'set_status_threshold' ) ) - || ( $f_access != config_get_access( 'status_enum_workflow' ) ) ) { + if( ( $t_set_status != $t_file_set + && $t_set_status != config_get( 'set_status_threshold' ) + ) + || $f_access != config_get_access( 'status_enum_workflow' ) + ) { config_set( 'set_status_threshold', $t_set_status, ALL_USERS, $t_project, $f_access ); } }