Skip to content

Commit

Permalink
Manage config workflow page does not reflect actual config
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dregad committed Oct 13, 2012
1 parent 7512b03 commit d893ca3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
5 changes: 3 additions & 2 deletions manage_config_workflow_page.php
Expand Up @@ -318,9 +318,10 @@ function access_row() {
}
}
} else {
$t_level = ( isset( $t_project_set[$t_status] ) ? $t_project_set[$t_status] : false );
$t_level_global = ( isset( $t_global_set[$t_status] ) ? $t_global_set[$t_status] : false );
$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 ) {
Expand Down
28 changes: 22 additions & 6 deletions manage_config_workflow_set.php
Expand Up @@ -64,8 +64,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] ) ) {
Expand Down Expand Up @@ -101,22 +101,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 );
}
}
Expand Down

0 comments on commit d893ca3

Please sign in to comment.