Blame Extras/Mantis/1.1.2-1.fc9/view_filters_page.php

4c79b5
4c79b5
# Mantis - a php based bugtracking system
4c79b5
4c79b5
# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
4c79b5
# Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
4c79b5
4c79b5
# Mantis is free software: you can redistribute it and/or modify
4c79b5
# it under the terms of the GNU General Public License as published by
4c79b5
# the Free Software Foundation, either version 2 of the License, or
4c79b5
# (at your option) any later version.
4c79b5
#
4c79b5
# Mantis is distributed in the hope that it will be useful,
4c79b5
# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c79b5
# GNU General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
4c79b5
4c79b5
	#------------------------------
4c79b5
	#   $Revision: 2643 $
4c79b5
	#     $Author: al $    
4c79b5
	#       $Date: 2009-06-18 19:06:27 -0400 (Thu, 18 Jun 2009) $  
4c79b5
	#------------------------------
4c79b5
?>
4c79b5
4c79b5
	require_once( 'core.php' );
4c79b5
	$t_core_path = config_get( 'core_path' );
4c79b5
4c79b5
	require_once( $t_core_path.'compress_api.php' );
4c79b5
	require_once( $t_core_path.'filter_api.php' );
4c79b5
	require_once( $t_core_path.'relationship_api.php' );
4c79b5
	require_once( $t_core_path.'current_user_api.php' );
4c79b5
	require_once( $t_core_path.'bug_api.php' );
4c79b5
	require_once( $t_core_path.'string_api.php' );
4c79b5
	require_once( $t_core_path.'date_api.php' );
4c79b5
	require_once( $t_core_path.'tag_api.php' );
4c79b5
4c79b5
	auth_ensure_user_authenticated();
4c79b5
4c79b5
	compress_enable();
4c79b5
4c79b5
	html_page_top1();
4c79b5
	html_page_top2();
4c79b5
4c79b5
	$t_target_field = gpc_get_string( 'target_field', '' );
4c79b5
4c79b5
	if ( ON == config_get( 'use_javascript' ) ) {
4c79b5
		?>
4c79b5
		<body onload="SetInitialFocus();">
4c79b5
4c79b5
		<script type="text/javascript" language="JavaScript">
4c79b5
		
4c79b5
		function SetInitialFocus() {
4c79b5
			
4c79b5
			global $t_target_field;
4c79b5
			if ( $t_target_field ) {
4c79b5
				$f_view_type = gpc_get_string( 'view_type', '' );
4c79b5
				if ( ( 'hide_status[]' == $t_target_field ) && ( 'advanced' == $f_view_type ) ) {
4c79b5
					print "field_to_focus = \"show_status[]\";";
4c79b5
				} else {
4c79b5
					print "field_to_focus = \"$t_target_field\";";
4c79b5
				}
4c79b5
			} else {
4c79b5
				print "field_to_focus = null;";
4c79b5
			}
4c79b5
			?>
4c79b5
			if ( field_to_focus ) {
4c79b5
				eval( "document.filters['" + field_to_focus + "'].focus()" );
4c79b5
			}
4c79b5
4c79b5
			SwitchDateFields();
4c79b5
		}
4c79b5
4c79b5
		function SwitchDateFields() {
4c79b5
		    // All fields need to be enabled to go back to the script
4c79b5
			document.filters.start_month.disabled = ! document.filters.do_filter_by_date.checked;
4c79b5
			document.filters.start_day.disabled = ! document.filters.do_filter_by_date.checked;
4c79b5
			document.filters.start_year.disabled = ! document.filters.do_filter_by_date.checked;
4c79b5
			document.filters.end_month.disabled = ! document.filters.do_filter_by_date.checked;
4c79b5
			document.filters.end_day.disabled = ! document.filters.do_filter_by_date.checked;
4c79b5
			document.filters.end_year.disabled = ! document.filters.do_filter_by_date.checked;
4c79b5
4c79b5
		    return true;
4c79b5
		}
4c79b5
		// -->
4c79b5
		</script>
4c79b5
4c79b5
		
4c79b5
	}
4c79b5
4c79b5
	# @@@ thraxisp - could this be replaced by a call to filter_draw_selection_area2
4c79b5
4c79b5
	$t_filter = current_user_get_bug_filter();
4c79b5
	$t_filter = filter_ensure_valid_filter( $t_filter );
4c79b5
	$t_project_id = helper_get_current_project();
4c79b5
4c79b5
	$t_current_user_access_level = current_user_get_access_level();
4c79b5
	$t_accessible_custom_fields_ids = array();
4c79b5
	$t_accessible_custom_fields_names = array();
4c79b5
	$t_accessible_custom_fields_type = array() ;
4c79b5
	$t_accessible_custom_fields_values = array();
4c79b5
	$t_filter_cols = config_get( 'filter_custom_fields_per_row' );
4c79b5
	$t_custom_cols = 1;
4c79b5
	$t_custom_rows = 0;
4c79b5
4c79b5
	#get valid target fields
