/
view_all_set.php
623 lines (553 loc) · 23.9 KB
/
view_all_set.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
<?php
# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
/**
* Set cookie for View all bugs page
*
* @package MantisBT
* @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
* @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*
* @uses core.php
* @uses authentication_api.php
* @uses config_api.php
* @uses constant_inc.php
* @uses custom_field_api.php
* @uses filter_api.php
* @uses filter_constants_inc.php
* @uses gpc_api.php
* @uses helper_api.php
* @uses html_api.php
* @uses logging_api.php
* @uses print_api.php
* @uses tokens_api.php
* @uses utility_api.php
*/
require_once( 'core.php' );
require_api( 'authentication_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
require_api( 'custom_field_api.php' );
require_api( 'filter_api.php' );
require_api( 'filter_constants_inc.php' );
require_api( 'gpc_api.php' );
require_api( 'helper_api.php' );
require_api( 'html_api.php' );
require_api( 'logging_api.php' );
require_api( 'print_api.php' );
require_api( 'tokens_api.php' );
require_api( 'utility_api.php' );
auth_ensure_user_authenticated();
$f_type = gpc_get_int( 'type', -1 );
$f_source_query_id = gpc_get_int( 'source_query_id', -1 );
$f_print = gpc_get_bool( 'print' );
$f_temp_filter = gpc_get_bool( 'temporary' );
# validate filter type
$f_default_view_type = 'simple';
if ( ADVANCED_DEFAULT == config_get( 'view_filters' ) ) {
$f_default_view_type = 'advanced';
}
$f_view_type = gpc_get_string( 'view_type', $f_default_view_type );
if ( ADVANCED_ONLY == config_get( 'view_filters' ) ) {
$f_view_type = 'advanced';
}
if ( SIMPLE_ONLY == config_get( 'view_filters' ) ) {
$f_view_type = 'simple';
}
if ( !in_array( $f_view_type, array( 'simple', 'advanced' ) ) ) {
$f_view_type = $f_default_view_type;
}
# these are all possibly multiple selections for advanced filtering
$f_show_category = array();
if ( is_array( gpc_get( FILTER_PROPERTY_CATEGORY_ID, null ) ) ) {
$f_show_category = gpc_get_string_array( FILTER_PROPERTY_CATEGORY_ID, META_FILTER_ANY );
} else {
$f_show_category = gpc_get_string( FILTER_PROPERTY_CATEGORY_ID, META_FILTER_ANY );
$f_show_category = array( $f_show_category );
}
$f_platform = array();
if ( is_array( gpc_get( FILTER_PROPERTY_PLATFORM, null ) ) ) {
$f_platform = gpc_get_string_array( FILTER_PROPERTY_PLATFORM, META_FILTER_ANY );
} else {
$f_platform = gpc_get_string( FILTER_PROPERTY_PLATFORM, META_FILTER_ANY );
$f_platform = array( $f_platform );
}
$f_os = array();
if ( is_array( gpc_get( FILTER_PROPERTY_OS, null ) ) ) {
$f_os = gpc_get_string_array( FILTER_PROPERTY_OS, META_FILTER_ANY );
} else {
$f_os = gpc_get_string( FILTER_PROPERTY_OS, META_FILTER_ANY );
$f_os = array( $f_os );
}
$f_os_build = array();
if ( is_array( gpc_get( FILTER_PROPERTY_OS_BUILD, null ) ) ) {
$f_os_build = gpc_get_string_array( FILTER_PROPERTY_OS_BUILD, META_FILTER_ANY );
} else {
$f_os_build = gpc_get_string( FILTER_PROPERTY_OS_BUILD, META_FILTER_ANY );
$f_os_build = array( $f_os_build );
}
$f_show_severity = array();
if ( is_array( gpc_get( FILTER_PROPERTY_SEVERITY, null ) ) ) {
$f_show_severity = gpc_get_string_array( FILTER_PROPERTY_SEVERITY, META_FILTER_ANY );
} else {
$f_show_severity = gpc_get_string( FILTER_PROPERTY_SEVERITY, META_FILTER_ANY );
$f_show_severity = array( $f_show_severity );
}
$f_show_status = array();
if ( is_array( gpc_get( FILTER_PROPERTY_STATUS, null ) ) ) {
$f_show_status = gpc_get_string_array( FILTER_PROPERTY_STATUS, META_FILTER_ANY );
} else {
$f_show_status = gpc_get_string( FILTER_PROPERTY_STATUS, META_FILTER_ANY );
$f_show_status = array( $f_show_status );
}
$f_hide_status = array();
if ( is_array( gpc_get( FILTER_PROPERTY_HIDE_STATUS, null ) ) ) {
$f_hide_status = gpc_get_string_array( FILTER_PROPERTY_HIDE_STATUS, META_FILTER_NONE );
} else {
$f_hide_status = gpc_get_string( FILTER_PROPERTY_HIDE_STATUS, META_FILTER_NONE );
$f_hide_status = array( $f_hide_status );
}
$f_reporter_id = array();
if ( is_array( gpc_get( FILTER_PROPERTY_REPORTER_ID, null ) ) ) {
$f_reporter_id = gpc_get_string_array( FILTER_PROPERTY_REPORTER_ID, META_FILTER_ANY );
} else {
$f_reporter_id = gpc_get_string( FILTER_PROPERTY_REPORTER_ID, META_FILTER_ANY );
$f_reporter_id = array( $f_reporter_id );
}
$f_handler_id = array();
if ( is_array( gpc_get( FILTER_PROPERTY_HANDLER_ID, null ) ) ) {
$f_handler_id = gpc_get_string_array( FILTER_PROPERTY_HANDLER_ID, META_FILTER_ANY );
} else {
$f_handler_id = gpc_get_string( FILTER_PROPERTY_HANDLER_ID, META_FILTER_ANY );
$f_handler_id = array( $f_handler_id );
}
$f_project_id = array();
if ( is_array( gpc_get( FILTER_PROPERTY_PROJECT_ID, null ) ) ) {
$f_project_id = gpc_get_int_array( FILTER_PROPERTY_PROJECT_ID, META_FILTER_CURRENT );
} else {
$f_project_id = gpc_get_int( FILTER_PROPERTY_PROJECT_ID, META_FILTER_CURRENT );
$f_project_id = array( $f_project_id );
}
$f_show_resolution = array();
if ( is_array( gpc_get( FILTER_PROPERTY_RESOLUTION, null ) ) ) {
$f_show_resolution = gpc_get_string_array( FILTER_PROPERTY_RESOLUTION, META_FILTER_ANY );
} else {
$f_show_resolution = gpc_get_string( FILTER_PROPERTY_RESOLUTION, META_FILTER_ANY );
$f_show_resolution = array( $f_show_resolution );
}
$f_show_build = array();
if ( is_array( gpc_get( FILTER_PROPERTY_BUILD, null ) ) ) {
$f_show_build = gpc_get_string_array( FILTER_PROPERTY_BUILD, META_FILTER_ANY );
} else {
$f_show_build = gpc_get_string( FILTER_PROPERTY_BUILD, META_FILTER_ANY );
$f_show_build = array( $f_show_build );
}
$f_show_version = array();
if ( is_array( gpc_get( FILTER_PROPERTY_VERSION, null ) ) ) {
$f_show_version = gpc_get_string_array( FILTER_PROPERTY_VERSION, META_FILTER_ANY );
} else {
$f_show_version = gpc_get_string( FILTER_PROPERTY_VERSION, META_FILTER_ANY );
$f_show_version = array( $f_show_version );
}
$f_fixed_in_version = array();
if ( is_array( gpc_get( FILTER_PROPERTY_FIXED_IN_VERSION, null ) ) ) {
$f_fixed_in_version = gpc_get_string_array( FILTER_PROPERTY_FIXED_IN_VERSION, META_FILTER_ANY );
} else {
$f_fixed_in_version = gpc_get_string( FILTER_PROPERTY_FIXED_IN_VERSION, META_FILTER_ANY );
$f_fixed_in_version = array( $f_fixed_in_version );
}
$f_target_version = array();
if ( is_array( gpc_get( FILTER_PROPERTY_TARGET_VERSION, null ) ) ) {
$f_target_version = gpc_get_string_array( FILTER_PROPERTY_TARGET_VERSION, META_FILTER_ANY );
} else {
$f_target_version = gpc_get_string( FILTER_PROPERTY_TARGET_VERSION, META_FILTER_ANY );
$f_target_version = array( $f_target_version );
}
$f_show_profile = array();
if ( is_array( gpc_get( FILTER_PROPERTY_PROFILE_ID, null ) ) ) {
$f_show_profile = gpc_get_string_array( FILTER_PROPERTY_PROFILE_ID, META_FILTER_ANY );
} else {
$f_show_profile = gpc_get_string( FILTER_PROPERTY_PROFILE_ID, META_FILTER_ANY );
$f_show_profile = array( $f_show_profile );
}
$f_show_priority = array();
if ( is_array( gpc_get( FILTER_PROPERTY_PRIORITY, null ) ) ) {
$f_show_priority = gpc_get_string_array( FILTER_PROPERTY_PRIORITY, META_FILTER_ANY );
} else {
$f_show_priority = gpc_get_string( FILTER_PROPERTY_PRIORITY, META_FILTER_ANY );
$f_show_priority = array( $f_show_priority );
}
$f_user_monitor = array();
if ( is_array( gpc_get( FILTER_PROPERTY_MONITOR_USER_ID, null ) ) ) {
$f_user_monitor = gpc_get_string_array( FILTER_PROPERTY_MONITOR_USER_ID, META_FILTER_ANY );
} else {
$f_user_monitor = gpc_get_string( FILTER_PROPERTY_MONITOR_USER_ID, META_FILTER_ANY );
$f_user_monitor = array( $f_user_monitor );
}
$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 );
}
# these are only single values, even when doing advanced filtering
$f_per_page = gpc_get_int( FILTER_PROPERTY_ISSUES_PER_PAGE, -1 );
$f_highlight_changed = gpc_get_int( FILTER_PROPERTY_HIGHLIGHT_CHANGED, config_get( 'default_show_changed' ) );
$f_sticky_issues = gpc_get_bool( FILTER_PROPERTY_STICKY );
# sort direction
$f_sort_d = gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME, '' );
$f_dir_d = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION, '' );
$f_sort_0 = gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME . '_0', 'last_updated' );
$f_dir_0 = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION . '_0', 'DESC' );
$f_sort_1 = gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME . '_1', '' );
$f_dir_1 = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION . '_1', '' );
# date values
$f_start_month = gpc_get_int( FILTER_PROPERTY_START_MONTH, date( 'm' ) );
$f_end_month = gpc_get_int( FILTER_PROPERTY_END_MONTH, date( 'm' ) );
$f_start_day = gpc_get_int( FILTER_PROPERTY_START_DAY, 1 );
$f_end_day = gpc_get_int( FILTER_PROPERTY_END_DAY, date( 'd' ) );
$f_start_year = gpc_get_int( FILTER_PROPERTY_START_YEAR, date( 'Y' ) );
$f_end_year = gpc_get_int( FILTER_PROPERTY_END_YEAR, date( 'Y' ) );
$f_search = gpc_get_string( FILTER_PROPERTY_SEARCH, '' );
$f_do_filter_by_date = gpc_get_bool( FILTER_PROPERTY_FILTER_BY_DATE );
$f_view_state = gpc_get_int( FILTER_PROPERTY_VIEW_STATE, META_FILTER_ANY );
$f_tag_string = gpc_get_string( FILTER_PROPERTY_TAG_STRING, '' );
$f_tag_select = gpc_get_int( FILTER_PROPERTY_TAG_SELECT, '0' );
# plugin filter updates
$t_plugin_filters = filter_get_plugin_filters();
$f_filter_input = array();
foreach( $t_plugin_filters as $t_field_name => $t_filter_object ) {
switch( $t_filter_object->type ) {
case FILTER_TYPE_STRING:
$f_filter_input[ $t_field_name ] = gpc_get_string( $t_field_name, $t_filter_object->default );
break;
case FILTER_TYPE_INT:
$f_filter_input[ $t_field_name ] = gpc_get_int( $t_field_name, $t_filter_object->default );
break;
case FILTER_TYPE_BOOLEAN:
$f_filter_input[ $t_field_name ] = gpc_get_bool( $t_field_name, OFF );
break;
case FILTER_TYPE_MULTI_STRING:
$f_filter_input[ $t_field_name ] = gpc_get_string_array( $t_field_name, $t_filter_object->default );
break;
case FILTER_TYPE_MULTI_INT:
$f_filter_input[ $t_field_name ] = gpc_get_int_array( $t_field_name, $t_filter_object->default );
break;
}
}
# custom field updates
$t_custom_fields = custom_field_get_ids(); /** @todo (thraxisp) This should really be the linked ids, but we don't know the project */
$f_custom_fields_data = array();
if ( is_array( $t_custom_fields ) && ( count( $t_custom_fields ) > 0 ) ) {
foreach( $t_custom_fields as $t_cfid ) {
if (custom_field_type( $t_cfid ) == CUSTOM_FIELD_TYPE_DATE) {
$t_control = gpc_get_string( 'custom_field_' . $t_cfid . '_control', null);
$t_year = gpc_get_int( 'custom_field_' . $t_cfid . '_start_year', null);
$t_month = gpc_get_int( 'custom_field_' . $t_cfid . '_start_month', null);
$t_day = gpc_get_int( 'custom_field_' . $t_cfid . '_start_day', null);
$t_start_date = mktime(0, 0, 0, $t_month, $t_day, $t_year);
$t_year = gpc_get_int( 'custom_field_' . $t_cfid . '_end_year', null);
$t_month = gpc_get_int( 'custom_field_' . $t_cfid . '_end_month', null);
$t_day = gpc_get_int( 'custom_field_' . $t_cfid . '_end_day', null);
$t_end_date = mktime(0, 0, 0, $t_month, $t_day, $t_year);
$f_custom_fields_data[$t_cfid] = array();
$f_custom_fields_data[$t_cfid][0] = $t_control;
$t_start = 1;
$t_end = 1;
$t_one_day = 86399;
switch ($t_control)
{
case CUSTOM_FIELD_DATE_ANY:
case CUSTOM_FIELD_DATE_NONE:
break ;
case CUSTOM_FIELD_DATE_BETWEEN:
$t_start = $t_start_date;
$t_end = $t_end_date + $t_one_day - 1;
break ;
case CUSTOM_FIELD_DATE_ONORBEFORE:
$t_end = $t_start_date + $t_one_day - 1;
break;
case CUSTOM_FIELD_DATE_BEFORE:
$t_end = $t_start_date;
break ;
case CUSTOM_FIELD_DATE_ON:
$t_start = $t_start_date;
$t_end = $t_start_date + $t_one_day - 1;
break;
case CUSTOM_FIELD_DATE_AFTER:
$t_start = $t_start_date + $t_one_day - 1;
$t_end = 2147483647; // Some time in 2038, max value of a signed int.
break;
case CUSTOM_FIELD_DATE_ONORAFTER:
$t_start = $t_start_date;
$t_end = 2147483647; // Some time in 2038, max value of a signed int.
break;
}
$f_custom_fields_data[$t_cfid][1] = $t_start;
$f_custom_fields_data[$t_cfid][2] = $t_end;
} else {
if ( is_array( gpc_get( 'custom_field_' . $t_cfid, null ) ) ) {
$f_custom_fields_data[$t_cfid] = gpc_get_string_array( 'custom_field_' . $t_cfid, META_FILTER_ANY );
} else {
$f_custom_fields_data[$t_cfid] = gpc_get_string( 'custom_field_' . $t_cfid, META_FILTER_ANY );
$f_custom_fields_data[$t_cfid] = array( $f_custom_fields_data[$t_cfid] );
}
}
}
}
$f_relationship_type = gpc_get_int( FILTER_PROPERTY_RELATIONSHIP_TYPE, -1 );
$f_relationship_bug = gpc_get_int( FILTER_PROPERTY_RELATIONSHIP_BUG, 0 );
if ( $f_temp_filter ) {
$f_type = 1;
}
if ( $f_do_filter_by_date ) {
$f_do_filter_by_date = true;
}
if ( $f_sticky_issues ) {
$f_sticky_issues = true;
} else {
$f_sticky_issues = false;
}
if ( $f_type < 0 ) {
print_header_redirect( 'view_all_bug_page.php' );
}
$t_hide_status_default = config_get( 'hide_status_default' );
# show bugs per page
if ( $f_per_page < 0 ) {
$f_per_page = config_get( 'default_limit_view' );
}
# combine sort settings
# (f_sort overrides f_sort_1 if set to keep old sorting code working in view_all_bug_inc)
$f_sort = ( ( $f_sort_d != "" ) ? $f_sort_d : $f_sort_0 ) . ( ( $f_sort_1 != "" ) ? "," . $f_sort_1 : "" );
$f_dir = ( ( $f_dir_d != "" ) ? $f_dir_d : $f_dir_0 ) . ( ( $f_dir_1 != "" ) ? "," . $f_dir_1 : "" );
# -1 is a special case stored query: it means we want to reset our filter
if ( ( $f_type == 3 ) && ( $f_source_query_id == -1 ) ) {
$f_type = 0;
}
/* array contents
--------------
0: version
1: $f_show_category
2: $f_show_severity
3: $f_show_status
4: $f_per_page
5: $f_highlight_changed
6: $f_hide_closed
7: $f_reporter_id
8: $f_handler_id
9: $f_sort
10: $f_dir
11: $f_start_month
12: $f_start_day
13: $f_start_year
14: $f_end_month
15: $f_end_day
16: $f_end_year
17: $f_search
18: $f_hide_resolved
19: $f_show_resolution
20: $f_show_build
21: $f_show_version
22: $f_do_filter_by_date
23: $f_custom_field
24: $f_relationship_type
25: $f_relationship_bug
26: $f_show_profile
*/
# Set new filter values. These are stored in a cookie
$t_view_all_cookie_id = gpc_get_cookie( config_get_global( 'view_all_cookie' ), '' );
$t_view_all_cookie = filter_db_get_filter( $t_view_all_cookie_id );
# process the cookie if it exists, it may be blank in a new install
if ( !is_blank( $t_view_all_cookie ) ) {
$t_setting_arr = filter_deserialize( $t_view_all_cookie );
if ( false === $t_setting_arr ) {
# couldn't deserialize, if we were trying to use the filter, clear it and reload
# for ftype = 0, 1, or 3, we are going to re-write the filter anyways
if ( !in_array( $f_type, array( 0, 1, 3 ) ) ) {
gpc_clear_cookie( 'view_all_cookie' );
throw new MantisBT\Exception\Filter\FilterTooOldToUpgrade();
}
}
} else {
# no cookie found, set it
$f_type = 1;
}
$t_cookie_version = config_get_global( 'cookie_version' );
$t_default_show_changed = config_get( 'default_show_changed' );
# Clear the source query id. Since we have entered new filter criteria.
$t_setting_arr['_source_query_id'] = '';
switch ( $f_type ) {
# New cookie
case '0':
log_event( LOG_FILTERING, 'view_all_set.php: New cookie' );
$t_setting_arr = array();
break;
# Update filters
case '1':
log_event( LOG_FILTERING, 'view_all_set.php: Update filters' );
$t_setting_arr['_version'] = $t_cookie_version;
$t_setting_arr['_view_type'] = $f_view_type;
$t_setting_arr[ FILTER_PROPERTY_CATEGORY_ID ] = $f_show_category;
$t_setting_arr[ FILTER_PROPERTY_SEVERITY ] = $f_show_severity;
$t_setting_arr[ FILTER_PROPERTY_STATUS ] = $f_show_status;
$t_setting_arr[ FILTER_PROPERTY_ISSUES_PER_PAGE ] = $f_per_page;
$t_setting_arr[ FILTER_PROPERTY_HIGHLIGHT_CHANGED ] = $f_highlight_changed;
$t_setting_arr[ FILTER_PROPERTY_REPORTER_ID ] = $f_reporter_id;
$t_setting_arr[ FILTER_PROPERTY_HANDLER_ID ] = $f_handler_id;
$t_setting_arr[ FILTER_PROPERTY_PROJECT_ID ] = $f_project_id;
$t_setting_arr[ FILTER_PROPERTY_SORT_FIELD_NAME ] = $f_sort;
$t_setting_arr[ FILTER_PROPERTY_SORT_DIRECTION ] = $f_dir;
$t_setting_arr[ FILTER_PROPERTY_START_MONTH ] = $f_start_month;
$t_setting_arr[ FILTER_PROPERTY_START_DAY ] = $f_start_day;
$t_setting_arr[ FILTER_PROPERTY_START_YEAR ] = $f_start_year;
$t_setting_arr[ FILTER_PROPERTY_END_MONTH ] = $f_end_month;
$t_setting_arr[ FILTER_PROPERTY_END_DAY ] = $f_end_day;
$t_setting_arr[ FILTER_PROPERTY_END_YEAR ] = $f_end_year;
$t_setting_arr[ FILTER_PROPERTY_SEARCH] = $f_search;
$t_setting_arr[ FILTER_PROPERTY_HIDE_STATUS ] = $f_hide_status;
$t_setting_arr[ FILTER_PROPERTY_RESOLUTION ] = $f_show_resolution;
$t_setting_arr[ FILTER_PROPERTY_BUILD ] = $f_show_build;
$t_setting_arr[ FILTER_PROPERTY_VERSION ] = $f_show_version;
$t_setting_arr[ FILTER_PROPERTY_FILTER_BY_DATE ] = $f_do_filter_by_date;
$t_setting_arr[ FILTER_PROPERTY_FIXED_IN_VERSION ] = $f_fixed_in_version;
$t_setting_arr[ FILTER_PROPERTY_TARGET_VERSION ] = $f_target_version;
$t_setting_arr[ FILTER_PROPERTY_PRIORITY ] = $f_show_priority;
$t_setting_arr[ FILTER_PROPERTY_MONITOR_USER_ID ] = $f_user_monitor;
$t_setting_arr[ FILTER_PROPERTY_VIEW_STATE ] = $f_view_state;
$t_setting_arr['custom_fields'] = $f_custom_fields_data;
$t_setting_arr[ FILTER_PROPERTY_STICKY ] = $f_sticky_issues;
$t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_TYPE ] = $f_relationship_type;
$t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_BUG ] = $f_relationship_bug;
$t_setting_arr[ FILTER_PROPERTY_PROFILE_ID ] = $f_show_profile;
$t_setting_arr[ FILTER_PROPERTY_PLATFORM ] = $f_platform;
$t_setting_arr[ FILTER_PROPERTY_OS ] = $f_os;
$t_setting_arr[ FILTER_PROPERTY_OS_BUILD ] = $f_os_build;
$t_setting_arr[ FILTER_PROPERTY_TAG_STRING ] = $f_tag_string;
$t_setting_arr[ FILTER_PROPERTY_TAG_SELECT ] = $f_tag_select;
$t_setting_arr[ FILTER_PROPERTY_NOTE_USER_ID ] = $f_note_user_id;
$t_setting_arr = array_merge( $t_setting_arr, $f_filter_input );
break;
# Set the sort order and direction
case '2':
log_event( LOG_FILTERING, 'view_all_set.php: Set the sort order and direction.' );
# We only need to set those fields that we are overriding
$t_setting_arr[ FILTER_PROPERTY_SORT_FIELD_NAME ] = $f_sort;
$t_setting_arr[ FILTER_PROPERTY_SORT_DIRECTION ] = $f_dir;
break;
# This is when we want to copy another query from the
# database over the top of our current one
case '3':
log_event( LOG_FILTERING, 'view_all_set.php: Copy another query from database' );
$t_filter_string = filter_db_get_filter( $f_source_query_id );
# If we can use the query that we've requested,
# grab it. We will overwrite the current one at the
# bottom of this page
$t_setting_arr = filter_deserialize( $t_filter_string );
if ( false === $t_setting_arr ) {
# couldn't deserialize, if we were trying to use the filter, clear it and reload
gpc_clear_cookie( 'view_all_cookie' );
throw new MantisBT\Exception\Filter\FilterTooOldToUpgrade();
}
# Store the source query id to select the correct filter in the drop down.
$t_setting_arr['_source_query_id'] = $f_source_query_id;
break;
# Generalise the filter
case '4':
log_event( LOG_FILTERING, 'view_all_set.php: Generalise the filter' );
$t_setting_arr[ FILTER_PROPERTY_CATEGORY_ID ] = array( META_FILTER_ANY );
$t_setting_arr[ FILTER_PROPERTY_REPORTER_ID ] = array( META_FILTER_ANY );
$t_setting_arr[ FILTER_PROPERTY_HANDLER_ID ] = array( META_FILTER_ANY );
$t_setting_arr[ FILTER_PROPERTY_BUILD ] = array( META_FILTER_ANY );
$t_setting_arr[ FILTER_PROPERTY_VERSION ] = array( META_FILTER_ANY );
$t_setting_arr[ FILTER_PROPERTY_PRIORITY ] = array( META_FILTER_ANY );
$t_setting_arr[ FILTER_PROPERTY_FIXED_IN_VERSION ] = array( META_FILTER_ANY );
$t_setting_arr[ FILTER_PROPERTY_TARGET_VERSION ] = array( META_FILTER_ANY );
$t_setting_arr[ FILTER_PROPERTY_MONITOR_USER_ID ] = array( META_FILTER_ANY );
$t_setting_arr[ FILTER_PROPERTY_NOTE_USER_ID ] = array( META_FILTER_ANY );
$t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_TYPE ] = -1;
$t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_BUG ] = 0;
$t_custom_fields = custom_field_get_ids(); # @@@ (thraxisp) This should really be the linked ids, but we don't know the project
$t_custom_fields_data = array();
if ( is_array( $t_custom_fields ) && ( count( $t_custom_fields ) > 0 ) ) {
foreach( $t_custom_fields as $t_cfid ) {
$t_custom_fields_data[$t_cfid] = array( META_FILTER_ANY );
}
}
$t_setting_arr['custom_fields'] = $t_custom_fields_data;
break;
# Just set the search string value
case '5':
log_event( LOG_FILTERING, 'view_all_set.php: Search Text' );
$t_setting_arr[ FILTER_PROPERTY_SEARCH ] = $f_search;
break;
# Just set the view_state (simple / advanced) value
case '6':
log_event( LOG_FILTERING, 'view_all_set.php: View state (simple/advanced)' );
$t_setting_arr['_view_type'] = $f_view_type;
break;
# does nothing. catch all case
default:
log_event( LOG_FILTERING, 'view_all_set.php: default - do nothing' );
break;
}
$tc_setting_arr = filter_ensure_valid_filter( $t_setting_arr );
/**
* Remove any statuses that should be excluded by the hide_status field
*/
if( $f_view_type == "advanced" ) {
if( $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] > 0 ) {
$t_statuses = MantisEnum::getValues( config_get( 'status_enum_string' ) );
foreach( $t_statuses as $t_key=>$t_val ) {
if( $t_val < $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] ) {
$t_keep_statuses[$t_key] = $t_val;
}
}
$tc_setting_arr[FILTER_PROPERTY_STATUS] = $t_keep_statuses;
}
}
/**
* If a status is selected in the status and the hide status field, remove it from
* hide status
*/
if( $f_view_type == "simple" && $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] > 0 ) {
foreach( $tc_setting_arr[FILTER_PROPERTY_STATUS] as $t_key => $t_val ) {
if( $tc_setting_arr[FILTER_PROPERTY_STATUS][$t_key] == $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] ) {
unset( $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] );
}
}
}
$t_settings_serialized = serialize( $tc_setting_arr );
$t_settings_string = $t_cookie_version . '#' . $t_settings_serialized;
# If only using a temporary filter, don't store it in the database
if ( !$f_temp_filter ) {
# Store the filter string in the database: its the current filter, so some values won't change
$t_project_id = helper_get_current_project();
$t_project_id = ( $t_project_id * -1 );
$t_row_id = filter_db_set_for_current_user( $t_project_id, false, '', $t_settings_string );
# set cookie values
gpc_set_cookie( config_get_global( 'view_all_cookie' ), $t_row_id, time()+config_get_global( 'cookie_time_length' ), config_get_global( 'cookie_path' ) );
}
# redirect to print_all or view_all page
if ( $f_print ) {
$t_redirect_url = 'print_all_bug_page.php';
} else {
$t_redirect_url = 'view_all_bug_page.php';
}
if ( $f_temp_filter ) {
$t_token_id = token_set( TOKEN_FILTER, $t_settings_serialized );
$t_redirect_url = $t_redirect_url . '?filter=' . $t_token_id;
}
print_header_redirect( $t_redirect_url );