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 * Columns include file
19 * @package MantisBT
20 * @copyright Copyright 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
21 * @copyright Copyright 2002  MantisBT Team - mantisbt-dev@lists.sourceforge.net
22 * @link http://www.mantisbt.org
23 *
24 * @uses access_api.php
25 * @uses authentication_api.php
26 * @uses columns_api.php
27 * @uses constant_inc.php
28 * @uses current_user_api.php
29 * @uses file_api.php
30 * @uses form_api.php
31 * @uses helper_api.php
32 * @uses html_api.php
33 * @uses lang_api.php
34 * @uses print_api.php
35 */
36
37if( !defined( 'MANAGE_COLUMNS_INC_ALLOW' ) ) {
38	return;
39}
40
41require_api( 'access_api.php' );
42require_api( 'authentication_api.php' );
43require_api( 'columns_api.php' );
44require_api( 'constant_inc.php' );
45require_api( 'current_user_api.php' );
46require_api( 'file_api.php' );
47require_api( 'form_api.php' );
48require_api( 'helper_api.php' );
49require_api( 'html_api.php' );
50require_api( 'lang_api.php' );
51require_api( 'print_api.php' );
52
53$t_manage_page = defined( 'MANAGE_COLUMNS' );
54$t_account_page = defined( 'ACCOUNT_COLUMNS' );
55
56$t_project_id = helper_get_current_project();
57
58# Calculate the user id to set the configuration for.
59if( $t_manage_page ) {
60	$t_user_id = NO_USER;
61} else {
62	$t_user_id = auth_get_current_user_id();
63}
64
65$t_columns = columns_get_all( $t_project_id );
66$t_all = implode( ', ', $t_columns );
67
68$t_columns = helper_get_columns_to_view( COLUMNS_TARGET_CSV_PAGE, false, $t_user_id );
69$t_csv = implode( ', ', $t_columns );
70
71$t_columns = helper_get_columns_to_view( COLUMNS_TARGET_VIEW_PAGE, false, $t_user_id );
72$t_view_issues = implode( ', ', $t_columns );
73
74$t_columns = helper_get_columns_to_view( COLUMNS_TARGET_PRINT_PAGE, false, $t_user_id );
75$t_print_issues = implode( ', ', $t_columns );
76
77$t_columns = helper_get_columns_to_view( COLUMNS_TARGET_EXCEL_PAGE, false, $t_user_id );
78$t_excel = implode( ', ', $t_columns );
79
80if( $t_account_page ) {
81	print_account_menu( 'account_manage_columns_page.php' );
82}
83?>
84
85<div class="col-md-12 col-xs-12">
86<div class="space-10"></div>
87
88<div class="widget-box widget-color-blue2">
89<div class="widget-header widget-header-small">
90	<h4 class="widget-title lighter">
91		<?php print_icon( 'fa-columns', 'ace-icon' ); ?>
92		<?php echo lang_get( 'manage_columns_config' ) ?>
93	</h4>
94</div>
95
96<div id="manage-columns-div" class="form-container">
97	<form id="manage-columns-form" method="post" action="manage_config_columns_set.php">
98
99<div class="widget-body">
100<div class="widget-main no-padding">
101	<div class="table-responsive">
102		<table class="table table-bordered table-condensed table-striped">
103		<fieldset>
104			<?php echo form_security_field( 'manage_config_columns_set' ) ?>
105			<input type="hidden" name="project_id" value="<?php echo $t_project_id ?>" />
106			<input type="hidden" name="form_page" value="<?php echo $t_account_page ? 'account' : 'manage'; ?>" />
107			<tr>
108				<td class="category">
109					<?php echo lang_get( 'all_columns_title' )?>
110				</td>
111				<td>
112					<?php # Newline after opening textarea tag is intentional, see #25839 ?>
113					<textarea class="form-control"  id="all-columns" <?php echo helper_get_tab_index() ?> name="all_columns" readonly="readonly" cols="80" rows="5">
114<?php echo $t_all ?>
115</textarea>
116				</td>
117			</tr>
118			<tr>
119				<td class="category">
120					<?php echo lang_get( 'view_issues_columns_title' )?>
121				</td>
122				<td>
123					<?php # Newline after opening textarea tag is intentional, see #25839 ?>
124					<textarea class="form-control" id="view-issues-columns" <?php echo helper_get_tab_index() ?> name="view_issues_columns" cols="80" rows="5">
125<?php echo $t_view_issues ?>
126</textarea>
127				</td>
128			</tr>
129			<tr>
130				<td class="category">
131					<?php echo lang_get( 'print_issues_columns_title' )?>
132				</td>
133				<td>
134					<?php # Newline after opening textarea tag is intentional, see #25839 ?>
135					<textarea class="form-control" id="print-issues-columns" <?php echo helper_get_tab_index() ?> name="print_issues_columns" cols="80" rows="5">
136<?php echo $t_print_issues ?>
137</textarea>
138				</td>
139			</tr>
140			<tr>
141				<td class="category">
142					<?php echo lang_get( 'csv_columns_title' )?>
143				</td>
144				<td>
145					<?php # Newline after opening textarea tag is intentional, see #25839 ?>
146					<textarea class="form-control" id="csv-columns" <?php echo helper_get_tab_index() ?> name="csv_columns" cols="80" rows="5">
147<?php echo $t_csv ?>
148</textarea>
149				</td>
150			</tr>
151			<tr>
152				<td class="category">
153					<?php echo lang_get( 'excel_columns_title' )?>
154				</td>
155				<td>
156					<textarea class="form-control" id="excel-columns" <?php echo helper_get_tab_index() ?> name="excel_columns" cols="80" rows="5">
157<?php echo $t_excel ?>
158</textarea>
159				</td>
160			</tr>
161		</fieldset>
162		</table>
163	</div>
164	</div>
165	<div class="widget-toolbox padding-8 clearfix">
166		<span class="required pull-right"> * <?php echo lang_get( 'required' ); ?></span>
167			<?php
168			if( $t_account_page ) {
169				if( $t_project_id == ALL_PROJECTS ) { ?>
170					<input <?php echo helper_get_tab_index() ?> type="submit" <?php echo helper_get_tab_index() ?> class="btn btn-primary btn-sm btn-white btn-round" name="update_columns_as_my_default" value="<?php echo lang_get( 'update_columns_as_my_default' ) ?>" /><?php
171				} else { ?>
172					<input <?php echo helper_get_tab_index() ?> type="submit" <?php echo helper_get_tab_index() ?> class="btn btn-primary btn-sm btn-white btn-round" name="update_columns_for_current_project" value="<?php echo lang_get( 'update_columns_for_current_project' ) ?>" /><?php
173
174				}
175			}
176
177			# All Projects: only if admin can setup global default columns.
178			# Specific Project: can set columns for that.  Switch to All Projects to set for all projects.
179			if( $t_manage_page ) { ?>
180				<?php
181				if( $t_project_id != ALL_PROJECTS ) { ?>
182					<input <?php echo helper_get_tab_index() ?> type="submit" class="btn btn-primary btn-sm btn-white btn-round" name="update_columns_as_global_default" value="<?php echo lang_get( 'update_columns_for_current_project' ) ?>" /><?php
183				} else if( current_user_is_administrator() ) { ?>
184					<input <?php echo helper_get_tab_index() ?> type="submit" class="btn btn-primary btn-sm btn-white btn-round" name="update_columns_as_global_default" value="<?php echo lang_get( 'update_columns_as_global_default' ) ?>" /><?php
185				} ?>
186				<?php
187			} ?>
188	</div>
189	</div>
190	</div>
191	</form>
192</div>
193
194<div class="space-10"></div>
195
196<div id="manage-columns-copy-div" class="form-container">
197	<form id="manage-columns-copy-form" method="post" action="manage_columns_copy.php">
198		<fieldset>
199			<?php echo form_security_field( 'manage_columns_copy' ) ?>
200			<input type="hidden" name="project_id" value="<?php echo $t_project_id ?>" />
201			<input type="hidden" name="manage_page" value="<?php echo $t_manage_page ?>" />
202
203			<select name="other_project_id" class="input-sm">
204				<?php print_project_option_list( null, true, $t_project_id ); ?>
205			</select>
206
207			<?php # Skip "Copy From" if the current project is ALL PROJECTS, the current page is management page, and the user is not administrator
208			if( !$t_manage_page || ( $t_project_id != ALL_PROJECTS ) || current_user_is_administrator() ) { ?>
209			<input type="submit" name="copy_from" class="btn btn-primary btn-sm btn-white btn-round" value="<?php echo lang_get( 'copy_columns_from' ) ?>" /><?php
210			} ?>
211			<input type="submit" name="copy_to" class="btn btn-primary btn-sm btn-white btn-round" value="<?php echo lang_get( 'copy_columns_to' ) ?>" />
212		</fieldset>
213	</form>
214</div>
215
216<?php
217if( $t_account_page ) {
218?>
219<div class="space-10"></div>
220<div class="form-container">
221	<form method="post" action="manage_config_columns_reset.php">
222		<fieldset>
223			<?php echo form_security_field( 'manage_config_columns_reset' ) ?>
224			<input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( 'reset_columns_configuration' ) ?>" />
225		</fieldset>
226	</form>
227</div>
228<?php
229}
230echo '</div>';
231