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 * Project Page
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 category_api.php
29 * @uses config_api.php
30 * @uses constant_inc.php
31 * @uses form_api.php
32 * @uses gpc_api.php
33 * @uses helper_api.php
34 * @uses html_api.php
35 * @uses icon_api.php
36 * @uses lang_api.php
37 * @uses print_api.php
38 * @uses project_api.php
39 * @uses project_hierarchy_api.php
40 * @uses string_api.php
41 * @uses user_api.php
42 * @uses utility_api.php
43 */
44
45require_once( 'core.php' );
46require_api( 'access_api.php' );
47require_api( 'authentication_api.php' );
48require_api( 'category_api.php' );
49require_api( 'config_api.php' );
50require_api( 'constant_inc.php' );
51require_api( 'form_api.php' );
52require_api( 'gpc_api.php' );
53require_api( 'helper_api.php' );
54require_api( 'html_api.php' );
55require_api( 'icon_api.php' );
56require_api( 'lang_api.php' );
57require_api( 'print_api.php' );
58require_api( 'project_api.php' );
59require_api( 'project_hierarchy_api.php' );
60require_api( 'string_api.php' );
61require_api( 'user_api.php' );
62require_api( 'utility_api.php' );
63
64auth_reauthenticate();
65
66$f_sort	= gpc_get_string( 'sort', 'name' );
67$f_dir	= gpc_get_string( 'dir', 'ASC' );
68
69if( 'ASC' == $f_dir ) {
70	$t_direction = ASCENDING;
71} else {
72	$t_direction = DESCENDING;
73}
74
75layout_page_header( lang_get( 'manage_projects_link' ) );
76
77layout_page_begin( 'manage_overview_page.php' );
78
79print_manage_menu( 'manage_proj_page.php' );
80
81# Project Menu Form BEGIN
82?>
83
84<div class="col-md-12 col-xs-12">
85    <div class="space-10"></div>
86	<div class="widget-box widget-color-blue2">
87	<div class="widget-header widget-header-small">
88		<h4 class="widget-title lighter">
89			<?php print_icon( 'fa-puzzle-piece', 'ace-icon' ); ?>
90			<?php echo lang_get( 'projects_title' ) ?>
91		</h4>
92	</div>
93	<div class="widget-body">
94	<div class="widget-main no-padding">
95	<div class="widget-toolbox padding-8 clearfix">
96		<?php
97		# Check the user's global access level before allowing project creation
98		if( access_has_global_level ( config_get( 'create_project_threshold' ) ) ) {
99			print_form_button( 'manage_proj_create_page.php', lang_get( 'create_new_project_link' ), null, null, 'btn btn-primary btn-white btn-round' );
100		} ?>
101	</div>
102	<div class="table-responsive">
103	<table class="table table-striped table-bordered table-condensed table-hover">
104		<thead>
105			<tr>
106				<th><?php
107					print_manage_project_sort_link( 'manage_proj_page.php', lang_get( 'name' ), 'name', $t_direction, $f_sort );
108					print_sort_icon( $t_direction, $f_sort, 'name' ); ?>
109				</th>
110				<th><?php
111					print_manage_project_sort_link( 'manage_proj_page.php', lang_get( 'status' ), 'status', $t_direction, $f_sort );
112					print_sort_icon( $t_direction, $f_sort, 'status' ); ?>
113				</th>
114				<th><?php
115					print_manage_project_sort_link( 'manage_proj_page.php', lang_get( 'enabled' ), 'enabled', $t_direction, $f_sort );
116					print_sort_icon( $t_direction, $f_sort, 'enabled' ); ?>
117				</th>
118				<th><?php
119					print_manage_project_sort_link( 'manage_proj_page.php', lang_get( 'view_status' ), 'view_state', $t_direction, $f_sort );
120					print_sort_icon( $t_direction, $f_sort, 'view_state' ); ?>
121				</th>
122				<th><?php
123					print_manage_project_sort_link( 'manage_proj_page.php', lang_get( 'description' ), 'description', $t_direction, $f_sort );
124					print_sort_icon( $t_direction, $f_sort, 'description' ); ?>
125				</th>
126			</tr>
127		</thead>
128
129		<tbody>
130<?php
131		$t_manage_project_threshold = config_get( 'manage_project_threshold' );
132		$t_projects = user_get_accessible_projects( auth_get_current_user_id(), true );
133		$t_full_projects = array();
134		foreach ( $t_projects as $t_project_id ) {
135			$t_full_projects[] = project_get_row( $t_project_id );
136		}
137		$t_projects = multi_sort( $t_full_projects, $f_sort, $t_direction );
138		$t_stack = array( $t_projects );
139
140		while( 0 < count( $t_stack ) ) {
141			$t_projects = array_shift( $t_stack );
142
143			if( 0 == count( $t_projects ) ) {
144				continue;
145			}
146
147			$t_project = array_shift( $t_projects );
148			$t_project_id = $t_project['id'];
149			$t_level      = count( $t_stack );
150
151			# only print row if user has project management privileges
152			if( access_has_project_level( $t_manage_project_threshold, $t_project_id, auth_get_current_user_id() ) ) { ?>
153			<tr>
154				<td>
155					<a href="manage_proj_edit_page.php?project_id=<?php echo $t_project['id'] ?>"><?php echo str_repeat( "&raquo; ", $t_level ) . string_display_line( $t_project['name'] ) ?></a>
156				</td>
157				<td><?php echo get_enum_element( 'project_status', $t_project['status'] ) ?></td>
158				<td class="center"><?php echo trans_bool( $t_project['enabled'] ) ?></td>
159				<td><?php echo get_enum_element( 'project_view_state', $t_project['view_state'] ) ?></td>
160				<td><?php echo string_display_links( $t_project['description'] ) ?></td>
161			</tr><?php
162			}
163			$t_subprojects = project_hierarchy_get_subprojects( $t_project_id, true );
164
165			if( 0 < count( $t_projects ) || 0 < count( $t_subprojects ) ) {
166				array_unshift( $t_stack, $t_projects );
167			}
168
169			if( 0 < count( $t_subprojects ) ) {
170				$t_full_projects = array();
171				foreach ( $t_subprojects as $t_project_id ) {
172					$t_full_projects[] = project_get_row( $t_project_id );
173				}
174				$t_subprojects = multi_sort( $t_full_projects, $f_sort, $t_direction );
175				array_unshift( $t_stack, $t_subprojects );
176			}
177		} ?>
178		</tbody>
179	</table>
180</div>
181	</div>
182	</div>
183	</div>
184
185	<div class="space-10"></div>
186
187	<div id="categories" class="form-container">
188
189	<div class="widget-box widget-color-blue2">
190	<div class="widget-header widget-header-small">
191		<h4 class="widget-title lighter">
192			<?php print_icon( 'fa-sitemap', 'ace-icon' ); ?>
193			<?php echo lang_get( 'global_categories' ) ?>
194		</h4>
195	</div>
196	<div class="widget-body">
197		<div class="widget-main no-padding">
198		<div class="table-responsive">
199		<table class="table table-striped table-bordered table-condensed table-hover">
200<?php
201		$t_categories = category_get_all_rows( ALL_PROJECTS );
202		$t_can_update_global_cat = access_has_global_level( config_get( 'manage_site_threshold' ) );
203
204		if( count( $t_categories ) > 0 ) {
205?>
206		<thead>
207			<tr>
208				<td><?php echo lang_get( 'category' ) ?></td>
209				<td><?php echo lang_get( 'assign_to' ) ?></td>
210				<?php if( $t_can_update_global_cat ) { ?>
211				<td class="center"><?php echo lang_get( 'actions' ) ?></td>
212				<?php } ?>
213			</tr>
214		</thead>
215
216		<tbody>
217<?php
218			foreach( $t_categories as $t_category ) {
219				$t_id = $t_category['id'];
220?>
221			<tr>
222				<td><?php echo string_display_line( category_full_name( $t_id, false ) )  ?></td>
223				<td><?php echo prepare_user_name( $t_category['user_id'] ) ?></td>
224				<?php if( $t_can_update_global_cat ) { ?>
225				<td class="center">
226<?php
227					$t_id = urlencode( $t_id );
228					$t_project_id = urlencode( ALL_PROJECTS );
229					echo '<div class="btn-group inline">';
230					echo '<div class="pull-left">';
231					print_form_button( "manage_proj_cat_edit_page.php?id=$t_id&project_id=$t_project_id", lang_get( 'edit' ) );
232					echo '</div>';
233					echo '<div class="pull-left">';
234					print_form_button( "manage_proj_cat_delete.php?id=$t_id&project_id=$t_project_id", lang_get( 'delete' ) );
235					echo '</div>';
236?>
237				</td>
238			<?php } ?>
239			</tr>
240<?php
241			} # end for loop
242?>
243		</tbody>
244<?php
245		} # end if
246?>
247	</table>
248	</div>
249	</div>
250
251<?php if( $t_can_update_global_cat ) { ?>
252	<form method="post" action="manage_proj_cat_add.php" class="form-inline">
253		<div class="widget-toolbox padding-8 clearfix">
254			<?php echo form_security_field( 'manage_proj_cat_add' ) ?>
255			<input type="hidden" name="project_id" value="<?php echo ALL_PROJECTS ?>" />
256			<input type="text" name="name" class="input-sm" size="32" maxlength="128" />
257			<input type="submit" class="btn btn-primary btn-sm btn-white btn-round" value="<?php echo lang_get( 'add_category_button' ) ?>" />
258			<input type="submit" name="add_and_edit_category" class="btn btn-primary btn-sm btn-white btn-round" value="<?php echo lang_get( 'add_and_edit_category_button' ) ?>" />
259		</div>
260	</form>
261<?php } ?>
262</div>
263</div>
264</div>
265<?php
266echo '</div>';
267layout_page_end();
268