4c79b5
	$t_fields = helper_get_columns_to_view();
4c79b5
	$t_n_fields = count( $t_fields );
4c79b5
	for ( $i=0; $i < $t_n_fields; $i++ ) {
4c79b5
		if ( in_array( $t_fields[$i], array( 'selection', 'edit', 'bugnotes_count', 'attachment' ) ) ) {
4c79b5
			unset( $t_fields[$i] );
4c79b5
		}
4c79b5
	}
4c79b5
4c79b5
	if ( ON == config_get( 'filter_by_custom_fields' ) ) {
4c79b5
		$t_custom_cols = $t_filter_cols;
4c79b5
		$t_custom_fields = custom_field_get_linked_ids( $t_project_id );
4c79b5
4c79b5
		foreach ( $t_custom_fields as $t_cfid ) {
4c79b5
			$t_field_info = custom_field_cache_row( $t_cfid, true );
4c79b5
			if ( $t_field_info['access_level_r'] <= $t_current_user_access_level ) {
4c79b5
				$t_accessible_custom_fields_ids[] = $t_cfid;
4c79b5
				$t_accessible_custom_fields_names[] = $t_field_info['name'];
4c79b5
				$t_accessible_custom_fields_types[] = $t_field_info['type'];
4c79b5
				$t_accessible_custom_fields_values[] = custom_field_distinct_values( $t_cfid, $t_project_id );
4c79b5
				$t_fields[] = "custom_" . $t_field_info['name'];
4c79b5
			}
4c79b5
		}
4c79b5
4c79b5
		if ( sizeof( $t_accessible_custom_fields_ids ) > 0 ) {
4c79b5
			$t_per_row = config_get( 'filter_custom_fields_per_row' );
4c79b5
			$t_custom_rows = ceil( sizeof( $t_accessible_custom_fields_ids ) / $t_per_row );
4c79b5
		}
4c79b5
	}
4c79b5
4c79b5
	if ( ! in_array( $t_target_field, $t_fields ) ) {
4c79b5
		$t_target_field = '';
4c79b5
	}
4c79b5
	
4c79b5
	$f_for_screen = gpc_get_bool( 'for_screen', true );
4c79b5
4c79b5
	$t_action  = "view_all_set.php?f=3";
4c79b5
4c79b5
	if ( $f_for_screen == false ) {
4c79b5
		$t_action  = "view_all_set.php";
4c79b5
	}
4c79b5
4c79b5
	$f_default_view_type = 'simple';
4c79b5
	if ( ADVANCED_DEFAULT == config_get( 'view_filters' ) ) {
4c79b5
		$f_default_view_type = 'advanced';
4c79b5
	}
4c79b5
4c79b5
	$f_view_type = gpc_get_string( 'view_type', $f_default_view_type );
4c79b5
	if ( ADVANCED_ONLY == config_get( 'view_filters' ) ) {
4c79b5
		$f_view_type = 'advanced';
4c79b5
	}
4c79b5
	if ( SIMPLE_ONLY == config_get( 'view_filters' ) ) {
4c79b5
		$f_view_type = 'simple';
4c79b5
	}
4c79b5
	if ( ! in_array( $f_view_type, array( 'simple', 'advanced' ) ) ) {
4c79b5
		$f_view_type = $f_default_view_type;
4c79b5
	}	
4c79b5
4c79b5
	$t_select_modifier = '';
4c79b5
	if ( 'advanced' == $f_view_type ) {
4c79b5
		$t_select_modifier = 'multiple="multiple" size="10" ';
4c79b5
	}
4c79b5
4c79b5
	$t_show_version = ( ON == config_get( 'show_product_version' ) )
4c79b5
			|| ( ( AUTO == config_get( 'show_product_version' ) )
4c79b5
						&& ( count( version_get_all_rows_with_subs( $t_project_id ) ) > 0 ) );
4c79b5
?>
4c79b5

4c79b5
<form method="post" name="filters" action="<?php echo $t_action; ?>">
4c79b5
<input type="hidden" name="type" value="1" />
4c79b5
<input type="hidden" name="view_type" value="<?php PRINT $f_view_type; ?>" />
4c79b5
4c79b5
	if ( $f_for_screen == false )
4c79b5
	{
4c79b5
		print "<input type=\"hidden\" name=\"print\" value=\"1\" />";
4c79b5
		print "<input type=\"hidden\" name=\"offset\" value=\"0\" />";
4c79b5
	}
4c79b5
?>
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
		$f_switch_view_link = 'view_filters_page.php?target_field=' . $t_target_field . '&view_type=';
4c79b5
4c79b5
		if ( ( SIMPLE_ONLY != config_get( 'view_filters' ) ) && ( ADVANCED_ONLY != config_get( 'view_filters' ) ) ) {
4c79b5
			if ( 'advanced' == $f_view_type ) {
4c79b5
				print_bracket_link( $f_switch_view_link . 'simple', lang_get( 'simple_filters' ) );
4c79b5
			} else {
4c79b5
				print_bracket_link( $f_switch_view_link . 'advanced', lang_get( 'advanced_filters' ) );
4c79b5
			}
4c79b5
		}
