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') != '' && getStringFromRequest('confirm_delete') == '1') {
50 if (!$u->delete(true)) {
51 exit_error( _('Could Not Complete Operation: ').$u->getErrorMessage(),'admin');
53 $feedback = _('Deleted (D)').'<br />';
56 } elseif (getStringFromRequest('action') == "update_user" && getStringFromRequest('delete_user') == '') {
57 $email = getStringFromRequest('email');
58 $shell = getStringFromRequest('shell');
59 $status = getStringFromRequest('status');
60 $addToProjectArray =getStringFromRequest('group_id_add_member');
63 if (!$u->setEmail($email)
64 || (forge_get_config('use_shell') && !$u->setShell($shell))
65 || !$u->setStatus($status)) {
66 exit_error( _('Could Not Complete Operation: ').$u->getErrorMessage(),'admin');
69 if ($u->getUnixStatus() != 'N') {
70 $u->setUnixStatus($status);
72 if (count($u->getGroups())>0 && $u->isActive()) {
73 $u->setUnixStatus('A');
75 // make sure that user doesn't have LDAP entry
76 $u->setUnixStatus('N');
80 if (is_array($addToProjectArray)) {
81 foreach($addToProjectArray as $project_id_to_add) {
82 $feedbackMembership = '';
83 $error_msgMembership = '';
84 $projectRoleid = getIntFromRequest('role_id-'.$project_id_to_add);
85 $projectObjectAction = group_get_object($project_id_to_add);
86 if (!$projectObjectAction->addUser((int)$u->getID(), $projectRoleid)) {
87 echo $projectObjectAction->getErrorMessage().$u->getID();
88 $error_msgMembership .= $projectObjectAction->getErrorMessage().'<br/>';
90 $feedbackMembership .= _("Added Successfully to project ").$projectObjectAction->getPublicName().'<br/>';
91 //if the user have requested to join this group
92 //we should remove him from the request list
93 //since it has already been added
94 $gjr = new GroupJoinRequest($projectObjectAction, $u->getID());
95 if ($gjr || is_object($gjr) || !$gjr->isError()) {
103 $error_msg = $u->getErrorMessage();
104 if (isset($error_msgMembership) && sizeof($error_msgMembership))
105 $error_msg .= '<br/>'.$error_msgMembership;
107 $feedback = _('Updated');
108 if (isset($feedbackMembership) && sizeof($feedbackMembership))
109 $feedback .= '<br/>'.$feedbackMembership;
114 $title = _('Site Admin: User Info');
115 site_admin_header(array('title'=>$title));
118 <h2><?php echo _('Account Information'); ?><sup>1</sup></h2>
120 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
121 <input type="hidden" name="action" value="update_user" />
122 <input type="hidden" name="user_id" value="<?php print $user_id; ?>" />
127 <?php echo _('User Id:'); ?>
130 <?php echo $u->getID(); ?>
136 <?php echo _('User name:'); ?>
139 <?php echo $u->getUnixName(); ?>
145 <?php echo _('Real name'); ?>
148 <?php echo $u->getRealName(); ?>
154 <?php echo _('Web account status'); ?>
158 if ($u->getStatus() == 'D') {
159 $status_letter = array('P','A','S','D');
160 $status_text = array(_('Pending (P)'),
164 } else if ($u->getStatus() == 'P') {
165 $status_letter = array('P','A','S');
166 $status_text = array(_('Pending (P)'),
170 $status_letter = array('A','S');
171 $status_text = array(_('Active (A)'),
174 echo html_build_select_box_from_arrays(
175 $status_letter, $status_text,'status', $u->getStatus(), false);
183 if (forge_get_config('use_shell')) {
187 <?php echo _('Unix Account Status'); ?><sup>2</sup>:
190 <?php echo $unix_status2str[$u->getUnixStatus()]; ?>
196 <?php echo _('Unix Shell:'); ?>
199 <select name="shell">
200 <?php account_shellselects($u->getShell()); ?>
205 } // end of sys_use_shell conditionnal
210 <?php echo _('Email')._(':'); ?>
213 <input type="text" name="email" value="<?php echo $u->getEmail(); ?>" size="25" maxlength="255" />
219 <?php echo _('Current confirm hash:'); ?>
222 <?php echo $u->getConfirmHash(); ?>
225 <?php if ($u->getStatus() != 'D') { ?>
227 <td colspan="2"><input type="checkbox" name="confirm_delete" value="1" /><?php echo _('I want to delete this user'); ?>
228 <input type="submit" name="delete_user" value="<?php echo _('Delete'); ?>" /><br />
233 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
235 <sup>1</sup><?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).'); ?>
241 if (forge_get_config('use_shell')) {
244 <sup>2</sup><?php echo _('Unix status updated mirroring web status, unless it has value \'No unix account (N)\''); ?>
247 } //end of sys_use_shell condition
252 <h2><?php echo _('Projects Membership'); ?></h2>
256 Iterate and show projects this user is in
258 $projects = $u->getGroups();
261 $title[] = _('Name');
262 $title[] = _('Unix name');
263 $title[] = _('Operations');
266 $userProjectsIdArray = array();
267 foreach ($projects as $p) {
269 echo $GLOBALS['HTML']->listTableTop($title);
272 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
273 <td>'.util_unconvert_htmlspecialchars(htmlspecialchars($p->getPublicName())).'</td>
274 <td>'.$p->getUnixName().'</td>
275 <td width="40%">'.util_make_link('/project/admin/?group_id='.$p->getID(),_('[Project Admin]')).'</td>
278 $userProjectsIdArray[] = $p->getID();
283 echo $GLOBALS['HTML']->listTableBottom();
285 echo '<p>'._('This user is not a member of any project.').'</p>';
288 echo '<h2>'._('Add membership to new projects').'</h2>';
289 $addToNewProjectsTableTitle = array();
290 $addToNewProjectsTableTitle[] = '';
291 $addToNewProjectsTableTitle[] = _('Name');
292 $addToNewProjectsTableTitle[] = _('Unix name');
293 $addToNewProjectsTableTitle[] = _('Operations');
294 $addToNewProjectsTableTitle[] = _('Select role');
295 $fullListProjectsQueryResult = db_query_params('SELECT group_id from groups where status = $1 and is_template = 0', array('A'));
296 if ($fullListProjectsQueryResult) {
297 echo $GLOBALS['HTML']->listTableTop($addToNewProjectsTableTitle);
298 while ($projectQueryResult = db_fetch_array($fullListProjectsQueryResult)) {
299 $projectObject = group_get_object($projectQueryResult['group_id']);
300 if (!in_array($projectObject->getID(), $userProjectsIdArray)) {
302 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
303 <td><input type="checkbox" name="group_id_add_member[]" value="'.$projectObject->getID().'">
304 <td>'.util_unconvert_htmlspecialchars(htmlspecialchars($projectObject->getPublicName())).'</td>
305 <td>'.$projectObject->getUnixName().'</td>
306 <td>'.util_make_link ('/project/admin/?group_id='.$projectObject->getID(),_('[Project Admin]')).'</td>
307 <td>'.role_box($projectObject->getID(),'role_id-'.$projectObject->getID()).'</td>
312 echo $GLOBALS['HTML']->listTableBottom();
314 echo '<br/><input type="submit" name="submit" value="'. _('Update').'" />';
317 site_admin_footer(array());
321 // c-file-style: "bsd"