2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # MantisBT is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
24 * @uses access_api.php
25 * @uses authentication_api.php
26 * @uses compress_api.php
27 * @uses config_api.php
28 * @uses constant_inc.php
29 * @uses current_user_api.php
30 * @uses custom_field_api.php
31 * @uses filter_api.php
32 * @uses filter_constants_inc.php
34 * @uses helper_api.php
38 * @uses string_api.php
39 * @uses version_api.php
42 require_once( 'core.php' );
43 require_api( 'access_api.php' );
44 require_api( 'authentication_api.php' );
45 require_api( 'compress_api.php' );
46 require_api( 'config_api.php' );
47 require_api( 'constant_inc.php' );
48 require_api( 'current_user_api.php' );
49 require_api( 'custom_field_api.php' );
50 require_api( 'filter_api.php' );
51 require_api( 'filter_constants_inc.php' );
52 require_api( 'gpc_api.php' );
53 require_api( 'helper_api.php' );
54 require_api( 'html_api.php' );
55 require_api( 'lang_api.php' );
56 require_api( 'print_api.php' );
57 require_api( 'string_api.php' );
58 require_api( 'version_api.php' );
60 auth_ensure_user_authenticated();
66 $t_filter = filter_get_default();
67 $t_target_field = rtrim( gpc_get_string( 'target_field', '' ), '[]');
68 if ( !isset( $t_filter[ $t_target_field ] ) ) {
72 if ( ON
== config_get( 'use_javascript' ) ) {
74 <body onload
="SetInitialFocus();">
76 <script type
="text/javascript" language
="JavaScript">
78 function SetInitialFocus() {
80 global $t_target_field;
81 if ( $t_target_field ) {
82 $f_view_type = gpc_get_string( 'view_type', '' );
83 if ( ( FILTER_PROPERTY_HIDE_STATUS_ID
. '[]' == $t_target_field ) && ( 'advanced' == $f_view_type ) ) {
84 echo 'field_to_focus = "', FILTER_PROPERTY_STATUS_ID
, '[]";';
86 echo 'field_to_focus = "', $t_target_field, '";';
89 print "field_to_focus = null;";
92 if ( field_to_focus
) {
93 eval( "document.filters['" + field_to_focus +
"'].focus()" );
99 function SwitchDateFields() {
100 // All fields need to be enabled to go back to the script
102 echo 'document.filters.', FILTER_PROPERTY_START_MONTH
, '.disabled = ! document.filters.', FILTER_PROPERTY_FILTER_BY_DATE
, '.checked;';
103 echo 'document.filters.', FILTER_PROPERTY_START_DAY
, '.disabled = ! document.filters.', FILTER_PROPERTY_FILTER_BY_DATE
, '.checked;';
104 echo 'document.filters.', FILTER_PROPERTY_START_YEAR
, '.disabled = ! document.filters.', FILTER_PROPERTY_FILTER_BY_DATE
, '.checked;';
105 echo 'document.filters.', FILTER_PROPERTY_END_MONTH
, '.disabled = ! document.filters.', FILTER_PROPERTY_FILTER_BY_DATE
, '.checked;';
106 echo 'document.filters.', FILTER_PROPERTY_END_DAY
, '.disabled = ! document.filters.', FILTER_PROPERTY_FILTER_BY_DATE
, '.checked;';
107 echo 'document.filters.', FILTER_PROPERTY_END_YEAR
, '.disabled = ! document.filters.', FILTER_PROPERTY_FILTER_BY_DATE
, '.checked;';
118 /** @todo thraxisp - could this be replaced by a call to filter_draw_selection_area2 */
120 $t_filter = current_user_get_bug_filter();
121 $t_filter = filter_ensure_valid_filter( $t_filter );
122 $t_project_id = helper_get_current_project();
124 $t_current_user_access_level = current_user_get_access_level();
125 $t_accessible_custom_fields_ids = array();
126 $t_accessible_custom_fields_names = array();
127 $t_accessible_custom_fields_type = array() ;
128 $t_accessible_custom_fields_values = array();
129 $t_filter_cols = config_get( 'filter_custom_fields_per_row' );
133 #get valid target fields
134 $t_fields = helper_get_columns_to_view();
135 $t_n_fields = count( $t_fields );
136 for ( $i=0; $i < $t_n_fields; $i++
) {
137 if ( in_array( $t_fields[$i], array( 'selection', 'edit', 'bugnotes_count', 'attachment' ) ) ) {
138 unset( $t_fields[$i] );
142 if ( ON
== config_get( 'filter_by_custom_fields' ) ) {
143 $t_custom_cols = $t_filter_cols;
144 $t_custom_fields = custom_field_get_linked_ids( $t_project_id );
146 foreach ( $t_custom_fields as $t_cfid ) {
147 $t_field_info = custom_field_cache_row( $t_cfid, true );
148 if ( $t_field_info['access_level_r'] <= $t_current_user_access_level && $t_field_info['filter_by']) {
149 $t_accessible_custom_fields_ids[] = $t_cfid;
150 $t_accessible_custom_fields_names[] = $t_field_info['name'];
151 $t_accessible_custom_fields_types[] = $t_field_info['type'];
152 $t_accessible_custom_fields_values[] = custom_field_distinct_values( $t_field_info, $t_project_id );
153 $t_fields[] = "custom_" . $t_field_info['name'];
157 if ( count( $t_accessible_custom_fields_ids ) > 0 ) {
158 $t_per_row = config_get( 'filter_custom_fields_per_row' );
159 $t_custom_rows = ceil( count( $t_accessible_custom_fields_ids ) / $t_per_row );
163 if ( !in_array( $t_target_field, $t_fields ) ) {
164 $t_target_field = '';
167 $f_for_screen = gpc_get_bool( 'for_screen', true );
169 $t_action = "view_all_set.php?f=3";
171 if ( $f_for_screen == false ) {
172 $t_action = "view_all_set.php";
175 $f_default_view_type = 'simple';
176 if ( ADVANCED_DEFAULT
== config_get( 'view_filters' ) ) {
177 $f_default_view_type = 'advanced';
180 $f_view_type = gpc_get_string( 'view_type', $f_default_view_type );
181 if ( ADVANCED_ONLY
== config_get( 'view_filters' ) ) {
182 $f_view_type = 'advanced';
184 if ( SIMPLE_ONLY
== config_get( 'view_filters' ) ) {
185 $f_view_type = 'simple';
187 if ( !in_array( $f_view_type, array( 'simple', 'advanced' ) ) ) {
188 $f_view_type = $f_default_view_type;
191 $t_select_modifier = '';
192 if ( 'advanced' == $f_view_type ) {
193 $t_select_modifier = 'multiple="multiple" size="10" ';
196 $t_show_product_version = version_should_show_product_version( $t_project_id );
197 $t_show_build = $t_show_product_version && ( config_get( 'enable_product_build' ) == ON
);
199 $t_show_tags = access_has_global_level( config_get( 'tag_view_threshold' ) );
202 <form method
="post" name
="filters" action
="<?php echo $t_action; ?>">
203 <?php
# CSRF protection not required here - form does not result in modifications ?>
204 <input type
="hidden" name
="type" value
="1" />
205 <input type
="hidden" name
="view_type" value
="<?php echo $f_view_type; ?>" />
207 if ( $f_for_screen == false ) {
208 print '<input type="hidden" name="print" value="1" />';
209 print '<input type="hidden" name="offset" value="0" />';
212 <table
class="width100" cellspacing
="1">
214 <td
class="right" colspan
="<?php echo ( 8 * $t_custom_cols ); ?>">
216 $f_switch_view_link = 'view_filters_page.php?target_field=' . $t_target_field . '&view_type=';
218 if ( ( SIMPLE_ONLY
!= config_get( 'view_filters' ) ) && ( ADVANCED_ONLY
!= config_get( 'view_filters' ) ) ) {
219 if ( 'advanced' == $f_view_type ) {
220 print_bracket_link( $f_switch_view_link . 'simple', lang_get( 'simple_filters' ) );
222 print_bracket_link( $f_switch_view_link . 'advanced', lang_get( 'advanced_filters' ) );
228 <tr
class="row-category2">
229 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'reporter' ) ?
></td
>
230 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'monitored_by' ) ?
></td
>
231 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'assigned_to' ) ?
></td
>
232 <td
class="small-caption" colspan
="<?php echo ( 2 * $t_custom_cols ); ?>"><?php
echo lang_get( 'category' ) ?
></td
>
233 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'severity' ) ?
></td
>
234 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'resolution' ) ?
></td
>
235 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'profile' ) ?
></td
>
236 <!-- <td colspan
="<?php echo ( ( $t_filter_cols - 8 ) * $t_custom_cols ); ?>"> 
;</td
> -->
240 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
241 <?php
print_filter_reporter_id(); ?
>
243 <!-- Monitored by
-->
244 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
245 <?php
print_filter_user_monitor(); ?
>
248 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
249 <?php
print_filter_handler_id(); ?
>
252 <td valign
="top" colspan
="<?php echo ( 2 * $t_custom_cols ); ?>">
253 <?php
print_filter_show_category(); ?
>
256 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
257 <?php
print_filter_show_severity(); ?
>
260 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
261 <?php
print_filter_show_resolution(); ?
>
264 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
265 <?php
print_filter_show_profile(); ?
>
267 <!-- <td colspan
="<?php echo ( ( $t_filter_cols - 8 ) * $t_custom_cols ); ?>"> 
;</td
> -->
270 <tr
class="row-category2">
271 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'status' ) ?
></td
>
272 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
274 if ( 'simple' == $f_view_type ) {
275 echo lang_get( 'hide_status' );
281 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'product_build' ) ?
></td
>
282 <?php
if ( $t_show_product_version ) { ?
>
283 <td
class="small-caption" colspan
="<?php echo ( 2 * $t_custom_cols ); ?>"><?php
echo lang_get( 'product_version' ) ?
></td
>
284 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'fixed_in_version' ) ?
></td
>
286 <td
class="small-caption" colspan
="<?php echo ( 2 * $t_custom_cols ); ?>"> 
;</td
>
287 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"> 
;</td
>
289 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'priority' ) ?
></td
>
290 <?php
if ( $t_show_product_version ) { ?
>
291 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'target_version' ) ?
></td
>
293 <td
class="small-caption" colspan
="<?php echo ( ( $t_filter_cols - 7 ) * $t_custom_cols ); ?>"> 
;</td
>
298 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
299 <?php
print_filter_show_status(); ?
>
302 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
304 if ( 'simple' == $f_view_type ) {
305 print_filter_hide_status();
312 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
313 <?php
if ( $t_show_build ) {
314 print_filter_show_build();
318 <td valign
="top" colspan
="<?php echo ( 2 * $t_custom_cols ); ?>">
319 <?php
if ( $t_show_product_version ) {
320 print_filter_show_version();
325 <!-- Fixed in Version
-->
326 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
327 <?php
if ( $t_show_product_version ) {
328 print_filter_show_fixed_in_version();
334 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
335 <?php
print_filter_show_priority(); ?
>
337 <!-- Target Version
-->
338 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
339 <?php
if ( $t_show_product_version ) {
340 print_filter_show_target_version();
347 <tr
class="row-category2">
348 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'show' ) ?
></td
>
349 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'view_status' ) ?
></td
>
350 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'sticky' ) ?
></td
>
351 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'changed' ) ?
></td
>
352 <td
class="small-caption" colspan
="<?php echo ( 3 * $t_custom_cols ); ?>">
353 <input type
="checkbox" name
="do_filter_by_date" <?php
354 check_checked( $t_filter['do_filter_by_date'], 'on' );
355 if ( ON
== config_get( 'use_javascript' ) ) {
356 print "onclick=\"SwitchDateFields();\""; } ?
> />
357 <?php
echo lang_get( 'use_date_filters' ) ?
>
359 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
360 <?php
echo lang_get( 'bug_relationships' ) ?
>
362 <!-- <td colspan
="<?php echo ( ( $t_filter_cols - 8 ) * $t_custom_cols ); ?>"> 
;</td
> -->
365 <!-- Number of bugs per page
-->
366 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
367 <?php
print_filter_per_page(); ?
>
370 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
371 <?php
print_filter_view_state(); ?
>
373 <!-- Show Sticky bugs
-->
374 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
375 <?php
print_filter_sticky_issues(); ?
>
377 <!-- Highlight changed bugs
-->
378 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
379 <?php
print_filter_highlight_changed(); ?
>
381 <td valign
="top" class="left" colspan
="<?php echo ( 3 * $t_custom_cols ); ?>">
382 <?php
print_filter_do_filter_by_date( true ); # hide checkbox as it's already been shown ?>
384 <td valign
="top" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
385 <?php
print_filter_relationship_type(); ?
>
387 <!-- <td colspan
="<?php echo ( ( $t_filter_cols - 8 ) * $t_custom_cols ); ?>"> 
;</td
> -->
391 if ( ON
== config_get( 'filter_by_custom_fields' ) ) {
393 # -- Custom Field Searching --
394 if ( count( $t_accessible_custom_fields_ids ) > 0 ) {
395 $t_per_row = config_get( 'filter_custom_fields_per_row' );
396 $t_num_rows = ceil( count( $t_accessible_custom_fields_ids ) / $t_per_row );
399 for ( $i = 0; $i < $t_num_rows; $i++
) {
401 <tr
class="row-category2">
403 for( $j = 0; $j < $t_per_row; $j++
) {
404 echo '<td class="small-caption" colspan="' . ( 1 * $t_filter_cols ) . '">';
405 if ( isset( $t_accessible_custom_fields_names[$t_base +
$j] ) ) {
406 echo string_display( lang_get_defaulted( $t_accessible_custom_fields_names[$t_base +
$j] ) );
416 for ( $j = 0; $j < $t_per_row; $j++
) {
417 echo '<td colspan="' . ( 1 * $t_filter_cols ) . '">';
418 if ( isset( $t_accessible_custom_fields_ids[$t_base +
$j] ) ) {
419 print_filter_custom_field($t_accessible_custom_fields_ids[$t_base +
$j]);
429 $t_base +
= $t_per_row;
434 if ( 'simple' == $f_view_type ) {
442 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>" valign
="top">
443 <?php
echo lang_get( 'sort_label' ) ?
>
445 <td valign
="top" colspan
="<?php echo ( ( $t_filter_cols - 1 - $t_project_cols ) * $t_custom_cols ); ?>">
447 print_filter_show_sort();
451 if ( 'advanced' == $f_view_type ) {
453 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>" valign
="top">
454 <?php
echo lang_get( 'email_project_label' ) ?
>
456 <td valign
="top" colspan
="<?php echo( 2 * $t_custom_cols ); ?>">
458 print_filter_project_id();
469 $t_plugin_filters = filter_get_plugin_filters();
472 $t_row_filters = array();
474 # output a filter form element for each plugin filter
475 foreach( $t_plugin_filters as $t_field_name => $t_filter_object ) {
476 $t_fields .= '<td class="small-caption" valign="top" colspan="' . $t_custom_cols . '"> ' . string_display_line( $t_filter_object->title
) . ' </td>';
477 $t_row_filters[] = $t_field_name;
481 # wrap at the appropriate column
482 if ( $t_column >= $t_filter_cols ) {
483 echo '<tr class="row-category2">', $t_fields, '</tr>';
484 echo '<tr class="row-1">';
485 foreach( $t_row_filters as $t_row_field_name ) {
486 echo '<td class="small-caption" valign="top" colspan="' . $t_custom_cols . '"> ',
487 print_filter_plugin_field( $t_row_field_name, $t_plugin_filters[ $t_row_field_name ] ), '</td>';
492 $t_row_filters = array();
496 # output any remaining plugin filters
497 if ( $t_column > 0 ) {
498 if ( $t_column < $t_filter_cols ) {
499 $t_fields .= '<td class="small-caption" colspan="' . ( $t_filter_cols - $t_column ) * $t_custom_cols . '"> </td>';
502 echo '<tr class="row-category2">', $t_fields, '</tr>';
503 echo '<tr class="row-1">';
504 foreach( $t_row_filters as $t_row_field_name ) {
505 echo '<td class="small-caption" valign="top" colspan="' . $t_custom_cols . '"> ',
506 print_filter_plugin_field( $t_row_field_name, $t_plugin_filters[ $t_row_field_name ] ), '</td>';
509 if ( $t_column < $t_filter_cols ) {
510 echo '<td class="small-caption" colspan="' . ( $t_filter_cols - $t_column ) * $t_custom_cols . '"> </td>';
518 <tr
class="row-category2">
519 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"><?php
echo lang_get( 'search' ) ?
></td
>
520 <td
class="small-caption" colspan
="<?php echo ( ( $t_filter_cols - 2 ) * $t_custom_cols ); ?>"><?php
if ( $t_show_tags ) { echo lang_get( 'tags' ); } ?
></td
>
521 <td
class="small-caption" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>"></td
>
524 <!-- Search field
-->
525 <td colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
526 <input type
="text" size
="16" name
="search" value
="<?php echo string_html_specialchars( $t_filter['search'] ); ?>" />
529 <td
class="small-caption" colspan
="<?php echo ( ( $t_filter_cols - 2 ) * $t_custom_cols ); ?>"><?php
if ( $t_show_tags ) { print_filter_tag_string(); } ?
></td
>
531 <!-- Submit button
-->
532 <td
class="right" colspan
="<?php echo ( 1 * $t_custom_cols ); ?>">
533 <input type
="submit" name
="filter" class="button" value
="<?php echo lang_get( 'filter_button' ) ?>" />