Skip to content

Commit

Permalink
Fix workflow transition to status reopened always checked
Browse files Browse the repository at this point in the history
In manage_config_workflow_page.php, the code was always showing the
'reopened' states as checked regardless of the actual values stored in
the database.

This was due to storing the 'reopened' label within the array of values
used to build the table to display, which consequently were always set.

The code that initializes the labels has been removed from function
parse_workflow(), and the logic is now handled directly in show_flag(),
with globally initialized variables for better performance.

Fixes #12129
  • Loading branch information
dregad committed Apr 4, 2012
1 parent 974f363 commit 08b00de
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions manage_config_workflow_page.php
Expand Up @@ -80,10 +80,7 @@ function parse_workflow( $p_enum_workflow ) {
$t_exit[0][$t_status] = $t_new_label;
}

# add user defined arcs and implicit reopen arcs
$t_reopen = config_get( 'bug_reopen_status' );
$t_reopen_label = MantisEnum::getLabel( lang_get( 'resolution_enum_string' ), config_get( 'bug_reopen_resolution' ) );
$t_resolved_status = config_get( 'bug_resolved_status_threshold' );
# add user defined arcs
$t_default = array();
foreach ( $t_status_arr as $t_status => $t_status_label ) {
if ( isset( $p_enum_workflow[$t_status] ) ) {
Expand All @@ -98,10 +95,6 @@ function parse_workflow( $p_enum_workflow ) {
} else {
$t_exit[$t_status] = array();
}
if ( $t_status >= $t_resolved_status ) {
$t_exit[$t_status][$t_reopen] = $t_reopen_label;
$t_entry[$t_reopen][$t_status] = $t_reopen_label;
}
if ( !isset( $t_entry[$t_status] ) ) {
$t_entry[$t_status] = array();
}
Expand All @@ -112,7 +105,10 @@ function parse_workflow( $p_enum_workflow ) {

# Get the value associated with the specific action and flag.
function show_flag( $p_from_status_id, $p_to_status_id ) {
global $t_can_change_workflow, $t_overrides, $t_file_workflow, $t_global_workflow, $t_project_workflow, $t_colour_global, $t_colour_project;
global $t_can_change_workflow, $t_overrides,
$t_file_workflow, $t_global_workflow, $t_project_workflow,
$t_colour_global, $t_colour_project,
$t_resolved_status, $t_reopen_status, $t_reopen_label;
if ( $p_from_status_id <> $p_to_status_id ) {
$t_file = isset( $t_file_workflow['exit'][$p_from_status_id][$p_to_status_id] ) ? 1 : 0 ;
$t_global = isset( $t_global_workflow['exit'][$p_from_status_id][$p_to_status_id] ) ? 1 : 0 ;
Expand All @@ -134,7 +130,6 @@ function show_flag( $p_from_status_id, $p_to_status_id ) {
$t_value = '<td class="center"' . $t_colour . '>';

$t_flag = ( 1 == $t_project );
$t_label = $t_flag ? $t_project_workflow['exit'][$p_from_status_id][$p_to_status_id] : '';

if ( $t_can_change_workflow ) {
$t_flag_name = $p_from_status_id . ':' . $p_to_status_id;
Expand All @@ -144,8 +139,9 @@ function show_flag( $p_from_status_id, $p_to_status_id ) {
$t_value .= $t_flag ? '<img src="images/ok.gif" width="20" height="15" title="X" alt="X" />' : '&#160;';
}

if ( $t_flag && ( '' != $t_label ) ) {
$t_value .= '<br />(' . $t_label . ')';
# Add 'reopened' label
if ( $p_from_status_id >= $t_resolved_status && $p_to_status_id == $t_reopen_status ) {
$t_value .= "<br />($t_reopen_label)";
}
} else {
$t_value = '<td>&#160;';
Expand Down Expand Up @@ -442,6 +438,11 @@ function access_row() {
echo '</table><br /><br />';
}

# Initialization for 'reopened' label handling
$t_resolved_status = config_get( 'bug_resolved_status_threshold' );
$t_reopen_status = config_get( 'bug_reopen_status' );
$t_reopen_label = MantisEnum::getLabel( lang_get( 'resolution_enum_string' ), config_get( 'bug_reopen_resolution' ) );

# display the graph as a matrix
section_begin( lang_get( 'workflow' ) );
foreach ( $t_status_arr as $t_from_status => $t_from_label) {
Expand Down

0 comments on commit 08b00de

Please sign in to comment.