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 * View User Page
19 *
20 * @package MantisBT
21 * @copyright Copyright 2002  MantisBT Team - mantisbt-dev@lists.sourceforge.net
22 * @link http://www.mantisbt.org
23 *
24 * @uses core.php
25 * @uses access_api.php
26 * @uses authentication_api.php
27 * @uses config_api.php
28 * @uses constant_inc.php
29 * @uses error_api.php
30 * @uses gpc_api.php
31 * @uses helper_api.php
32 * @uses html_api.php
33 * @uses lang_api.php
34 * @uses print_api.php
35 * @uses string_api.php
36 * @uses user_api.php
37 * @uses utility_api.php
38 */
39
40require_once( 'core.php' );
41require_api( 'access_api.php' );
42require_api( 'authentication_api.php' );
43require_api( 'config_api.php' );
44require_api( 'constant_inc.php' );
45require_api( 'error_api.php' );
46require_api( 'gpc_api.php' );
47require_api( 'helper_api.php' );
48require_api( 'html_api.php' );
49require_api( 'lang_api.php' );
50require_api( 'print_api.php' );
51require_api( 'string_api.php' );
52require_api( 'user_api.php' );
53require_api( 'utility_api.php' );
54
55auth_ensure_user_authenticated();
56
57# extracts the user information for the currently logged in user
58# and prefixes it with u_
59$f_user_id = gpc_get_int( 'id', auth_get_current_user_id() );
60$t_row = user_get_row( $f_user_id );
61
62extract( $t_row, EXTR_PREFIX_ALL, 'u' );
63
64$t_can_manage = access_has_global_level( config_get( 'manage_user_threshold' ) ) &&
65	access_has_global_level( $u_access_level );
66
67$t_can_see_realname = $t_can_manage || user_show_realname() ||
68    access_has_project_level( config_get( 'show_user_realname_threshold' ) );
69$t_can_see_email = $t_can_manage || access_has_project_level( config_get( 'show_user_email_threshold' ) );
70$t_can_impersonate = auth_can_impersonate( $f_user_id );
71
72# In case we're using LDAP to get the email address... this will pull out
73#  that version instead of the one in the DB
74$u_email = user_get_email( $u_id );
75$u_realname = user_get_realname( $u_id );
76
77$t_date_format = config_get( 'normal_date_format' );
78
79layout_page_header();
80
81layout_page_begin();
82$t_timeline_view_threshold_access = access_has_project_level( config_get( 'timeline_view_threshold' ) );
83$t_timeline_view_class = ( $t_timeline_view_threshold_access ) ? "col-md-7" : "col-md-12";
84?>
85<div class="<?php echo $t_timeline_view_class ?> col-xs-12">
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-user', 'ace-icon' ); ?>
90		<?php echo lang_get('view_account_title') ?>
91	</h4>
92</div>
93<div class="widget-body">
94<div class="widget-main no-padding">
95<div class="table-responsive">
96<table class="table table-bordered table-condensed table-striped">
97	<fieldset>
98	<tr>
99		<th class="category">
100			<?php echo lang_get( 'username' ) ?>
101		</th>
102		<td>
103			<?php echo string_display_line( $u_username ) ?>
104		</td>
105	</tr>
106	<?php
107		if( $t_can_see_realname ) { ?>
108			<tr>
109				<th class="category">
110					<?php echo lang_get( 'realname' ) ?>
111				</th>
112				<td>
113					<?php echo string_display_line( $u_realname ); ?>
114				</td>
115			</tr>
116	<?php } ?>
117	<?php
118		if( $t_can_see_email ) { ?>
119			<tr>
120				<th class="category">
121					<?php echo lang_get( 'email' ) ?>
122				</th>
123				<td>
124				    <?php
125						if( !is_blank( $u_email ) ) {
126							print_email_link( $u_email, $u_email );
127						}
128					?>
129				</td>
130			</tr>
131	<?php } ?>
132	<?php
133		if( $t_can_manage ) { ?>
134			<tr>
135				<th class="category">
136					<?php echo lang_get( 'access_level' ) ?>
137				</th>
138				<td>
139					<?php echo string_display_line( get_enum_element( 'access_levels', $u_access_level ) ); ?>
140				</td>
141			</tr>
142			<tr>
143				<th class="category">
144					<?php echo lang_get( 'enabled' ) ?>
145				</th>
146				<td>
147					<?php echo $u_enabled ? lang_get( 'yes' ) : lang_get( 'no' ); ?>
148				</td>
149			</tr>
150			<tr>
151				<th class="category">
152					<?php echo lang_get( 'protected' ) ?>
153				</th>
154				<td>
155					<?php echo $u_protected ? lang_get( 'yes' ) : lang_get( 'no' ); ?>
156				</td>
157			</tr>
158			<tr>
159				<th class="category">
160					<?php echo lang_get( 'date_created' ) ?>
161				</th>
162				<td>
163					<?php echo date( $t_date_format, $u_date_created ); ?>
164				</td>
165			</tr>
166			<tr>
167				<th class="category">
168					<?php echo lang_get( 'last_visit' ) ?>
169				</th>
170				<td>
171					<?php echo date( $t_date_format, $u_last_visit ); ?>
172				</td>
173			</tr>
174	<?php } ?>
175	</fieldset>
176</table>
177	</div>
178	</div>
179	<?php if( $t_can_manage || $t_can_impersonate ) { ?>
180	<div class="widget-toolbox padding-8 clearfix">
181		<?php if( $t_can_manage ) { ?>
182		<form id="manage-user-form" method="get" action="manage_user_edit_page.php" class="pull-left">
183			<fieldset>
184				<input type="hidden" name="user_id" value="<?php echo $f_user_id ?>" />
185				<input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( 'manage_user' ) ?>" /></span>
186			</fieldset>
187		</form>
188		<?php } ?>
189		<?php if( $t_can_impersonate ) { ?>
190		<form id="manage-user-impersonate-form" method="post" action="manage_user_impersonate.php" class="pull-right">
191			<fieldset>
192				<?php echo form_security_field( 'manage_user_impersonate' ) ?>
193				<input type="hidden" name="user_id" value="<?php echo $f_user_id ?>" />
194				<span><input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( 'impersonate_user_button' ) ?>" /></span>
195			</fieldset>
196		</form>
197		<?php } ?>
198	</div>
199	<?php } ?>
200</div>
201</div>
202</div>
203
204<?php
205if( $t_timeline_view_threshold_access ) {
206	# Build a filter to show all bugs in current projects
207	$g_timeline_filter = array();
208	$g_timeline_filter[FILTER_PROPERTY_HIDE_STATUS] = array( META_FILTER_NONE );
209	$g_timeline_filter = filter_ensure_valid_filter( $g_timeline_filter );
210	$g_timeline_user = $f_user_id;
211	?>
212	<div class="col-md-5 col-xs-12">
213		<?php include( $g_core_path . 'timeline_inc.php' ); ?>
214		<div class="space-10"></div>
215	</div>
216<?php } ?>
217
218<?php
219layout_page_end();
220