Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / manage_columns_copy.php
blobcb43cdab373b918e1bad1fbe2a8bc9a880dc5464
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 access_api.php
25 * @uses authentication_api.php
26 * @uses columns_api.php
27 * @uses config_api.php
28 * @uses constant_inc.php
29 * @uses current_user_api.php
30 * @uses form_api.php
31 * @uses gpc_api.php
32 * @uses print_api.php
35 require_once( 'core.php' );
36 require_api( 'access_api.php' );
37 require_api( 'authentication_api.php' );
38 require_api( 'columns_api.php' );
39 require_api( 'config_api.php' );
40 require_api( 'constant_inc.php' );
41 require_api( 'current_user_api.php' );
42 require_api( 'form_api.php' );
43 require_api( 'gpc_api.php' );
44 require_api( 'print_api.php' );
46 form_security_validate( 'manage_columns_copy' );
48 auth_reauthenticate();
50 $f_project_id = gpc_get_int( 'project_id' );
51 $f_other_project_id = gpc_get_int( 'other_project_id' );
52 $f_copy_from = gpc_get_bool( 'copy_from' );
53 $f_copy_to = gpc_get_bool( 'copy_to' );
54 $f_manage_page = gpc_get_bool( 'manage_page' );
56 if ( $f_copy_from ) {
57 $t_src_project_id = $f_other_project_id;
58 $t_dst_project_id = $f_project_id;
59 } else if ( $f_copy_to ) {
60 $t_src_project_id = $f_project_id;
61 $t_dst_project_id = $f_other_project_id;
62 } else {
63 trigger_error( ERROR_GENERIC, ERROR );
66 # only admins can set global defaults.for ALL_PROJECT
67 if ( $f_manage_page && $t_dst_project_id == ALL_PROJECTS && !current_user_is_administrator() ) {
68 access_denied();
71 # only MANAGERS can set global defaults.for a project
72 if ( $f_manage_page && $t_dst_project_id != ALL_PROJECTS ) {
73 access_ensure_project_level( MANAGER, $t_dst_project_id );
76 # user should only be able to set columns for a project that is accessible.
77 if ( $t_dst_project_id != ALL_PROJECTS ) {
78 access_ensure_project_level( VIEWER, $t_dst_project_id );
81 # Calculate the user id to set the configuration for.
82 if ( $f_manage_page ) {
83 $t_user_id = NO_USER;
84 } else {
85 $t_user_id = auth_get_current_user_id();
88 $t_all_columns = columns_get_all();
89 $t_default = null;
91 $t_view_issues_page_columns = config_get( 'view_issues_page_columns', $t_default, $t_user_id, $t_src_project_id );
92 $t_view_issues_page_columns = columns_remove_invalid( $t_view_issues_page_columns, $t_all_columns );
94 $t_print_issues_page_columns = config_get( 'print_issues_page_columns', $t_default, $t_user_id, $t_src_project_id );
95 $t_print_issues_page_columns = columns_remove_invalid( $t_print_issues_page_columns, $t_all_columns );
97 $t_csv_columns = config_get( 'csv_columns', $t_default, $t_user_id, $t_src_project_id );
98 $t_csv_columns = columns_remove_invalid( $t_csv_columns, $t_all_columns );
100 $t_excel_columns = config_get( 'excel_columns', $t_default, $t_user_id, $t_src_project_id );
101 $t_excel_columns = columns_remove_invalid( $t_excel_columns, $t_all_columns );
103 config_set( 'view_issues_page_columns', $t_view_issues_page_columns, $t_user_id, $t_dst_project_id );
104 config_set( 'print_issues_page_columns', $t_print_issues_page_columns, $t_user_id, $t_dst_project_id );
105 config_set( 'csv_columns', $t_csv_columns, $t_user_id, $t_dst_project_id );
106 config_set( 'excel_columns', $t_excel_columns, $t_user_id, $t_dst_project_id );
108 form_security_purge( 'manage_columns_copy' );
110 $t_redirect_url = $f_manage_page ? 'manage_config_columns_page.php' : 'account_manage_columns_page.php';
111 print_header_redirect( $t_redirect_url );