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
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once '../env.inc.php';
26 require_once $gfcommon.'include/pre.php';
27 require_once $gfcommon.'include/account.php';
28 require_once $gfwww.'admin/admin_utils.php';
29 require_once $gfwww.'include/role_utils.php';
31 session_require_global_perm('forge_admin');
33 $unix_status2str = array(
34 'N'=>_('No Unix account (N)'),
36 'S'=>_('Suspended (S)'),
40 $user_id = getIntFromRequest('user_id');
41 $u =& user_get_object($user_id);
42 if (!$u || !is_object($u)) {
43 exit_error(_('Could Not Get User'),'admin');
44 } elseif ($u->isError()) {
45 exit_error($u->getErrorMessage(),'admin');
48 if (getStringFromRequest('delete_user') != '') {
49 if (getStringFromRequest('confirm_delete') == '1') {
51 if (!$u->delete(true)) {
52 exit_error( _('Could Not Complete Operation: ').$u->getErrorMessage(),'admin');
54 $feedback = _('Deleted (D)').'<br />';
57 $error_msg = _('Please check the confirmation box if you really want to delete this user.');
59 } elseif (getStringFromRequest('action') == "update_user" && getStringFromRequest('delete_user') == '') {
60 $email = getStringFromRequest('email');
61 $shell = getStringFromRequest('shell');
62 $status = getStringFromRequest('status');
63 $addToProjectArray =getStringFromRequest('group_id_add_member');
66 if (!$u->setEmail($email)
67 || (forge_get_config('use_shell') && !$u->setShell($shell))
68 || !$u->setStatus($status)) {
69 exit_error( _('Could Not Complete Operation: ').$u->getErrorMessage(),'admin');
72 if ($u->getUnixStatus() != 'N') {
73 $u->setUnixStatus($status);
75 if (count($u->getGroups())>0 && $u->isActive()) {
76 $u->setUnixStatus('A');
78 // make sure that user doesn't have LDAP entry
79 $u->setUnixStatus('N');
83 if (is_array($addToProjectArray)) {
84 foreach($addToProjectArray as $project_id_to_add) {
85 $feedbackMembership = '';
86 $error_msgMembership = '';
87 $projectRoleid = getIntFromRequest('role_id-'.$project_id_to_add);
88 $projectObjectAction = group_get_object($project_id_to_add);
89 if (!$projectObjectAction->addUser((int)$u->getID(), $projectRoleid)) {
90 echo $projectObjectAction->getErrorMessage().$u->getID();
91 $error_msgMembership .= $projectObjectAction->getErrorMessage().'<br/>';
93 $feedbackMembership .= _("Added Successfully to project ").$projectObjectAction->getPublicName().'<br/>';
94 //if the user have requested to join this group
95 //we should remove him from the request list
96 //since it has already been added
97 $gjr = new GroupJoinRequest($projectObjectAction, $u->getID());
98 if ($gjr || is_object($gjr) || !$gjr->isError()) {
106 $error_msg = $u->getErrorMessage();
107 if (isset($error_msgMembership) && sizeof($error_msgMembership))
108 $error_msg .= '<br/>'.$error_msgMembership;
110 $feedback = _('Updated');
111 if (isset($feedbackMembership) && sizeof($feedbackMembership))
112 $feedback .= '<br/>'.$feedbackMembership;
117 $title = _('Site Admin: User Info');
118 site_admin_header(array('title'=>$title));
121 <h2><?php echo _('Account Information'); ?></h2>
123 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
124 <input type="hidden" name="action" value="update_user" />
125 <input type="hidden" name="user_id" value="<?php print $user_id; ?>" />
130 <?php echo _('User Id:'); ?>
133 <?php echo $u->getID(); ?>
139 <?php echo _('User name:'); ?>
142 <?php echo $u->getUnixName(); ?>
148 <?php echo _('Real name') . _(':'); ?>
151 <?php echo $u->getRealName(); ?>
157 <?php echo _('Web account status') . _(':'); ?>
161 if ($u->getStatus() == 'D') {
162 $status_letter = array('P','A','S','D');
163 $status_text = array(_('Pending (P)'),
167 } elseif ($u->getStatus() == 'P') {
168 $status_letter = array('P','A','S');
169 $status_text = array(_('Pending (P)'),
173 $status_letter = array('A','S');
174 $status_text = array(_('Active (A)'),
177 echo html_build_select_box_from_arrays(
178 $status_letter, $status_text,'status', $u->getStatus(), false);
184 if (forge_get_config('use_shell')) {
188 <?php echo _('Unix Account Status'); ?>:
191 <?php echo $unix_status2str[$u->getUnixStatus()]; ?>
197 <label for="unix-shell"><?php echo _('Unix Shell:'); ?></label>
200 <select id="unix-shell" name="shell">
201 <?php account_shellselects($u->getShell()); ?>
206 } // end of sys_use_shell conditional
211 <label for="email"><?php echo _('Email')._(':'); ?></label>
214 <input id="email" type="text" name="email" value="<?php echo $u->getEmail(); ?>" size="40" maxlength="255" />
220 <?php echo _('Current confirm hash:'); ?>
223 <?php echo $u->getConfirmHash(); ?>
226 <?php if ($u->getStatus() != 'D') { ?>
229 <input id="confirm-delete" type="checkbox" name="confirm_delete" value="1" />
230 <label for="confirm-delete"><?php echo _('I want to delete this user'); ?></label>
231 <input type="submit" name="delete_user" value="<?php echo _('Delete'); ?>" /><br />
236 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
238 <?php echo _('This pages allows to change only direct properties of user object. To edit properties pertinent to user within specific group, visit admin page of that group (below).'); ?>
242 if (forge_get_config('use_shell')) {
245 <?php echo _('Unix status updated mirroring web status, unless it has value \'No unix account (N)\''); ?>
248 } //end of sys_use_shell condition
253 <h2><?php echo _('Projects Membership'); ?></h2>
257 Iterate and show projects this user is in
259 $projects = $u->getGroups();
262 $title[] = _('Name');
263 $title[] = _('Unix name');
264 $title[] = _('Operations');
267 $userProjectsIdArray = array();
268 foreach ($projects as $p) {
270 echo $GLOBALS['HTML']->listTableTop($title);
273 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
274 <td>'.util_unconvert_htmlspecialchars(htmlspecialchars($p->getPublicName())).'</td>
275 <td>'.$p->getUnixName().'</td>
276 <td width="40%">'.util_make_link('/project/admin/?group_id='.$p->getID(),_('[Project Admin]')).'</td>
279 $userProjectsIdArray[] = $p->getID();
284 echo $GLOBALS['HTML']->listTableBottom();
286 echo '<p>'._('This user is not a member of any project.').'</p>';
289 echo '<h2>'._('Add membership to new projects').'</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', array('A'));
297 if ($fullListProjectsQueryResult) {
298 echo $GLOBALS['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 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
304 <td><input type="checkbox" name="group_id_add_member[]" value="'.$projectObject->getID().'">
305 <td>'.util_unconvert_htmlspecialchars(htmlspecialchars($projectObject->getPublicName())).'</td>
306 <td>'.$projectObject->getUnixName().'</td>
307 <td>'.util_make_link ('/project/admin/?group_id='.$projectObject->getID(),_('[Project Admin]')).'</td>
308 <td>'.role_box($projectObject->getID(),'role_id-'.$projectObject->getID()).'</td>
313 echo $GLOBALS['HTML']->listTableBottom();
315 echo '<br/><input type="submit" name="submit" value="'. _('Update').'" />';
318 site_admin_footer(array());
322 // c-file-style: "bsd"