Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / set_project.php
blobdef62947919974ac14a9338e02cb9b1fa4ba2e0c
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 - 2010 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 require_once( 'core.php' );
39 require_api( 'config_api.php' );
40 require_api( 'constant_inc.php' );
41 require_api( 'current_user_api.php' );
42 require_api( 'filter_api.php' );
43 require_api( 'gpc_api.php' );
44 require_api( 'helper_api.php' );
45 require_api( 'html_api.php' );
46 require_api( 'lang_api.php' );
47 require_api( 'print_api.php' );
48 require_api( 'project_api.php' );
49 require_api( 'string_api.php' );
50 require_api( 'utility_api.php' );
52 $f_project_id = gpc_get_string( 'project_id' );
53 $f_make_default = gpc_get_bool ( 'make_default' );
54 $f_ref = gpc_get_string( 'ref', '' );
56 $c_ref = string_prepare_header( $f_ref );
58 $t_project = explode( ';', $f_project_id );
59 $t_top = $t_project[0];
60 $t_bottom = $t_project[ count( $t_project ) - 1 ];
62 if ( ALL_PROJECTS != $t_bottom ) {
63 project_ensure_exists( $t_bottom );
66 # Set default project
67 if ( $f_make_default ) {
68 current_user_set_default_project( $t_top );
71 helper_set_current_project( $f_project_id );
73 # redirect to 'same page' when switching projects.
75 # for proxies that clear out HTTP_REFERER
76 if ( !is_blank( $c_ref ) ) {
77 $t_redirect_url = $c_ref;
78 } else if ( !isset( $_SERVER['HTTP_REFERER'] ) || is_blank( $_SERVER['HTTP_REFERER'] ) ) {
79 $t_redirect_url = config_get( 'default_home_page' );
80 } else {
81 $t_home_page = config_get( 'default_home_page' );
83 # Check that referrer matches our address after squashing case (case insensitive compare)
84 $t_path = rtrim( config_get( 'path' ), '/' );
85 if ( preg_match( "@^($t_path)/(?:/*([^\?#]*))(.*)?\$@", $_SERVER['HTTP_REFERER'], $t_matches ) ) {
86 $t_referrer_page = $t_matches[2];
87 $t_param = $t_matches[3];
89 # if view_all_bug_page, pass on filter
90 if ( strcasecmp( 'view_all_bug_page.php', $t_referrer_page ) == 0 ) {
91 $t_source_filter_id = filter_db_get_project_current( $f_project_id );
92 $t_redirect_url = 'view_all_set.php?type=4';
94 if ( $t_source_filter_id !== null ) {
95 $t_redirect_url = 'view_all_set.php?type=3&source_query_id=' . $t_source_filter_id;
97 } else if ( stripos( $t_referrer_page, '_page.php' ) !== false ) {
98 switch ( $t_referrer_page ) {
99 case 'bug_view_page.php':
100 case 'bug_view_advanced_page.php':
101 case 'bug_update_page.php':
102 case 'bug_update_advanced_page.php':
103 case 'bug_change_status_page.php':
104 $t_path = $t_home_page;
105 break;
106 default:
107 $t_path = $t_referrer_page . $t_param;
108 break;
110 $t_redirect_url = $t_path;
111 } else {
112 $t_redirect_url = $t_home_page;
114 } else {
115 $t_redirect_url = $t_home_page;
119 print_header_redirect( $t_redirect_url, true, true );
121 html_page_top1();
122 html_meta_redirect( $t_redirect_url );
124 html_page_top1();
127 <br />
128 <div align="center">
129 <?php
130 echo lang_get( 'operation_successful' ).'<br />';
132 print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
134 </div>
136 <?php
137 html_page_bottom();