--- core/filter_api.php	2010-09-14 14:40:10.000000000 +1000
+++ core/filter_api.php	2010-11-10 19:16:30.000000000 +1100
@@ -449,9 +449,25 @@ function filter_ensure_valid_filter( $p_
 		# if the version is old, update it
 		$p_filter_arr['_version'] = config_get( 'cookie_version' );
 	}
+
+	# validate filter type
+	$t_default_view_type = 'simple';
+	if ( ADVANCED_DEFAULT == config_get( 'view_filters' ) ) {
+		$t_default_view_type = 'advanced';
+	}
 	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', $t_default_view_type );
+	}
+
+	if ( ADVANCED_ONLY == config_get( 'view_filters' ) ) {
+		$p_filter_arr['_view_type'] = 'advanced';
+	} else if ( SIMPLE_ONLY == config_get( 'view_filters' ) ) {
+		$p_filter_arr['_view_type'] = 'simple';
+	}
+	if ( !in_array( $p_filter_arr['_view_type'], array( 'simple', 'advanced' ) ) ) {
+		$p_filter_arr['_view_type'] = $t_default_view_type;
 	}
+
 	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' ) );
 	}
@@ -696,6 +712,22 @@ function filter_ensure_valid_filter( $p_
 		}
 	}
 
+	if ($p_filter_arr['_view_type'] == 'advanced' && count($p_filter_arr[FILTER_PROPERTY_HIDE_STATUS_ID])) {
+		# advanced filtering: remove all stati above or equal the lowest selected hide status value from the show status list
+		$t_hide_status = $p_filter_arr[FILTER_PROPERTY_HIDE_STATUS_ID];
+		sort($t_hide_status);
+		if ($t_hide_status[0] > 1) {
+			$t_show_status = (filter_field_is_any($p_filter_arr[FILTER_PROPERTY_STATUS_ID])) ? MantisEnum::getValues( config_get( 'status_enum_string' ) ) : $p_filter_arr[FILTER_PROPERTY_STATUS_ID];
+			$p_filter_arr[FILTER_PROPERTY_STATUS_ID] = array();
+			foreach( $t_show_status as $t_this_show_status ) {
+				if( $t_this_show_status < $t_hide_status[0] ) {
+					$p_filter_arr[FILTER_PROPERTY_STATUS_ID][] = $t_this_show_status;
+				}
+			}
+			$p_filter_arr[FILTER_PROPERTY_HIDE_STATUS_ID] = array();
+		}
+	}
+
 	if( is_array( $t_custom_fields ) && ( count( $t_custom_fields ) > 0 ) ) {
 		foreach( $t_custom_fields as $t_cfid ) {
 			if( !isset( $p_filter_arr['custom_fields'][$t_cfid] ) ) {
@@ -1352,13 +1384,13 @@ function filter_get_bug_rows( &$p_page_n
 	# the ones we want shown are still available
 	$t_desired_statuses = array();
 	$t_available_statuses = MantisEnum::getValues( config_get( 'status_enum_string' ) );
+	$t_this_hide_status = $t_filter[FILTER_PROPERTY_HIDE_STATUS_ID][0];
 
 	if( 'simple' == $t_filter['_view_type'] ) {
 
 		# simple filtering: if showing any, restrict by the hide status value, otherwise ignore the hide
 		$t_any_found = false;
 		$t_this_status = $t_filter[FILTER_PROPERTY_STATUS_ID][0];
-		$t_this_hide_status = $t_filter[FILTER_PROPERTY_HIDE_STATUS_ID][0];
 
 		if( filter_field_is_any( $t_this_status ) ) {
 			foreach( $t_available_statuses as $t_this_available_status ) {
