3 * Site Admin user properties editing page
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
7 * Copyright 2011, Franck Villaume - Capgemini
8 * Copyright 2014, Franck Villaume - TrivialDev
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once '../env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfcommon.'include/account.php';
29 require_once $gfwww.'admin/admin_utils.php';
30 require_once $gfwww.'include/role_utils.php';
34 session_require_global_perm('forge_admin');
36 $unix_status2str = array(
37 'N'=>_('No Unix account (N)'),
39 'S'=>_('Suspended (S)'),
43 $user_id = getIntFromRequest('user_id');
44 $u = user_get_object($user_id);
45 if (!$u || !is_object($u)) {
46 exit_error(_('Could Not Get User'),'admin');
47 } elseif ($u->isError()) {
48 exit_error($u->getErrorMessage(),'admin');
51 if (getStringFromRequest('delete_user') != '') {
52 if (getStringFromRequest('confirm_delete') == '1') {
54 if (!$u->delete(true)) {
55 exit_error( _('Could Not Complete Operation: ').$u->getErrorMessage(),'admin');
57 $feedback = _('Deleted (D)').'<br />';
60 $error_msg = _('Please check the confirmation box if you really want to delete this user.');
62 } elseif (getStringFromRequest('action') == "update_user" && getStringFromRequest('delete_user') == '') {
63 $email = getStringFromRequest('email');
64 $shell = getStringFromRequest('shell');
65 $status = getStringFromRequest('status');
66 $addToProjectArray =getStringFromRequest('group_id_add_member');
69 if (!$u->setEmail($email)
70 || (forge_get_config('use_shell') && !$u->setShell($shell))
71 || !$u->setStatus($status)) {
72 exit_error( _('Could Not Complete Operation: ').$u->getErrorMessage(),'admin');
75 if (is_array($addToProjectArray)) {
76 foreach($addToProjectArray as $project_id_to_add) {
77 $feedbackMembership = '';
78 $error_msgMembership = '';
79 $projectRoleid = getIntFromRequest('role_id-'.$project_id_to_add);
80 $projectObjectAction = group_get_object($project_id_to_add);
81 if (!$projectObjectAction->addUser((int)$u->getID(), $projectRoleid)) {
82 $error_msgMembership .= $projectObjectAction->getErrorMessage().'<br/>';
84 $feedbackMembership .= _("Added Successfully to project ").$projectObjectAction->getPublicName().'<br/>';
85 //if the user have requested to join this group
86 //we should remove him from the request list
87 //since it has already been added
88 $gjr = new GroupJoinRequest($projectObjectAction, $u->getID());
89 if ($gjr || is_object($gjr) || !$gjr->isError()) {
96 if ($u->getUnixStatus() == 'A') {
97 $u->setUnixStatus($status);
99 if (count($u->getGroups())>0 && $u->isActive()) {
100 $u->setUnixStatus('A');
102 // make sure that user doesn't have LDAP entry
103 $u->setUnixStatus('N');
108 $error_msg = $u->getErrorMessage();
109 if (isset($error_msgMembership) && sizeof($error_msgMembership))
110 $error_msg .= '<br/>'.$error_msgMembership;
112 $feedback = _('Updated');
113 if (isset($feedbackMembership) && sizeof($feedbackMembership))
114 $feedback .= '<br/>'.$feedbackMembership;
119 $title = _('Site Admin')._(': ')._('User Info');
120 site_admin_header(array('title'=>$title));
123 <h2><?php echo _('Account Information'); ?></h2>
126 echo $HTML->openForm(array('method' => 'post', 'action' => '/admin/useredit.php')); ?>
127 <input type="hidden" name="action" value="update_user" />
128 <input type="hidden" name="user_id" value="<?php print $user_id; ?>" />
130 <table class="infotable">
133 <?php echo _('User Id')._(':'); ?>
136 <?php echo $u->getID(); ?>
142 <?php echo _('User Name')._(':'); ?>
145 <?php echo $u->getUnixName(); ?>
151 <?php echo _('Real Name')._(':'); ?>
154 <?php echo $u->getRealName(); ?>
160 <?php echo _('Web account status') . _(':'); ?>
164 if ($u->getStatus() == 'D') {
165 $status_letter = array('P','A','S','D');
166 $status_text = array(_('Pending (P)'),
170 } elseif ($u->getStatus() == 'P') {
171 $status_letter = array('P','A','S');
172 $status_text = array(_('Pending (P)'),
176 $status_letter = array('A','S');
177 $status_text = array(_('Active (A)'),
180 echo html_build_select_box_from_arrays(
181 $status_letter, $status_text,'status', $u->getStatus(), false);
187 if (forge_get_config('use_shell')) {
191 <?php echo _('Unix Account Status'); ?>:
194 <?php echo $unix_status2str[$u->getUnixStatus()]; ?>
200 <label for="unix-shell"><?php echo _('Unix Shell:'); ?></label>
203 <select id="unix-shell" name="shell">
204 <?php account_shellselects($u->getShell()); ?>
209 } // end of sys_use_shell conditional
214 <label for="email"><?php echo _('Email')._(':'); ?></label>
217 <input id="email" type="text" name="email" value="<?php echo $u->getEmail(); ?>" size="40" maxlength="255" />
223 <?php echo _('Current confirm hash:'); ?>
226 <?php echo $u->getConfirmHash(); ?>
229 <?php if ($u->getStatus() != 'D') { ?>
232 <input id="confirm-delete" type="checkbox" name="confirm_delete" value="1" />
233 <label for="confirm-delete"><?php echo _('I want to delete this user'); ?></label>
234 <input type="submit" name="delete_user" value="<?php echo _('Delete'); ?>" /><br />
239 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
241 <?php echo _('This pages allows to change only direct properties of user object. To edit properties pertinent to user within specific project, visit admin page of that project (below).'); ?>
245 if (forge_get_config('use_shell')) {
248 <?php echo _('Unix status updated mirroring web status, unless it has value “No Unix account (N)”'); ?>
251 } //end of sys_use_shell condition
256 <h2><?php echo _('Projects Membership'); ?></h2>
260 Iterate and show projects this user is in
262 $projects = $u->getGroups();
265 $title[] = _('Name');
266 $title[] = _('Unix Name');
267 $title[] = _('Operations');
270 $userProjectsIdArray = array();
271 foreach ($projects as $p) {
273 echo $HTML->listTableTop($title);
276 $cells[][] = util_unconvert_htmlspecialchars(htmlspecialchars($p->getPublicName()));
277 $cells[][] = $p->getUnixName();
278 $cells[] = array(util_make_link('/project/admin/?group_id='.$p->getID(),'['._('Project Admin').']'), 'width' => '40%');
279 echo $HTML->multiTableRow(array(), $cells);
280 $userProjectsIdArray[] = $p->getID();
284 echo $HTML->listTableBottom();
286 echo '<p>'._('This user is not a member of any project.').'</p>';
289 echo '<h2>'._('Add membership to new projects').' '._('(100 shown)').'</h2>';
290 $addToNewProjectsTableTitle = array();
291 $addToNewProjectsTableTitle[] = '';
292 $addToNewProjectsTableTitle[] = _('Name');
293 $addToNewProjectsTableTitle[] = _('Unix Name');
294 $addToNewProjectsTableTitle[] = _('Operations');
295 $addToNewProjectsTableTitle[] = _('Select role');
296 $fullListProjectsQueryResult = db_query_params('SELECT group_id from groups where status = $1 and is_template = 0 LIMIT 100', array('A'));
297 if ($fullListProjectsQueryResult) {
298 echo $HTML->listTableTop($addToNewProjectsTableTitle);
299 while ($projectQueryResult = db_fetch_array($fullListProjectsQueryResult)) {
300 $projectObject = group_get_object($projectQueryResult['group_id']);
301 if (!in_array($projectObject->getID(), $userProjectsIdArray)) {
303 $cells[][] = '<input type="checkbox" name="group_id_add_member[]" value="'.$projectObject->getID().'">';
304 $cells[][] = util_unconvert_htmlspecialchars(htmlspecialchars($projectObject->getPublicName()));
305 $cells[][] = $projectObject->getUnixName();
306 $cells[][] = util_make_link('/project/admin/?group_id='.$projectObject->getID(),'['._('Project Admin').']');
307 $cells[][] = role_box($projectObject->getID(),'role_id-'.$projectObject->getID());
308 echo $HTML->multiTableRow(array(), $cells);
311 echo $HTML->listTableBottom();
313 echo '<br/><input type="submit" name="submit" value="'. _('Update').'" />';
314 echo $HTML->closeForm();
320 // c-file-style: "bsd"