From 3ac08e57ecc54245cb0901f5bb9de63b8d2c679d Mon Sep 17 00:00:00 2001 From: Dominik Blunk Date: Thu, 22 Sep 2011 15:15:06 +0200 Subject: [PATCH] Fixed: "Hide status" is lost when working with "advanced filters" @see http://www.mantisbt.org/bugs/view.php?id=6042 - Field "hide status" is shown on both filter pages (simple and advanced) - "Hide status" is only considered when "show status" is (contains) ANY - "Hide status" is set to NONE when "show status" is not ANY - "Hide status" on advanced filter page does only consider selected values (while simple filter does consider status AND ABOVE) --- core/filter_api.php | 52 ++++++++++++++++++++++++++++++++++++-------------- view_all_set.php | 12 +++++----- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/core/filter_api.php b/core/filter_api.php index 27a8807..b50c217 100644 --- a/core/filter_api.php +++ b/core/filter_api.php @@ -445,12 +445,26 @@ function filter_ensure_valid_filter( $p_filter_arr ) { } $t_cookie_vers = (int) utf8_substr( $p_filter_arr['_version'], 1 ); if( utf8_substr( config_get( 'cookie_version' ), 1 ) > $t_cookie_vers ) { - # if the version is old, update it $p_filter_arr['_version'] = config_get( 'cookie_version' ); } if( !isset( $p_filter_arr['_view_type'] ) ) { - $p_filter_arr['_view_type'] = gpc_get_string( 'view_type', 'simple' ); + $p_filter_arr['_view_type'] = gpc_get_string( 'view_type', null ); + if ( empty( $p_filter_arr['_view_type'] ) ) { + $t_view_filters_setting = config_get( 'view_filters' ); + $t_default_view_type = ( ADVANCED_ONLY == $t_view_filters_setting || ADVANCED_DEFAULT == $t_view_filters_setting ? 'advanced' : 'simple' ); + # If config restricts view type to a particular one, just force that for all cases + if( ADVANCED_ONLY == $t_view_filters_setting || SIMPLE_ONLY == $t_view_filters_setting ) { + $p_filter_arr['_view_type'] = $t_default_view_type; + } + # Otherwise just set to default if not already set. + else if( !isset( $p_filter_arr['_view_type'] ) ) { + $p_filter_arr['_view_type'] = gpc_get_string( 'view_type', $t_default_view_type ); + } + if ( !isset( $p_filter_arr['_view_type'] ) ) { + $p_filter_arr['_view_type'] = gpc_get_string( 'view_type', 'simple' ); + } + } } if( !isset( $p_filter_arr[FILTER_PROPERTY_ISSUES_PER_PAGE] ) ) { $p_filter_arr[FILTER_PROPERTY_ISSUES_PER_PAGE] = gpc_get_int( FILTER_PROPERTY_ISSUES_PER_PAGE, config_get( 'default_limit_view' ) ); @@ -720,6 +734,11 @@ function filter_ensure_valid_filter( $p_filter_arr ) { } } } + + # set hide_status to "none when show_status is not ANY + if ( !filter_field_is_any( $p_filter_arr['show_status'] ) ) { + $p_filter_arr['hide_status'] = array( META_FILTER_NONE ); + } # all of our filter values are now guaranteed to be there, and correct. return $p_filter_arr; @@ -1370,12 +1389,20 @@ function filter_get_bug_rows( &$p_page_number, &$p_per_page, &$p_page_count, &$p $t_desired_statuses[] = $t_this_status; } } else { - # advanced filtering: ignore the hide + # advanced filtering: if showing any, restrict by the hide status value, otherwise ignore the hide if( filter_field_is_any( $t_filter[FILTER_PROPERTY_STATUS_ID] ) ) { - $t_desired_statuses = array(); - } else { - foreach( $t_filter[FILTER_PROPERTY_STATUS_ID] as $t_this_status ) { - $t_desired_statuses[] = $t_this_status; + foreach( $t_filter[FILTER_PROPERTY_HIDE_STATUS_ID] as $t_this_hide_status ) { + $t_this_hide_statuses[] = $t_this_hide_status; + } + foreach( $t_available_statuses as $t_this_available_status ) { + if( !in_array( $t_this_available_status, $t_this_hide_statuses ) ) { + $t_desired_statuses[] = $t_this_available_status; + } + } + } + else { + foreach( $t_filter[FILTER_PROPERTY_STATUS_ID] as $t_this_show_status ) { + $t_desired_statuses[] = $t_this_show_status; } } } @@ -2449,10 +2476,7 @@ function filter_draw_selection_area2( $p_page_number, $p_for_screen = true, $p_e : - - : - + : @@ -2523,8 +2547,7 @@ function filter_draw_selection_area2( $p_page_number, $p_for_screen = true, $p_e ?> - diff --git a/view_all_set.php b/view_all_set.php index 950e48d..7a608b3 100644 --- a/view_all_set.php +++ b/view_all_set.php @@ -195,12 +195,12 @@ } $f_note_user_id = array(); - if ( is_array( gpc_get( FILTER_PROPERTY_NOTE_USER_ID, null ) ) ) { - $f_note_user_id = gpc_get_string_array( FILTER_PROPERTY_NOTE_USER_ID, META_FILTER_ANY ); - } else { - $f_note_user_id = gpc_get_string( FILTER_PROPERTY_NOTE_USER_ID, META_FILTER_ANY ); - $f_note_user_id = array( $f_note_user_id ); - } + if ( is_array( gpc_get( FILTER_PROPERTY_NOTE_USER_ID, null ) ) ) { + $f_note_user_id = gpc_get_string_array( FILTER_PROPERTY_NOTE_USER_ID, META_FILTER_ANY ); + } else { + $f_note_user_id = gpc_get_string( FILTER_PROPERTY_NOTE_USER_ID, META_FILTER_ANY ); + $f_note_user_id = array( $f_note_user_id ); + } # these are only single values, even when doing advanced filtering $f_per_page = gpc_get_int( FILTER_PROPERTY_ISSUES_PER_PAGE, -1 ); -- 1.7.4.msysgit.0