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 authentication_api.php
25 * @uses config_api.php
26 * @uses constant_inc.php
27 * @uses custom_field_api.php
29 * @uses filter_api.php
30 * @uses filter_constants_inc.php
32 * @uses helper_api.php
34 * @uses logging_api.php
36 * @uses tokens_api.php
37 * @uses utility_api.php
40 require_once( 'core.php' );
41 require_api( 'authentication_api.php' );
42 require_api( 'config_api.php' );
43 require_api( 'constant_inc.php' );
44 require_api( 'custom_field_api.php' );
45 require_api( 'error_api.php' );
46 require_api( 'filter_api.php' );
47 require_api( 'filter_constants_inc.php' );
48 require_api( 'gpc_api.php' );
49 require_api( 'helper_api.php' );
50 require_api( 'html_api.php' );
51 require_api( 'logging_api.php' );
52 require_api( 'print_api.php' );
53 require_api( 'tokens_api.php' );
54 require_api( 'utility_api.php' );
56 auth_ensure_user_authenticated();
58 $f_type = gpc_get_int( 'type', -1 );
59 $f_source_query_id = gpc_get_int( 'source_query_id', -1 );
60 $f_print = gpc_get_bool( 'print' );
61 $f_temp_filter = gpc_get_bool( 'temporary' );
63 # validate filter type
64 $f_default_view_type = 'simple';
65 if ( ADVANCED_DEFAULT
== config_get( 'view_filters' ) ) {
66 $f_default_view_type = 'advanced';
69 $f_view_type = gpc_get_string( 'view_type', $f_default_view_type );
70 if ( ADVANCED_ONLY
== config_get( 'view_filters' ) ) {
71 $f_view_type = 'advanced';
73 if ( SIMPLE_ONLY
== config_get( 'view_filters' ) ) {
74 $f_view_type = 'simple';
76 if ( !in_array( $f_view_type, array( 'simple', 'advanced' ) ) ) {
77 $f_view_type = $f_default_view_type;
80 # these are all possibly multiple selections for advanced filtering
81 $f_show_category = array();
82 if ( is_array( gpc_get( FILTER_PROPERTY_CATEGORY
, null ) ) ) {
83 $f_show_category = gpc_get_string_array( FILTER_PROPERTY_CATEGORY
, META_FILTER_ANY
);
85 $f_show_category = gpc_get_string( FILTER_PROPERTY_CATEGORY
, META_FILTER_ANY
);
86 $f_show_category = array( $f_show_category );
89 $f_platform = array();
90 if ( is_array( gpc_get( FILTER_PROPERTY_PLATFORM
, null ) ) ) {
91 $f_platform = gpc_get_string_array( FILTER_PROPERTY_PLATFORM
, META_FILTER_ANY
);
93 $f_platform = gpc_get_string( FILTER_PROPERTY_PLATFORM
, META_FILTER_ANY
);
94 $f_platform = array( $f_platform );
98 if ( is_array( gpc_get( FILTER_PROPERTY_OS
, null ) ) ) {
99 $f_os = gpc_get_string_array( FILTER_PROPERTY_OS
, META_FILTER_ANY
);
101 $f_os = gpc_get_string( FILTER_PROPERTY_OS
, META_FILTER_ANY
);
102 $f_os = array( $f_os );
105 $f_os_build = array();
106 if ( is_array( gpc_get( FILTER_PROPERTY_OS_BUILD
, null ) ) ) {
107 $f_os_build = gpc_get_string_array( FILTER_PROPERTY_OS_BUILD
, META_FILTER_ANY
);
109 $f_os_build = gpc_get_string( FILTER_PROPERTY_OS_BUILD
, META_FILTER_ANY
);
110 $f_os_build = array( $f_os_build );
113 $f_show_severity = array();
114 if ( is_array( gpc_get( FILTER_PROPERTY_SEVERITY_ID
, null ) ) ) {
115 $f_show_severity = gpc_get_string_array( FILTER_PROPERTY_SEVERITY_ID
, META_FILTER_ANY
);
117 $f_show_severity = gpc_get_string( FILTER_PROPERTY_SEVERITY_ID
, META_FILTER_ANY
);
118 $f_show_severity = array( $f_show_severity );
121 $f_show_status = array();
122 if ( is_array( gpc_get( FILTER_PROPERTY_STATUS_ID
, null ) ) ) {
123 $f_show_status = gpc_get_string_array( FILTER_PROPERTY_STATUS_ID
, META_FILTER_ANY
);
125 $f_show_status = gpc_get_string( FILTER_PROPERTY_STATUS_ID
, META_FILTER_ANY
);
126 $f_show_status = array( $f_show_status );
129 $f_hide_status = array();
130 if ( is_array( gpc_get( FILTER_PROPERTY_HIDE_STATUS_ID
, null ) ) ) {
131 $f_hide_status = gpc_get_string_array( FILTER_PROPERTY_HIDE_STATUS_ID
, META_FILTER_NONE
);
133 $f_hide_status = gpc_get_string( FILTER_PROPERTY_HIDE_STATUS_ID
, META_FILTER_NONE
);
134 $f_hide_status = array( $f_hide_status );
137 $f_reporter_id = array();
138 if ( is_array( gpc_get( FILTER_PROPERTY_REPORTER_ID
, null ) ) ) {
139 $f_reporter_id = gpc_get_string_array( FILTER_PROPERTY_REPORTER_ID
, META_FILTER_ANY
);
141 $f_reporter_id = gpc_get_string( FILTER_PROPERTY_REPORTER_ID
, META_FILTER_ANY
);
142 $f_reporter_id = array( $f_reporter_id );
145 $f_handler_id = array();
146 if ( is_array( gpc_get( FILTER_PROPERTY_HANDLER_ID
, null ) ) ) {
147 $f_handler_id = gpc_get_string_array( FILTER_PROPERTY_HANDLER_ID
, META_FILTER_ANY
);
149 $f_handler_id = gpc_get_string( FILTER_PROPERTY_HANDLER_ID
, META_FILTER_ANY
);
150 $f_handler_id = array( $f_handler_id );
153 $f_project_id = array();
154 if ( is_array( gpc_get( FILTER_PROPERTY_PROJECT_ID
, null ) ) ) {
155 $f_project_id = gpc_get_int_array( FILTER_PROPERTY_PROJECT_ID
, META_FILTER_CURRENT
);
157 $f_project_id = gpc_get_int( FILTER_PROPERTY_PROJECT_ID
, META_FILTER_CURRENT
);
158 $f_project_id = array( $f_project_id );
161 $f_show_resolution = array();
162 if ( is_array( gpc_get( FILTER_PROPERTY_RESOLUTION_ID
, null ) ) ) {
163 $f_show_resolution = gpc_get_string_array( FILTER_PROPERTY_RESOLUTION_ID
, META_FILTER_ANY
);
165 $f_show_resolution = gpc_get_string( FILTER_PROPERTY_RESOLUTION_ID
, META_FILTER_ANY
);
166 $f_show_resolution = array( $f_show_resolution );
169 $f_show_build = array();
170 if ( is_array( gpc_get( FILTER_PROPERTY_PRODUCT_BUILD
, null ) ) ) {
171 $f_show_build = gpc_get_string_array( FILTER_PROPERTY_PRODUCT_BUILD
, META_FILTER_ANY
);
173 $f_show_build = gpc_get_string( FILTER_PROPERTY_PRODUCT_BUILD
, META_FILTER_ANY
);
174 $f_show_build = array( $f_show_build );
177 $f_show_version = array();
178 if ( is_array( gpc_get( FILTER_PROPERTY_PRODUCT_VERSION
, null ) ) ) {
179 $f_show_version = gpc_get_string_array( FILTER_PROPERTY_PRODUCT_VERSION
, META_FILTER_ANY
);
181 $f_show_version = gpc_get_string( FILTER_PROPERTY_PRODUCT_VERSION
, META_FILTER_ANY
);
182 $f_show_version = array( $f_show_version );
185 $f_fixed_in_version = array();
186 if ( is_array( gpc_get( FILTER_PROPERTY_FIXED_IN_VERSION
, null ) ) ) {
187 $f_fixed_in_version = gpc_get_string_array( FILTER_PROPERTY_FIXED_IN_VERSION
, META_FILTER_ANY
);
189 $f_fixed_in_version = gpc_get_string( FILTER_PROPERTY_FIXED_IN_VERSION
, META_FILTER_ANY
);
190 $f_fixed_in_version = array( $f_fixed_in_version );
193 $f_target_version = array();
194 if ( is_array( gpc_get( FILTER_PROPERTY_TARGET_VERSION
, null ) ) ) {
195 $f_target_version = gpc_get_string_array( FILTER_PROPERTY_TARGET_VERSION
, META_FILTER_ANY
);
197 $f_target_version = gpc_get_string( FILTER_PROPERTY_TARGET_VERSION
, META_FILTER_ANY
);
198 $f_target_version = array( $f_target_version );
201 $f_show_profile = array();
202 if ( is_array( gpc_get( 'show_profile', null ) ) ) {
203 $f_show_profile = gpc_get_string_array( 'show_profile', META_FILTER_ANY
);
205 $f_show_profile = gpc_get_string( 'show_profile', META_FILTER_ANY
);
206 $f_show_profile = array( $f_show_profile );
209 $f_show_priority = array();
210 if ( is_array( gpc_get( FILTER_PROPERTY_PRIORITY_ID
, null ) ) ) {
211 $f_show_priority = gpc_get_string_array( FILTER_PROPERTY_PRIORITY_ID
, META_FILTER_ANY
);
213 $f_show_priority = gpc_get_string( FILTER_PROPERTY_PRIORITY_ID
, META_FILTER_ANY
);
214 $f_show_priority = array( $f_show_priority );
217 $f_user_monitor = array();
218 if ( is_array( gpc_get( FILTER_PROPERTY_MONITOR_USER_ID
, null ) ) ) {
219 $f_user_monitor = gpc_get_string_array( FILTER_PROPERTY_MONITOR_USER_ID
, META_FILTER_ANY
);
221 $f_user_monitor = gpc_get_string( FILTER_PROPERTY_MONITOR_USER_ID
, META_FILTER_ANY
);
222 $f_user_monitor = array( $f_user_monitor );
225 $f_note_user_id = array();
226 if ( is_array( gpc_get( FILTER_PROPERTY_NOTE_USER_ID
, null ) ) ) {
227 $f_note_user_id = gpc_get_string_array( FILTER_PROPERTY_NOTE_USER_ID
, META_FILTER_ANY
);
229 $f_note_user_id = gpc_get_string( FILTER_PROPERTY_NOTE_USER_ID
, META_FILTER_ANY
);
230 $f_note_user_id = array( $f_note_user_id );
233 # these are only single values, even when doing advanced filtering
234 $f_per_page = gpc_get_int( FILTER_PROPERTY_ISSUES_PER_PAGE
, -1 );
235 $f_highlight_changed = gpc_get_int( FILTER_PROPERTY_HIGHLIGHT_CHANGED
, config_get( 'default_show_changed' ) );
236 $f_sticky_issues = gpc_get_bool( FILTER_PROPERTY_SHOW_STICKY_ISSUES
);
238 $f_sort_d = gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME
, '' );
239 $f_dir_d = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION
, '' );
240 $f_sort_0 = gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME
. '_0', 'last_updated' );
241 $f_dir_0 = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION
. '_0', 'DESC' );
242 $f_sort_1 = gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME
. '_1', '' );
243 $f_dir_1 = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION
. '_1', '' );
246 $f_start_month = gpc_get_int( FILTER_PROPERTY_START_MONTH
, date( 'm' ) );
247 $f_end_month = gpc_get_int( FILTER_PROPERTY_END_MONTH
, date( 'm' ) );
248 $f_start_day = gpc_get_int( FILTER_PROPERTY_START_DAY
, 1 );
249 $f_end_day = gpc_get_int( FILTER_PROPERTY_END_DAY
, date( 'd' ) );
250 $f_start_year = gpc_get_int( FILTER_PROPERTY_START_YEAR
, date( 'Y' ) );
251 $f_end_year = gpc_get_int( FILTER_PROPERTY_END_YEAR
, date( 'Y' ) );
252 $f_search = gpc_get_string( FILTER_PROPERTY_FREE_TEXT
, '' );
253 $f_and_not_assigned = gpc_get_bool( FILTER_PROPERTY_NOT_ASSIGNED
);
254 $f_do_filter_by_date = gpc_get_bool( FILTER_PROPERTY_FILTER_BY_DATE
);
255 $f_view_state = gpc_get_int( FILTER_PROPERTY_VIEW_STATE_ID
, META_FILTER_ANY
);
257 $f_tag_string = gpc_get_string( FILTER_PROPERTY_TAG_STRING
, '' );
258 $f_tag_select = gpc_get_int( FILTER_PROPERTY_TAG_SELECT
, '0' );
260 # plugin filter updates
261 $t_plugin_filters = filter_get_plugin_filters();
262 $f_filter_input = array();
264 foreach( $t_plugin_filters as $t_field_name => $t_filter_object ) {
265 switch( $t_filter_object->type
) {
266 case FILTER_TYPE_STRING
:
267 $f_filter_input[ $t_field_name ] = gpc_get_string( $t_field_name, $t_filter_object->default );
270 case FILTER_TYPE_INT
:
271 $f_filter_input[ $t_field_name ] = gpc_get_int( $t_field_name, $t_filter_object->default );
274 case FILTER_TYPE_BOOLEAN
:
275 $f_filter_input[ $t_field_name ] = gpc_get_bool( $t_field_name, OFF
);
278 case FILTER_TYPE_MULTI_STRING
:
279 $f_filter_input[ $t_field_name ] = gpc_get_string_array( $t_field_name, $t_filter_object->default );
282 case FILTER_TYPE_MULTI_INT
:
283 $f_filter_input[ $t_field_name ] = gpc_get_int_array( $t_field_name, $t_filter_object->default );
288 # custom field updates
289 $t_custom_fields = custom_field_get_ids(); /** @todo (thraxisp) This should really be the linked ids, but we don't know the project */
290 $f_custom_fields_data = array();
291 if ( is_array( $t_custom_fields ) && ( count( $t_custom_fields ) > 0 ) ) {
292 foreach( $t_custom_fields as $t_cfid ) {
293 if (custom_field_type( $t_cfid ) == CUSTOM_FIELD_TYPE_DATE
) {
294 $t_control = gpc_get_string( 'custom_field_' . $t_cfid . '_control', null);
296 $t_year = gpc_get_int( 'custom_field_' . $t_cfid . '_start_year', null);
297 $t_month = gpc_get_int( 'custom_field_' . $t_cfid . '_start_month', null);
298 $t_day = gpc_get_int( 'custom_field_' . $t_cfid . '_start_day', null);
299 $t_start_date = mktime(0, 0, 0, $t_month, $t_day, $t_year);
301 $t_year = gpc_get_int( 'custom_field_' . $t_cfid . '_end_year', null);
302 $t_month = gpc_get_int( 'custom_field_' . $t_cfid . '_end_month', null);
303 $t_day = gpc_get_int( 'custom_field_' . $t_cfid . '_end_day', null);
304 $t_end_date = mktime(0, 0, 0, $t_month, $t_day, $t_year);
306 $f_custom_fields_data[$t_cfid] = array();
307 $f_custom_fields_data[$t_cfid][0] = $t_control;
314 case CUSTOM_FIELD_DATE_ANY
:
315 case CUSTOM_FIELD_DATE_NONE
:
317 case CUSTOM_FIELD_DATE_BETWEEN
:
318 $t_start = $t_start_date;
319 $t_end = $t_end_date +
$t_one_day - 1;
321 case CUSTOM_FIELD_DATE_ONORBEFORE
:
322 $t_end = $t_start_date +
$t_one_day - 1;
324 case CUSTOM_FIELD_DATE_BEFORE
:
325 $t_end = $t_start_date;
327 case CUSTOM_FIELD_DATE_ON
:
328 $t_start = $t_start_date;
329 $t_end = $t_start_date +
$t_one_day - 1;
331 case CUSTOM_FIELD_DATE_AFTER
:
332 $t_start = $t_start_date +
$t_one_day - 1;
333 $t_end = 2147483647; // Some time in 2038, max value of a signed int.
335 case CUSTOM_FIELD_DATE_ONORAFTER
:
336 $t_start = $t_start_date;
337 $t_end = 2147483647; // Some time in 2038, max value of a signed int.
340 $f_custom_fields_data[$t_cfid][1] = $t_start;
341 $f_custom_fields_data[$t_cfid][2] = $t_end;
343 if ( is_array( gpc_get( 'custom_field_' . $t_cfid, null ) ) ) {
344 $f_custom_fields_data[$t_cfid] = gpc_get_string_array( 'custom_field_' . $t_cfid, META_FILTER_ANY
);
346 $f_custom_fields_data[$t_cfid] = gpc_get_string( 'custom_field_' . $t_cfid, META_FILTER_ANY
);
347 $f_custom_fields_data[$t_cfid] = array( $f_custom_fields_data[$t_cfid] );
353 $f_relationship_type = gpc_get_int( FILTER_PROPERTY_RELATIONSHIP_TYPE
, -1 );
354 $f_relationship_bug = gpc_get_int( FILTER_PROPERTY_RELATIONSHIP_BUG
, 0 );
356 if ( $f_temp_filter ) {
360 if ( $f_and_not_assigned ) {
361 $f_and_not_assigned = 'on';
364 if ( $f_do_filter_by_date ) {
365 $f_do_filter_by_date = 'on';
368 if ( $f_sticky_issues ) {
369 $f_sticky_issues = 'on';
371 $f_sticky_issues = 'off';
375 print_header_redirect( 'view_all_bug_page.php' );
378 $t_hide_status_default = config_get( 'hide_status_default' );
381 if ( $f_per_page < 0 ) {
382 $f_per_page = config_get( 'default_limit_view' );
385 # combine sort settings
386 # (f_sort overrides f_sort_1 if set to keep old sorting code working in view_all_bug_inc)
387 $f_sort = ( ( $f_sort_d != "" ) ?
$f_sort_d : $f_sort_0 ) . ( ( $f_sort_1 != "" ) ?
"," . $f_sort_1 : "" );
388 $f_dir = ( ( $f_dir_d != "" ) ?
$f_dir_d : $f_dir_0 ) . ( ( $f_dir_1 != "" ) ?
"," . $f_dir_1 : "" );
390 # -1 is a special case stored query: it means we want to reset our filter
391 if ( ( $f_type == 3 ) && ( $f_source_query_id == -1 ) ) {
402 5: $f_highlight_changed
416 19: $f_and_not_assigned
417 20: $f_show_resolution
420 23: $f_do_filter_by_date
422 25: $f_relationship_type
423 26: $f_relationship_bug
427 # Set new filter values. These are stored in a cookie
428 $t_view_all_cookie_id = gpc_get_cookie( config_get( 'view_all_cookie' ), '' );
429 $t_view_all_cookie = filter_db_get_filter( $t_view_all_cookie_id );
431 # process the cookie if it exists, it may be blank in a new install
432 if ( !is_blank( $t_view_all_cookie ) ) {
433 $t_setting_arr = filter_deserialize( $t_view_all_cookie );
434 if ( false === $t_setting_arr ) {
435 # couldn't deserialize, if we were trying to use the filter, clear it and reload
436 # for ftype = 0, 1, or 3, we are going to re-write the filter anyways
437 if ( !in_array( $f_type, array( 0, 1, 3 ) ) ) {
438 gpc_clear_cookie( 'view_all_cookie' );
439 error_proceed_url( 'view_all_set.php?type=0' );
440 trigger_error( ERROR_FILTER_TOO_OLD
, ERROR
);
445 # no cookie found, set it
449 $t_cookie_version = config_get( 'cookie_version' );
450 $t_default_show_changed = config_get( 'default_show_changed' );
455 log_event( LOG_FILTERING
, 'view_all_set.php: New cookie' );
456 $t_setting_arr = array();
461 log_event( LOG_FILTERING
, 'view_all_set.php: Update filters' );
462 $t_setting_arr['_version'] = $t_cookie_version;
463 $t_setting_arr['_view_type'] = $f_view_type;
464 $t_setting_arr[ FILTER_PROPERTY_CATEGORY
] = $f_show_category;
465 $t_setting_arr[ FILTER_PROPERTY_SEVERITY_ID
] = $f_show_severity;
466 $t_setting_arr[ FILTER_PROPERTY_STATUS_ID
] = $f_show_status;
467 $t_setting_arr[ FILTER_PROPERTY_ISSUES_PER_PAGE
] = $f_per_page;
468 $t_setting_arr[ FILTER_PROPERTY_HIGHLIGHT_CHANGED
] = $f_highlight_changed;
469 $t_setting_arr[ FILTER_PROPERTY_REPORTER_ID
] = $f_reporter_id;
470 $t_setting_arr[ FILTER_PROPERTY_HANDLER_ID
] = $f_handler_id;
471 $t_setting_arr[ FILTER_PROPERTY_PROJECT_ID
] = $f_project_id;
472 $t_setting_arr[ FILTER_PROPERTY_SORT_FIELD_NAME
] = $f_sort;
473 $t_setting_arr[ FILTER_PROPERTY_SORT_DIRECTION
] = $f_dir;
474 $t_setting_arr[ FILTER_PROPERTY_START_MONTH
] = $f_start_month;
475 $t_setting_arr[ FILTER_PROPERTY_START_DAY
] = $f_start_day;
476 $t_setting_arr[ FILTER_PROPERTY_START_YEAR
] = $f_start_year;
477 $t_setting_arr[ FILTER_PROPERTY_END_MONTH
] = $f_end_month;
478 $t_setting_arr[ FILTER_PROPERTY_END_DAY
] = $f_end_day;
479 $t_setting_arr[ FILTER_PROPERTY_END_YEAR
] = $f_end_year;
480 $t_setting_arr[ FILTER_PROPERTY_FREE_TEXT
] = $f_search;
481 $t_setting_arr[ FILTER_PROPERTY_HIDE_STATUS_ID
] = $f_hide_status;
482 $t_setting_arr[ FILTER_PROPERTY_NOT_ASSIGNED
] = $f_and_not_assigned;
483 $t_setting_arr[ FILTER_PROPERTY_RESOLUTION_ID
] = $f_show_resolution;
484 $t_setting_arr[ FILTER_PROPERTY_PRODUCT_BUILD
] = $f_show_build;
485 $t_setting_arr[ FILTER_PROPERTY_PRODUCT_VERSION
] = $f_show_version;
486 $t_setting_arr[ FILTER_PROPERTY_FILTER_BY_DATE
] = $f_do_filter_by_date;
487 $t_setting_arr[ FILTER_PROPERTY_FIXED_IN_VERSION
] = $f_fixed_in_version;
488 $t_setting_arr[ FILTER_PROPERTY_TARGET_VERSION
] = $f_target_version;
489 $t_setting_arr[ FILTER_PROPERTY_PRIORITY_ID
] = $f_show_priority;
490 $t_setting_arr[ FILTER_PROPERTY_MONITOR_USER_ID
] = $f_user_monitor;
491 $t_setting_arr[ FILTER_PROPERTY_VIEW_STATE_ID
] = $f_view_state;
492 $t_setting_arr['custom_fields'] = $f_custom_fields_data;
493 $t_setting_arr[ FILTER_PROPERTY_SHOW_STICKY_ISSUES
] = $f_sticky_issues;
494 $t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_TYPE
] = $f_relationship_type;
495 $t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_BUG
] = $f_relationship_bug;
496 $t_setting_arr['show_profile'] = $f_show_profile;
497 $t_setting_arr[ FILTER_PROPERTY_PLATFORM
] = $f_platform;
498 $t_setting_arr[ FILTER_PROPERTY_OS
] = $f_os;
499 $t_setting_arr[ FILTER_PROPERTY_OS_BUILD
] = $f_os_build;
500 $t_setting_arr[ FILTER_PROPERTY_TAG_STRING
] = $f_tag_string;
501 $t_setting_arr[ FILTER_PROPERTY_TAG_SELECT
] = $f_tag_select;
502 $t_setting_arr[ FILTER_PROPERTY_NOTE_USER_ID
] = $f_note_user_id;
503 $t_setting_arr = array_merge( $t_setting_arr, $f_filter_input );
505 # Set the sort order and direction
507 log_event( LOG_FILTERING
, 'view_all_set.php: Set the sort order and direction.' );
509 # We only need to set those fields that we are overriding
510 $t_setting_arr[ FILTER_PROPERTY_SORT_FIELD_NAME
] = $f_sort;
511 $t_setting_arr[ FILTER_PROPERTY_SORT_DIRECTION
] = $f_dir;
514 # This is when we want to copy another query from the
515 # database over the top of our current one
517 log_event( LOG_FILTERING
, 'view_all_set.php: Copy another query from database' );
519 $t_filter_string = filter_db_get_filter( $f_source_query_id );
520 # If we can use the query that we've requested,
521 # grab it. We will overwrite the current one at the
522 # bottom of this page
523 $t_setting_arr = filter_deserialize( $t_filter_string );
524 if ( false === $t_setting_arr ) {
525 # couldn't deserialize, if we were trying to use the filter, clear it and reload
526 gpc_clear_cookie( 'view_all_cookie' );
527 error_proceed_url( 'view_all_set.php?type=0' );
528 trigger_error( ERROR_FILTER_TOO_OLD
, ERROR
);
532 # Generalise the filter
534 log_event( LOG_FILTERING
, 'view_all_set.php: Generalise the filter' );
536 $t_setting_arr[ FILTER_PROPERTY_CATEGORY
] = array( META_FILTER_ANY
);
537 $t_setting_arr[ FILTER_PROPERTY_REPORTER_ID
] = array( META_FILTER_ANY
);
538 $t_setting_arr[ FILTER_PROPERTY_HANDLER_ID
] = array( META_FILTER_ANY
);
539 $t_setting_arr[ FILTER_PROPERTY_PRODUCT_BUILD
] = array( META_FILTER_ANY
);
540 $t_setting_arr[ FILTER_PROPERTY_PRODUCT_VERSION
] = array( META_FILTER_ANY
);
541 $t_setting_arr[ FILTER_PROPERTY_PRIORITY_ID
] = array( META_FILTER_ANY
);
542 $t_setting_arr[ FILTER_PROPERTY_FIXED_IN_VERSION
] = array( META_FILTER_ANY
);
543 $t_setting_arr[ FILTER_PROPERTY_TARGET_VERSION
] = array( META_FILTER_ANY
);
544 $t_setting_arr[ FILTER_PROPERTY_MONITOR_USER_ID
] = array( META_FILTER_ANY
);
545 $t_setting_arr[ FILTER_PROPERTY_NOTE_USER_ID
] = array( META_FILTER_ANY
);
546 $t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_TYPE
] = -1;
547 $t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_BUG
] = 0;
549 $t_custom_fields = custom_field_get_ids(); # @@@ (thraxisp) This should really be the linked ids, but we don't know the project
550 $t_custom_fields_data = array();
551 if ( is_array( $t_custom_fields ) && ( count( $t_custom_fields ) > 0 ) ) {
552 foreach( $t_custom_fields as $t_cfid ) {
553 $t_custom_fields_data[$t_cfid] = array( META_FILTER_ANY
);
556 $t_setting_arr['custom_fields'] = $t_custom_fields_data;
559 # Just set the search string value
561 log_event( LOG_FILTERING
, 'view_all_set.php: Search Text' );
562 $t_setting_arr[ FILTER_PROPERTY_FREE_TEXT
] = $f_search;
565 # Just set the view_state (simple / advanced) value
567 log_event( LOG_FILTERING
, 'view_all_set.php: View state (simple/advanced)' );
568 $t_setting_arr['_view_type'] = $f_view_type;
571 # does nothing. catch all case
573 log_event( LOG_FILTERING
, 'view_all_set.php: default - do nothing' );
577 $tc_setting_arr = filter_ensure_valid_filter( $t_setting_arr );
579 $t_settings_serialized = serialize( $tc_setting_arr );
580 $t_settings_string = $t_cookie_version . '#' . $t_settings_serialized;
582 # If only using a temporary filter, don't store it in the database
583 if ( !$f_temp_filter ) {
584 # Store the filter string in the database: its the current filter, so some values won't change
585 $t_project_id = helper_get_current_project();
586 $t_project_id = ( $t_project_id * -1 );
587 $t_row_id = filter_db_set_for_current_user( $t_project_id, false, '', $t_settings_string );
590 gpc_set_cookie( config_get( 'view_all_cookie' ), $t_row_id, time()+
config_get( 'cookie_time_length' ), config_get( 'cookie_path' ) );
593 # redirect to print_all or view_all page
595 $t_redirect_url = 'print_all_bug_page.php';
597 $t_redirect_url = 'view_all_bug_page.php';
600 if ( $f_temp_filter ) {
601 $t_token_id = token_set( TOKEN_FILTER
, $t_settings_serialized );
602 $t_redirect_url = $t_redirect_url . '?filter=' . $t_token_id;
603 html_meta_redirect( $t_redirect_url, 0 );
605 print_header_redirect( $t_redirect_url );