SOAP API: do not try to unserialize an invalid filter
[mantis.git] / set_project.php
blob711cd1dc7e1bdd76dd43d326f24cf14b43c06381
1 <?php
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/>.
17 /**
18 * @package MantisBT
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
23 * @uses core.php
24 * @uses config_api.php
25 * @uses constant_inc.php
26 * @uses current_user_api.php
27 * @uses filter_api.php
28 * @uses gpc_api.php
29 * @uses helper_api.php
30 * @uses html_api.php
31 * @uses lang_api.php
32 * @uses print_api.php
33 * @uses project_api.php
34 * @uses string_api.php
35 * @uses utility_api.php
38 /**
39 * MantisBT Core API's
41 require_once( 'core.php' );
42 require_api( 'config_api.php' );
43 require_api( 'constant_inc.php' );
44 require_api( 'current_user_api.php' );
45 require_api( 'filter_api.php' );
46 require_api( 'gpc_api.php' );
47 require_api( 'helper_api.php' );
48 require_api( 'html_api.php' );
49 require_api( 'lang_api.php' );
50 require_api( 'print_api.php' );
51 require_api( 'project_api.php' );
52 require_api( 'string_api.php' );
53 require_api( 'utility_api.php' );
55 $f_project_id = gpc_get_string( 'project_id' );
56 $f_make_default = gpc_get_bool ( 'make_default' );
57 $f_ref = gpc_get_string( 'ref', '' );
59 $c_ref = string_prepare_header( $f_ref );
61 $t_project = explode( ';', $f_project_id );
62 $t_top = $t_project[0];
63 $t_bottom = $t_project[ count( $t_project ) - 1 ];
65 if ( ALL_PROJECTS != $t_bottom ) {
66 project_ensure_exists( $t_bottom );
69 # Set default project
70 if ( $f_make_default ) {
71 current_user_set_default_project( $t_top );
74 helper_set_current_project( $f_project_id );
76 # redirect to 'same page' when switching projects.
78 # for proxies that clear out HTTP_REFERER
79 if ( !is_blank( $c_ref ) ) {
80 $t_redirect_url = $c_ref;
81 } else if ( !isset( $_SERVER['HTTP_REFERER'] ) || is_blank( $_SERVER['HTTP_REFERER'] ) ) {
82 $t_redirect_url = config_get( 'default_home_page' );
83 } else {
84 $t_home_page = config_get( 'default_home_page' );
86 # Check that referrer matches our address after squashing case (case insensitive compare)
87 $t_path = rtrim( config_get( 'path' ), '/' );
88 if ( preg_match( "@^($t_path)/(?:/*([^\?#]*))(.*)?\$@", $_SERVER['HTTP_REFERER'], $t_matches ) ) {
89 $t_referrer_page = $t_matches[2];
90 $t_param = $t_matches[3];
92 # if view_all_bug_page, pass on filter
93 if ( strcasecmp( 'view_all_bug_page.php', $t_referrer_page ) == 0 ) {
94 $t_source_filter_id = filter_db_get_project_current( $f_project_id );
95 $t_redirect_url = 'view_all_set.php?type=4';
97 if ( $t_source_filter_id !== null ) {
98 $t_redirect_url = 'view_all_set.php?type=3&source_query_id=' . $t_source_filter_id;
100 } else if ( stripos( $t_referrer_page, '_page.php' ) !== false ) {
101 switch ( $t_referrer_page ) {
102 case 'bug_view_page.php':
103 case 'bug_view_advanced_page.php':
104 case 'bug_update_page.php':
105 case 'bug_update_advanced_page.php':
106 case 'bug_change_status_page.php':
107 $t_path = $t_home_page;
108 break;
109 default:
110 $t_path = $t_referrer_page . $t_param;
111 break;
113 $t_redirect_url = $t_path;
114 } else {
115 $t_redirect_url = $t_home_page;
117 } else {
118 $t_redirect_url = $t_home_page;
122 print_header_redirect( $t_redirect_url, true, true );
124 html_page_top1();
125 html_meta_redirect( $t_redirect_url );
127 html_page_top1();
130 <br />
131 <div>
132 <?php
133 echo lang_get( 'operation_successful' ).'<br />';
135 print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
137 </div>
139 <?php
140 html_page_bottom();