Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 17858aeea2ac
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7c46e2872d08
Choose a head ref
  • 6 commits
  • 4 files changed
  • 1 contributor

Commits on Dec 1, 2012

  1. Fix whitespace

    dregad committed Dec 1, 2012
    Copy the full SHA
    606ceec View commit details
  2. Copy the full SHA
    85c132d View commit details
  3. 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
    dregad committed Dec 1, 2012
    Copy the full SHA
    a414438 View commit details
  4. Simplify and improve code in manage_config_workflow_page.php

    - Avoid code duplication with a function set_color_override to determine
      override of cells bgcolors attribute
    - Use a single loop over the status enum in access_row()
    - Removed unnecessary assignments and useless code
    dregad committed Dec 1, 2012
    Copy the full SHA
    2d41753 View commit details
  5. Workflow config: delete override if identical to parent

    The code in manage_config_workflow_set.php now deletes the config
    override for the current project if the new settings are identical to
    the parent's (ALL_PROJECTS level if project, or file-level if all
    projects).
    
    Follow-up fix for issue #14496
    dregad committed Dec 1, 2012
    Copy the full SHA
    c96ca21 View commit details
  6. Define default $g_set_status_threshold for NEW to REPORTER

    This prevents incorrect highlighting of NEW status as an override in the
    Access Levels section of manage_config_workflow_page.php, when
    $g_bug_submit_status is different from default.
    
    Fixes #14496 (see atrol's bugnote ~33192 and my follow up in ~33325)
    dregad committed Dec 1, 2012
    Copy the full SHA
    7c46e28 View commit details
Showing with 181 additions and 117 deletions.
  1. +1 −1 config_defaults_inc.php
  2. +13 −4 core/access_api.php
  3. +78 −95 manage_config_workflow_page.php
  4. +89 −17 manage_config_workflow_set.php
2 changes: 1 addition & 1 deletion config_defaults_inc.php
Original file line number Diff line number Diff line change
@@ -2826,7 +2826,7 @@
* );
* @global array $g_set_status_threshold
*/
$g_set_status_threshold = array();
$g_set_status_threshold = array( NEW_ => REPORTER );

/**
* Threshold at which a user can edit his/her own bugnotes.
17 changes: 13 additions & 4 deletions core/access_api.php
Original file line number Diff line number Diff line change
@@ -554,17 +554,26 @@ function access_can_reopen_bug( $p_bug, $p_user_id = null ) {
$p_user_id = auth_get_current_user_id();
}

# If allow_reporter_reopen is enabled, then reporters can always reopen their own bugs
# If allow_reporter_reopen is enabled, then reporters can always reopen
# their own bugs as long as their access level is reporter or above
if( ON == config_get( 'allow_reporter_reopen', null, null, $p_bug->project_id )
&& bug_is_user_reporter( $p_bug->id, $p_user_id )
&& access_has_project_level( config_get( 'report_bug_threshold', null, $p_user_id, $p_bug->project_id ), $p_bug->project_id, $p_user_id )
) {
return true;
}

$t_reopen_status = config_get( 'reopen_bug_threshold', null, null, $p_bug->project_id );
$t_reopen_status_threshold = access_get_status_threshold( $t_reopen_status, $p_bug->project_id );
# Other users's access level must allow them to reopen bugs
$t_reopen_bug_threshold = config_get( 'reopen_bug_threshold', null, null, $p_bug->project_id );
if( access_has_bug_level( $t_reopen_bug_threshold, $p_bug->id, $p_user_id ) ) {
$t_reopen_status = config_get( 'bug_reopen_status', null, null, $p_bug->project_id );

return access_has_bug_level( $t_reopen_status_threshold, $p_bug->id, $p_user_id );
# User must be allowed to change status to reopen status
$t_reopen_status_threshold = access_get_status_threshold( $t_reopen_status, $p_bug->project_id );
return access_has_bug_level( $t_reopen_status_threshold, $p_bug->id, $p_user_id );
}

return false;
}

/**
173 changes: 78 additions & 95 deletions manage_config_workflow_page.php
Original file line number Diff line number Diff line change
@@ -66,35 +66,48 @@
$t_overrides = array();

function set_overrides( $p_config ) {
global $t_overrides;
if ( !in_array( $p_config, $t_overrides ) ) {
$t_overrides[] = $p_config;
}
global $t_overrides;
if( !in_array( $p_config, $t_overrides ) ) {
$t_overrides[] = $p_config;
}
}

/**
* Returns a string to define the background color attribute depending
* on the level where it's overridden
* @param int $p_level_file config file's access level
* @param int $p_level_global all projects' access level
* @param int $p_level_project current project's access level
* @return string bgcolor attribute, or '' if no color
*/
function set_colour_override( $p_level_file, $p_level_global, $p_level_project ) {
global $t_colour_global, $t_colour_project;

if ( $p_level_project != $p_level_global ) {
$t_colour = $t_colour_project;
} else if( $p_level_global != $p_level_file ) {
$t_colour = $t_colour_global;
} else {
return '';
}

return ' bgcolor="' . $t_colour . '" ';
}


