1<?php 2# MantisBT - A PHP based bugtracking system 3 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. 8# 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. 13# 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/>. 16 17/** 18 * Copy Columns between projects 19 * 20 * @package MantisBT 21 * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 22 * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net 23 * @link http://www.mantisbt.org 24 * 25 * @uses core.php 26 * @uses access_api.php 27 * @uses authentication_api.php 28 * @uses columns_api.php 29 * @uses config_api.php 30 * @uses constant_inc.php 31 * @uses current_user_api.php 32 * @uses form_api.php 33 * @uses gpc_api.php 34 * @uses print_api.php 35 */ 36 37require_once( 'core.php' ); 38require_api( 'access_api.php' ); 39require_api( 'authentication_api.php' ); 40require_api( 'columns_api.php' ); 41require_api( 'config_api.php' ); 42require_api( 'constant_inc.php' ); 43require_api( 'current_user_api.php' ); 44require_api( 'form_api.php' ); 45require_api( 'gpc_api.php' ); 46require_api( 'print_api.php' ); 47 48form_security_validate( 'manage_columns_copy' ); 49 50auth_reauthenticate(); 51 52$f_project_id = gpc_get_int( 'project_id' ); 53$f_other_project_id = gpc_get_int( 'other_project_id' ); 54$f_copy_from = gpc_get_bool( 'copy_from' ); 55$f_copy_to = gpc_get_bool( 'copy_to' ); 56$f_manage_page = gpc_get_bool( 'manage_page' ); 57 58if( $f_copy_from ) { 59 $t_src_project_id = $f_other_project_id; 60 $t_dst_project_id = $f_project_id; 61} else if( $f_copy_to ) { 62 $t_src_project_id = $f_project_id; 63 $t_dst_project_id = $f_other_project_id; 64} else { 65 trigger_error( ERROR_GENERIC, ERROR ); 66} 67 68# only admins can set global defaults.for ALL_PROJECT 69if( $f_manage_page && $t_dst_project_id == ALL_PROJECTS && !current_user_is_administrator() ) { 70 access_denied(); 71} 72 73# only MANAGERS can set global defaults.for a project 74if( $f_manage_page && $t_dst_project_id != ALL_PROJECTS ) { 75 access_ensure_project_level( MANAGER, $t_dst_project_id ); 76} 77 78# user should only be able to set columns for a project that is accessible. 79if( $t_dst_project_id != ALL_PROJECTS ) { 80 access_ensure_project_level( config_get( 'view_bug_threshold', null, null, $t_dst_project_id ), $t_dst_project_id ); 81} 82 83# Calculate the user id to set the configuration for. 84if( $f_manage_page ) { 85 $t_user_id = NO_USER; 86} else { 87 $t_user_id = auth_get_current_user_id(); 88} 89 90$t_all_columns = columns_get_all(); 91$t_default = null; 92 93$t_view_issues_page_columns = config_get( 'view_issues_page_columns', $t_default, $t_user_id, $t_src_project_id ); 94$t_view_issues_page_columns = columns_remove_invalid( $t_view_issues_page_columns, $t_all_columns ); 95 96$t_print_issues_page_columns = config_get( 'print_issues_page_columns', $t_default, $t_user_id, $t_src_project_id ); 97$t_print_issues_page_columns = columns_remove_invalid( $t_print_issues_page_columns, $t_all_columns ); 98 99$t_csv_columns = config_get( 'csv_columns', $t_default, $t_user_id, $t_src_project_id ); 100$t_csv_columns = columns_remove_invalid( $t_csv_columns, $t_all_columns ); 101 102$t_excel_columns = config_get( 'excel_columns', $t_default, $t_user_id, $t_src_project_id ); 103$t_excel_columns = columns_remove_invalid( $t_excel_columns, $t_all_columns ); 104 105config_set( 'view_issues_page_columns', $t_view_issues_page_columns, $t_user_id, $t_dst_project_id ); 106config_set( 'print_issues_page_columns', $t_print_issues_page_columns, $t_user_id, $t_dst_project_id ); 107config_set( 'csv_columns', $t_csv_columns, $t_user_id, $t_dst_project_id ); 108config_set( 'excel_columns', $t_excel_columns, $t_user_id, $t_dst_project_id ); 109 110form_security_purge( 'manage_columns_copy' ); 111 112$t_redirect_url = $f_manage_page ? 'manage_config_columns_page.php' : 'account_manage_columns_page.php'; 113print_header_redirect( $t_redirect_url ); 114