4c79b5
	?>
4c79b5
	
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
    
4c79b5
    
4c79b5
		
4c79b5
    
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	if ( 'simple' == $f_view_type ) {
4c79b5
		echo lang_get( 'hide_status' );
4c79b5
	} else {
4c79b5
		echo ' ';
4c79b5
	}
4c79b5
	?>
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
		
4c79b5
	
4c79b5
		 
4c79b5
		 
4c79b5
	
4c79b5
	
4c79b5
	 
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	if ( 'simple' == $f_view_type ) {
4c79b5
		print_filter_hide_status();
4c79b5
	} else {
4c79b5
		echo ' ';
4c79b5
	}
4c79b5
	?>
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
 		
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
 		
4c79b5
 			print_filter_show_version();
4c79b5
 		} else {
4c79b5
 			echo " ";
4c79b5
 		} ?>
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
 		
4c79b5
 			print_filter_show_fixed_in_version();
4c79b5
 		} else {
4c79b5
 			echo " ";
4c79b5
 		} ?>
4c79b5
 	
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	 
4c79b5
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		<label title="<?php echo lang_get( 'use_date_filters' ); ?>">
4c79b5
		
4c79b5
			check_checked( $t_filter['do_filter_by_date'], 'on' );
4c79b5
			if ( ON == config_get( 'use_javascript' ) ) {
4c79b5
				print "onclick=\"SwitchDateFields();\""; } ?> />
4c79b5
		
4c79b5
		'; ?>
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
        
4c79b5
	
4c79b5
	
4c79b5
4c79b5
4c79b5
4c79b5
if ( ON == config_get( 'filter_by_custom_fields' ) ) {
4c79b5
?>
4c79b5
	
4c79b5
	
4c79b5
	if ( sizeof( $t_accessible_custom_fields_ids ) > 0 ) {
4c79b5
		$t_per_row = config_get( 'filter_custom_fields_per_row' );
4c79b5
		$t_num_rows = ceil( sizeof( $t_accessible_custom_fields_ids ) / $t_per_row );
4c79b5
		$t_base = 0;
4c79b5
4c79b5
		for ( $i = 0; $i < $t_num_rows; $i++ ) {
4c79b5
			?>
4c79b5
			
4c79b5
			
4c79b5
			for( $j = 0; $j < $t_per_row; $j++ ) {
4c79b5
				echo '';
4c79b5
				if ( isset( $t_accessible_custom_fields_names[$t_base + $j] ) ) {
4c79b5
					echo string_display( lang_get_defaulted( $t_accessible_custom_fields_names[$t_base + $j] ) );
4c79b5
				} else {
4c79b5
					echo ' ';
4c79b5
				}
4c79b5
				echo '';
4c79b5
			}
4c79b5
			?>
4c79b5
			
4c79b5
			
4c79b5
			
4c79b5
			for ( $j = 0; $j < $t_per_row; $j++ ) {
4c79b5
				echo '';
4c79b5
				if ( isset( $t_accessible_custom_fields_ids[$t_base + $j] ) ) {
4c79b5
					print_filter_custom_field($t_accessible_custom_fields_ids[$t_base + $j]);
4c79b5
				} else {
4c79b5
					echo ' ';
4c79b5
				}
4c79b5
				echo '';
4c79b5
			}
4c79b5
4c79b5
			?>
4c79b5
			
4c79b5
			
4c79b5
			$t_base += $t_per_row;
4c79b5
		}
4c79b5
	}
4c79b5
}
4c79b5
4c79b5
if ( 'simple' == $f_view_type ) {
4c79b5
	$t_project_cols = 0;
4c79b5
} else {
4c79b5
	$t_project_cols = 3;
4c79b5
}
4c79b5
?>
4c79b5
4c79b5
4c79b5
	
4c79b5
		:
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
			print_filter_show_sort();
4c79b5
		?>
4c79b5
	
4c79b5
	
4c79b5
		if ( 'advanced' == $f_view_type ) {
4c79b5
	?>
4c79b5
			
4c79b5
				:
4c79b5
			
4c79b5
			
4c79b5
				
4c79b5
					print_filter_project_id();
4c79b5
				?>
4c79b5
			
4c79b5
	
4c79b5
		}
4c79b5
	?>
4c79b5
4c79b5
4c79b5
4c79b5
4c79b5
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
		<input type="text" size="16" name="search" value="<?php echo string_html_specialchars( $t_filter['search'] ); ?>" />
4c79b5
	
4c79b5
4c79b5
	
4c79b5
4c79b5
	
4c79b5
	
4c79b5
		<input type="submit" name="filter" class="button" value="<?php echo lang_get( 'filter_button' ) ?>" />
4c79b5
	
4c79b5
4c79b5
4c79b5
</form>
4c79b5
4c79b5