# 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,
$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 ;
$t_project = isset( $t_project_workflow['exit'][$p_from_status_id][$p_to_status_id] ) ? 1 : 0;

$t_colour = '';
if ( $t_global != $t_file ) {
$t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
if ( $t_can_change_workflow ) {
set_overrides( 'status_enum_workflow' );
}
}
if ( $t_project != $t_global ) {
$t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
if ( $t_can_change_workflow ) {
set_overrides( 'status_enum_workflow' );
}
$t_colour = set_colour_override( $t_file, $t_global, $t_project );
if ( $t_can_change_workflow && $t_colour != '' ) {
set_overrides( 'status_enum_workflow' );
}
$t_value = '<td class="center"' . $t_colour . '>';

@@ -140,7 +153,7 @@ function section_begin( $p_section_name ) {
}

function capability_row( $p_from_status ) {
global $t_file_workflow, $t_global_workflow, $t_project_workflow, $t_colour_global, $t_colour_project, $t_can_change_workflow;
global $t_file_workflow, $t_global_workflow, $t_project_workflow, $t_can_change_workflow;
$t_enum_status = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) );
echo '<tr ' . helper_alternate_class() . '><td>' . string_no_break( MantisEnum::getLabel( lang_get( 'status_enum_string' ), $p_from_status ) ) . '</td>';
foreach ( $t_enum_status as $t_to_status_id => $t_to_status_label ) {
@@ -151,18 +164,9 @@ function capability_row( $p_from_status ) {
$t_global = isset( $t_global_workflow['default'][$p_from_status] ) ? $t_global_workflow['default'][$p_from_status] : 0 ;
$t_project = isset( $t_project_workflow['default'][$p_from_status] ) ? $t_project_workflow['default'][$p_from_status] : 0;

$t_colour = '';
if ( $t_global != $t_file ) {
$t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
if ( $t_can_change_workflow ) {
set_overrides( 'status_enum_workflow' );
}
}
if ( $t_project != $t_global ) {
$t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
if ( $t_can_change_workflow ) {
set_overrides( 'status_enum_workflow' );
}
$t_colour = set_colour_override( $t_file, $t_global, $t_project );
if ( $t_can_change_workflow && $t_colour != '' ) {
set_overrides( 'status_enum_workflow' );
}
echo '<td class="center"' . $t_colour . '>';
if ( $t_can_change_workflow ) {
@@ -190,24 +194,16 @@ function threshold_begin( $p_section_name ) {
}

function threshold_row( $p_threshold ) {
global $t_access, $t_can_change_flags, $t_colour_project, $t_colour_global;
global $t_access, $t_can_change_flags;

$t_file = config_get_global( $p_threshold );
$t_global = config_get( $p_threshold, null, null, ALL_PROJECTS );
$t_project = config_get( $p_threshold );
$t_can_change_threshold = $t_access >= config_get_access( $p_threshold );
$t_colour = '';
if ( $t_global != $t_file ) {
$t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
if ( $t_can_change_threshold ) {
set_overrides( $p_threshold );
}
}
if ( $t_project != $t_global ) {
$t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
if ( $t_can_change_threshold ) {
set_overrides( $p_threshold );
}

$t_colour = set_colour_override( $t_file, $t_global, $t_project );
if ( $t_can_change_threshold && $t_colour != '' ) {
set_overrides( $p_threshold );
}

echo '<tr ' . helper_alternate_class() . '><td>' . lang_get( 'desc_' . $p_threshold ) . '</td>';
@@ -239,7 +235,7 @@ function access_begin( $p_section_name ) {
}

function access_row() {
global $t_access, $t_can_change_flags, $t_colour_project, $t_colour_global;
global $t_access, $t_can_change_flags;

$t_enum_status = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) );

@@ -248,74 +244,61 @@ function access_row() {
$t_project_new = config_get( 'report_bug_threshold' );

$t_file_set = config_get_global( 'set_status_threshold' );
foreach ( $t_enum_status as $t_status => $t_status_label) {
if ( !isset( $t_file_set[$t_status] ) ) {
$t_file_set[$t_status] = config_get_global('update_bug_status_threshold');
}
}

$t_global_set = config_get( 'set_status_threshold', null, null, ALL_PROJECTS );
foreach ( $t_enum_status as $t_status => $t_status_label) {
if ( !isset( $t_file_set[$t_status] ) ) {
$t_file_set[$t_status] = config_get('update_bug_status_threshold', null, null, ALL_PROJECTS );
}
}

$t_project_set = config_get( 'set_status_threshold' );
foreach ( $t_enum_status as $t_status => $t_status_label) {
if ( !isset( $t_file_set[$t_status] ) ) {
$t_file_set[$t_status] = config_get('update_bug_status_threshold' );
}
}

foreach ( $t_enum_status as $t_status => $t_status_label) {
echo '<tr ' . helper_alternate_class() . '><td width="30%">' . string_no_break( MantisEnum::getLabel( lang_get( 'status_enum_string' ), $t_status ) ) . '</td>';
if ( config_get( 'bug_submit_status' ) == $t_status ) {
$t_level = $t_project_new;
$t_submit_status = config_get( 'bug_submit_status' );

# Print the table rows
foreach( $t_enum_status as $t_status => $t_status_label ) {

echo '<tr ' . helper_alternate_class() . '><td width="30%">'
. string_no_break( MantisEnum::getLabel( lang_get( 'status_enum_string' ), $t_status ) )
. '</td>';

if( $t_status == $t_submit_status ) {
# 'NEW' status
$t_level_project = $t_project_new;

$t_can_change = ( $t_access >= config_get_access( 'report_bug_threshold' ) );
$t_colour = '';
if ( $t_global_new != $t_file_new ) {
$t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
if ( $t_can_change ) {
set_overrides( 'report_bug_threshold' );
}
}
if ( $t_project_new != $t_global_new ) {
$t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
if ( $t_can_change ) {
set_overrides( 'report_bug_threshold' );
}
$t_colour = set_colour_override( $t_file_new, $t_global_new, $t_project_new );
if( $t_can_change && $t_colour != '' ) {
set_overrides( 'report_bug_threshold' );
}
} 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_can_change = ( $t_access >= config_get_access( 'set_status_threshold' ) );
$t_colour = '';
if ( $t_level_global != $t_level_file ) {
$t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
if ( $t_can_change ) {
set_overrides( 'set_status_threshold' );
}
# Other statuses

# File level: fallback if set_status_threshold is not defined
if( isset( $t_file_set[$t_status] ) ) {
$t_level_file = $t_file_set[$t_status];
} else {
$t_level_file = config_get_global('update_bug_status_threshold');
}
if ( $t_level != $t_level_global ) {
$t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
if ( $t_can_change ) {
set_overrides( 'set_status_threshold' );
}

$t_level_global = isset( $t_global_set[$t_status] ) ? $t_global_set[$t_status] : $t_level_file;
$t_level_project = 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 = set_colour_override( $t_level_file, $t_level_global, $t_level_project );
if( $t_can_change && $t_colour != '' ) {
set_overrides( 'set_status_threshold' );
}
}

if ( $t_can_change ) {
echo '<td' . $t_colour . '><select name="access_change_' . $t_status . '">';
print_enum_string_option_list( 'access_levels', $t_level );
print_enum_string_option_list( 'access_levels', $t_level_project );
echo '</select> </td>';
$t_can_change_flags = true;
} else {
echo '<td class="center"' . $t_colour . '>' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), $t_level ) . '</td>';
echo '<td class="center"' . $t_colour . '>'
. MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), $t_level_project )
. '</td>';
}

echo '</tr>' . "\n";
}
}
} # end function access_row

echo '<br /><br />';

Loading