Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / query_store.php
blob56cadb2a4225010ae30842d2a1c99a8a4a01e62f
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 authentication_api.php
25 * @uses compress_api.php
26 * @uses config_api.php
27 * @uses filter_api.php
28 * @uses form_api.php
29 * @uses gpc_api.php
30 * @uses helper_api.php
31 * @uses lang_api.php
32 * @uses print_api.php
33 * @uses utility_api.php
36 require_once( 'core.php' );
37 require_api( 'authentication_api.php' );
38 require_api( 'compress_api.php' );
39 require_api( 'config_api.php' );
40 require_api( 'filter_api.php' );
41 require_api( 'form_api.php' );
42 require_api( 'gpc_api.php' );
43 require_api( 'helper_api.php' );
44 require_api( 'lang_api.php' );
45 require_api( 'print_api.php' );
46 require_api( 'utility_api.php' );
48 form_security_validate( 'query_store' );
50 auth_ensure_user_authenticated();
51 compress_enable();
53 $f_query_name = strip_tags( gpc_get_string( 'query_name' ) );
54 $f_is_public = gpc_get_bool( 'is_public' );
55 $f_all_projects = gpc_get_bool( 'all_projects' );
57 $t_query_redirect_url = 'query_store_page.php';
59 # We can't have a blank name
60 if ( is_blank( $f_query_name ) ) {
61 $t_query_redirect_url = $t_query_redirect_url . '?error_msg='
62 . urlencode( lang_get( 'query_blank_name' ) );
63 print_header_redirect( $t_query_redirect_url );
66 // mantis_filters_table.name has a length of 64. Not allowing longer.
67 if ( !filter_name_valid_length( $f_query_name ) ) {
68 $t_query_redirect_url = $t_query_redirect_url . '?error_msg='
69 . urlencode( lang_get( 'query_name_too_long' ) );
70 print_header_redirect( $t_query_redirect_url );
73 # Check and make sure they don't already have a
74 # query with the same name
75 $t_query_arr = filter_db_get_available_queries();
76 foreach( $t_query_arr as $t_id => $t_name ) {
77 if ( $f_query_name == $t_name ) {
78 $t_query_redirect_url = $t_query_redirect_url . '?error_msg='
79 . urlencode( lang_get( 'query_dupe_name' ) );
80 print_header_redirect( $t_query_redirect_url );
81 exit;
85 $t_project_id = helper_get_current_project();
86 if ( $f_all_projects ) {
87 $t_project_id = 0;
90 $t_filter_string = filter_db_get_filter( gpc_get_cookie( config_get( 'view_all_cookie' ), '' ) );
92 $t_new_row_id = filter_db_set_for_current_user($t_project_id, $f_is_public,
93 $f_query_name, $t_filter_string);
95 form_security_purge( 'query_store' );
97 if ( $t_new_row_id == -1 ) {
98 $t_query_redirect_url = $t_query_redirect_url . '?error_msg='
99 . urlencode( lang_get( 'query_store_error' ) );
100 print_header_redirect( $t_query_redirect_url );
101 } else {
102 print_header_redirect( 'view_all_bug_page.php' );