File: search.php

package info (click to toggle)
mantis 1.1.6+dfsg-2lenny6
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,576 kB
  • ctags: 14,851
  • sloc: php: 54,817; sql: 348; sh: 181; makefile: 56
file content (144 lines) | stat: -rw-r--r-- 7,339 bytes parent folder | download
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
<?php
# Mantis - a php based bugtracking system

# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net

# Mantis 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.
#
# Mantis 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 Mantis.  If not, see <http://www.gnu.org/licenses/>.

       # --------------------------------------------------------
       # $Revision: 1.5.2.1 $
       # $Author: giallu $
       # $Date: 2007-10-13 22:34:29 $
       #
       # $Id: search.php,v 1.5.2.1 2007-10-13 22:34:29 giallu Exp $
       # --------------------------------------------------------
?>
<?php
	require_once( 'core.php' );

	$t_core_path = config_get( 'core_path' );

	require_once( $t_core_path . 'compress_api.php' );
	require_once( $t_core_path . 'filter_api.php' );

	auth_ensure_user_authenticated();

	$f_print = gpc_get_bool( 'print' );

	gpc_make_array( FILTER_SEARCH_CATEGORY );
	gpc_make_array( FILTER_SEARCH_SEVERITY_ID );
	gpc_make_array( FILTER_SEARCH_STATUS_ID );
	gpc_make_array( FILTER_SEARCH_REPORTER_ID );
	gpc_make_array( FILTER_SEARCH_HANDLER_ID );
	gpc_make_array( FILTER_SEARCH_PROJECT_ID );
	gpc_make_array( FILTER_SEARCH_RESOLUTION_ID );
	gpc_make_array( FILTER_SEARCH_PRODUCT_BUILD );
	gpc_make_array( FILTER_SEARCH_PRODUCT_VERSION );
	gpc_make_array( FILTER_SEARCH_FIXED_IN_VERSION );
	gpc_make_array( FILTER_SEARCH_TARGET_VERSION );
	gpc_make_array( FILTER_SEARCH_PROFILE );
	gpc_make_array( FILTER_SEARCH_PLATFORM );
	gpc_make_array( FILTER_SEARCH_OS );
	gpc_make_array( FILTER_SEARCH_OS_BUILD );
	gpc_make_array( FILTER_SEARCH_PRIORITY_ID );
	gpc_make_array( FILTER_SEARCH_MONITOR_USER_ID );
	gpc_make_array( FILTER_SEARCH_VIEW_STATE_ID );

	$my_filter = filter_get_default();
	$my_filter[FILTER_PROPERTY_FREE_TEXT] = gpc_get_string( FILTER_SEARCH_FREE_TEXT, '' );
	$my_filter[FILTER_PROPERTY_CATEGORY] = gpc_get_string_array( FILTER_SEARCH_CATEGORY, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_REPORTER_ID] = gpc_get_string_array( FILTER_SEARCH_REPORTER_ID, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_HANDLER_ID] = gpc_get_string_array( FILTER_SEARCH_HANDLER_ID, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_SEVERITY_ID] = gpc_get_string_array( FILTER_SEARCH_SEVERITY_ID, META_FILTER_ANY );

	$my_filter[FILTER_PROPERTY_STATUS_ID] = gpc_get_string_array( FILTER_SEARCH_STATUS_ID, META_FILTER_ANY );

	$my_filter[FILTER_PROPERTY_PROJECT_ID] = gpc_get_string_array( FILTER_SEARCH_PROJECT_ID, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_RESOLUTION_ID] = gpc_get_string_array( FILTER_SEARCH_RESOLUTION_ID, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_PRODUCT_BUILD] = gpc_get_string_array( FILTER_SEARCH_PRODUCT_BUILD, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_FIXED_IN_VERSION] = gpc_get_string_array( FILTER_SEARCH_FIXED_IN_VERSION, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_TARGET_VERSION] = gpc_get_string_array( FILTER_SEARCH_TARGET_VERSION, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_PRIORITY_ID] = gpc_get_string_array( FILTER_SEARCH_PRIORITY_ID, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_MONITOR_USER_ID] = gpc_get_string_array( FILTER_SEARCH_MONITOR_USER_ID, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_PROFILE] = gpc_get_string_array( FILTER_SEARCH_PROFILE, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_PLATFORM] = gpc_get_string_array( FILTER_SEARCH_PLATFORM, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_OS] = gpc_get_string_array( FILTER_SEARCH_OS, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_OS_BUILD] = gpc_get_string_array( FILTER_SEARCH_OS_BUILD, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_VIEW_STATE_ID] = gpc_get_string_array( FILTER_SEARCH_VIEW_STATE_ID, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_PRODUCT_VERSION] = gpc_get_string_array( FILTER_SEARCH_PRODUCT_VERSION, META_FILTER_ANY );

	// Filtering by Date
	$my_filter[FILTER_PROPERTY_FILTER_BY_DATE] = gpc_get_bool( FILTER_SEARCH_FILTER_BY_DATE );
	$my_filter[FILTER_PROPERTY_START_MONTH] = gpc_get_int( FILTER_SEARCH_START_MONTH, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_START_DAY] = gpc_get_int( FILTER_SEARCH_START_DAY, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_START_YEAR] = gpc_get_int( FILTER_SEARCH_START_YEAR, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_END_MONTH] = gpc_get_int( FILTER_SEARCH_END_MONTH, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_END_DAY] = gpc_get_int( FILTER_SEARCH_END_DAY, META_FILTER_ANY );
	$my_filter[FILTER_PROPERTY_END_YEAR] = gpc_get_int( FILTER_SEARCH_END_YEAR, META_FILTER_ANY );

	$my_filter[FILTER_PROPERTY_NOT_ASSIGNED] = gpc_get_bool( FILTER_SEARCH_NOT_ASSIGNED );

	$my_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE] = gpc_get_int( FILTER_SEARCH_RELATIONSHIP_TYPE, -1 );
	$my_filter[FILTER_PROPERTY_RELATIONSHIP_BUG] = gpc_get_int( FILTER_SEARCH_RELATIONSHIP_BUG, 0 );

	$my_filter[FILTER_PROPERTY_HIDE_STATUS_ID] = gpc_get_int( FILTER_SEARCH_HIDE_STATUS_ID );
	$my_filter[FILTER_PROPERTY_SHOW_STICKY_ISSUES] = gpc_get_bool( FILTER_SEARCH_SHOW_STICKY_ISSUES );

	$my_filter[FILTER_PROPERTY_SORT_FIELD_NAME] = gpc_get_string( FILTER_SEARCH_SORT_FIELD_NAME, '' );
	$my_filter[FILTER_PROPERTY_SORT_DIRECTION] = gpc_get_string( FILTER_SEARCH_SORT_DIRECTION, '' );
	$my_filter[FILTER_PROPERTY_ISSUES_PER_PAGE] = gpc_get_int( FILTER_SEARCH_ISSUES_PER_PAGE, config_get( 'default_limit_view' ) );
	
	$t_highlight_changed = gpc_get_int( FILTER_SEARCH_HIGHLIGHT_CHANGED, -1 );
	if ( $t_highlight_changed != -1 ) {
		$my_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED] = $t_highlight_changed;
	}

	# Handle custom fields.
	$t_custom_fields = array();
	foreach( $_GET as $t_var_name => $t_var_value ) {
		if ( strpos( $t_var_name, 'custom_field_' ) === 0 ) {
			$t_custom_field_id = substr( $t_var_name, 13 );
			$t_custom_fields[$t_custom_field_id] = $t_var_value;
		}
	}

	$my_filter['custom_fields'] = $t_custom_fields;

	# Must use advanced filter so that the project_id is applied and multiple
	# selections are handled.
	$my_filter['_view_type'] = 'advanced';

	$tc_setting_arr = filter_ensure_valid_filter( $my_filter );

	$t_settings_serialized = serialize( $tc_setting_arr );
	$t_settings_string = config_get( 'cookie_version' ) . '#' . $t_settings_serialized;

	# 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( 'view_all_cookie' ), $t_row_id, time()+config_get( 'cookie_time_length' ), config_get( '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';
	}

	print_header_redirect( $t_redirect_url );
?>