Skip to content

Commit

Permalink
Fix Workflow config to acount for complex thresholds
Browse files Browse the repository at this point in the history
In workflow transitions configuration page, the "Minimum Access Level to
Change to this Status", for bug submitted status, is linked to the
report_bug_threshold option.
If the threshold is configured as an array, the simple dropdown select
cant be used to represent or modify this value, so don't allow it to be
editable.

Fixes: #21581
  • Loading branch information
cproensa committed Aug 4, 2016
1 parent 06af376 commit 083ae28
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
10 changes: 7 additions & 3 deletions manage_config_workflow_page.php
Expand Up @@ -327,7 +327,8 @@ function access_row() {

$t_file_new = config_get_global( 'report_bug_threshold' );
$t_global_new = config_get( 'report_bug_threshold', null, ALL_USERS, ALL_PROJECTS );
$t_project_new = config_get( 'report_bug_threshold' );
$t_report_bug_threshold = config_get( 'report_bug_threshold' );
$t_project_new = access_threshold_min_level( $t_report_bug_threshold );

$t_file_set = config_get_global( 'set_status_threshold' );
$t_global_set = config_get( 'set_status_threshold', null, ALL_USERS, ALL_PROJECTS );
Expand All @@ -344,8 +345,11 @@ function access_row() {
# 'NEW' status
$t_level_project = $t_project_new;

$t_can_change = ( $g_access >= config_get_access( 'report_bug_threshold' ) );
$t_color = set_color_override( $t_file_new, $t_global_new, $t_project_new );
# If report_bug_threshold is an array (instead of an integer value), the input is not editable
# because it must be configured in manage_config_work_threshold_page.
$t_can_change = ( $g_access >= config_get_access( 'report_bug_threshold' ) )
&& !is_array( $t_report_bug_threshold );
$t_color = set_color_override( $t_file_new, $t_global_new, $t_report_bug_threshold );
set_overrides( 'report_bug_threshold', $t_can_change, $t_color );
} else {
# Other statuses
Expand Down
21 changes: 12 additions & 9 deletions manage_config_workflow_set.php
Expand Up @@ -215,17 +215,20 @@ function config_get_access_parent( $p_project, $p_option ) {
# walk through the status labels to set the status threshold
$t_set_new = array();
foreach( $t_enum_status as $t_status_id => $t_status_label ) {
$f_level = gpc_get_int( 'access_change_' . $t_status_id );
if( config_get( 'bug_submit_status' ) == $t_status_id ) {
if( $f_level != $t_set_parent[$t_status_id] ) {
config_set( 'report_bug_threshold', (int)$f_level, ALL_USERS, $t_project, $f_access );
$f_level = gpc_get_int( 'access_change_' . $t_status_id, -1 );
# Only process those inputs that exists, since not all access_change_<status> may have been editable.
if( $f_level > -1 ) {
if( config_get( 'bug_submit_status' ) == $t_status_id ) {
if( $f_level != $t_set_parent[$t_status_id] ) {
config_set( 'report_bug_threshold', (int)$f_level, ALL_USERS, $t_project, $f_access );
} else {
config_delete( 'report_bug_threshold', ALL_USERS, $t_project );
}
unset( $t_set_parent[$t_status_id] );
unset( $t_set_current[$t_status_id] );
} else {
config_delete( 'report_bug_threshold', ALL_USERS, $t_project );
$t_set_new[$t_status_id] = $f_level;
}
unset( $t_set_parent[$t_status_id] );
unset( $t_set_current[$t_status_id] );
} else {
$t_set_new[$t_status_id] = $f_level;
}
}

Expand Down

0 comments on commit 083ae28

Please sign in to comment.