* Site Admin user properties editing page
*
* Copyright 1999-2001 (c) VA Linux Systems
+ * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2011, Franck Villaume - Capgemini
*
- * This file is part of GForge.
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
*
- * GForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GForge is distributed in the hope that it will be useful,
+ * FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with GForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
require_once('../env.inc.php');
-require_once $gfwww.'include/pre.php';
+require_once $gfcommon.'include/pre.php';
require_once $gfcommon.'include/account.php';
require_once $gfwww.'admin/admin_utils.php';
+require_once $gfwww.'include/role_utils.php';
-session_require_global_perm ('forge_admin');
+session_require_global_perm('forge_admin');
$unix_status2str = array(
'N'=>_('No Unix account (N)'),
$user_id = getIntFromRequest('user_id');
$u =& user_get_object($user_id);
if (!$u || !is_object($u)) {
- exit_error('Error','Could Not Get User');
+ exit_error(_('Could Not Get User'),'admin');
} elseif ($u->isError()) {
- exit_error('Error',$u->getErrorMessage());
+ exit_error($u->getErrorMessage(),'admin');
}
if (getStringFromRequest('delete_user') != '' && getStringFromRequest('confirm_delete') == '1') {
// delete user
if (!$u->delete(true)) {
- exit_error(
- _('Could Not Complete Operation'),
- $u->getErrorMessage()
- );
+ exit_error( _('Could Not Complete Operation: ').$u->getErrorMessage(),'admin');
} else {
$feedback = _('Deleted (D)').'<br />';
}
$email = getStringFromRequest('email');
$shell = getStringFromRequest('shell');
$status = getStringFromRequest('status');
+ $addToProjectArray =getStringFromRequest('group_id_add_member');
- //XXX use_shell
+ //XXX use_shell
if (!$u->setEmail($email)
|| (forge_get_config('use_shell') && !$u->setShell($shell))
|| !$u->setStatus($status)) {
- exit_error(
- _('Could Not Complete Operation'),
- $u->getErrorMessage()
- );
+ exit_error( _('Could Not Complete Operation: ').$u->getErrorMessage(),'admin');
}
if ($u->getUnixStatus() != 'N') {
$u->setUnixStatus('N');
}
}
-
+
+ if (is_array($addToProjectArray)) {
+ foreach($addToProjectArray as $project_id_to_add) {
+ $feedbackMembership = '';
+ $error_msgMembership = '';
+ $projectRoleid = getIntFromRequest('role_id-'.$project_id_to_add);
+ $projectObjectAction = group_get_object($project_id_to_add);
+ if (!$projectObjectAction->addUser((int)$u->getID(), $projectRoleid)) {
+ echo $projectObjectAction->getErrorMessage().$u->getID();
+ $error_msgMembership .= $projectObjectAction->getErrorMessage().'<br/>';
+ } else {
+ $feedbackMembership .= _("Added Successfully to project ").$projectObjectAction->getPublicName().'<br/>';
+ //if the user have requested to join this group
+ //we should remove him from the request list
+ //since it has already been added
+ $gjr = new GroupJoinRequest($projectObjectAction, $u->getID());
+ if ($gjr || is_object($gjr) || !$gjr->isError()) {
+ $gjr->delete(true);
+ }
+ }
+ }
+ }
+
if ($u->isError()) {
- $feedback = $u->getErrorMessage();
+ $error_msg = $u->getErrorMessage();
+ if (isset($error_msgMembership) && sizeof($error_msgMembership))
+ $error_msg .= '<br/>'.$error_msgMembership;
} else {
- $feedback = _('Updated').'<br />';
+ $feedback = _('Updated');
+ if (isset($feedbackMembership) && sizeof($feedbackMembership))
+ $feedback .= '<br/>'.$feedbackMembership;
}
}
-
-site_admin_header(array('title'=>_('Site Admin: User Info')));
+$title = _('Site Admin: User Info');
+site_admin_header(array('title'=>$title));
?>
-<h3><?php echo _('Account Information'); ?><sup>1</sup></h3>
+<h2><?php echo _('Account Information'); ?><sup>1</sup></h2>
<form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
<input type="hidden" name="action" value="update_user" />
<table>
<tr>
<td>
-<?php echo _('User ID:'); ?>
+<?php echo _('User Id:'); ?>
</td>
<td>
<?php echo $u->getID(); ?>
_('Active (A)'),
_('Suspended (S)'),
_('Deleted (D)'));
-} else {
+} else if ($u->getStatus() == 'P') {
$status_letter = array('P','A','S');
$status_text = array(_('Pending (P)'),
_('Active (A)'),
_('Suspended (S)'));
+} else {
+ $status_letter = array('A','S');
+ $status_text = array(_('Active (A)'),
+ _('Suspended (S)'));
}
-?>
-<?php echo html_build_select_box_from_arrays(
+echo html_build_select_box_from_arrays(
$status_letter, $status_text,'status', $u->getStatus(), false);
?>
</td>
</tr>
-<?php
+<?php
if (forge_get_config('use_shell')) {
-?>
+?>
<tr>
<td>
<?php echo _('Unix Account Status'); ?><sup>2</sup>:
<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).'); ?>
</p>
-<?php
+<?php
if (forge_get_config('use_shell')) {
-?>
+?>
<p>
<sup>2</sup><?php echo _('Unix status updated mirroring web status, unless it has value \'No unix account (N)\''); ?>
</p>
<?php
} //end of sys_use_shell condition
-?>
-
-</form>
+?>
<hr />
-<h3><?php echo _('Groups Membership'); ?></h3>
+<h2><?php echo _('Projects Membership'); ?></h2>
<?php
/*
- Iterate and show groups this user is in
+ Iterate and show projects this user is in
*/
-$res_cat = db_query_params ('
- SELECT groups.unix_group_name, groups.group_name AS group_name,
- groups.group_id AS group_id,
- user_group.admin_flags AS admin_flags
- FROM groups,user_group
- WHERE user_group.user_id=$1
- AND groups.group_id=user_group.group_id
-',
- array($user_id)) ;
-
-
-$title=array();
-$title[]=_('Name');
-$title[]=_('Unix name');
-$title[]=_('Operations');
-echo $GLOBALS['HTML']->listTableTop($title);
-
-$i = 0 ;
-while ($row_cat = db_fetch_array($res_cat)) {
-
- $row_cat['group_name'] = htmlspecialchars($row_cat['group_name']);
+$projects = $u->getGroups();
+
+$title = array();
+$title[] = _('Name');
+$title[] = _('Unix name');
+$title[] = _('Operations');
+
+$i = 0;
+$userProjectsIdArray = array();
+foreach ($projects as $p) {
+ if ($i == 0) {
+ echo $GLOBALS['HTML']->listTableTop($title);
+ }
print '
<tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
- <td>'.util_unconvert_htmlspecialchars($row_cat['group_name']).'</td>
- <td>'.$row_cat['unix_group_name'].'</td>
- <td width="40%">'.util_make_link ('/project/admin/?group_id='.$row_cat['group_id'],_('[Project Admin]')).'</td>
+ <td>'.util_unconvert_htmlspecialchars(htmlspecialchars($p->getPublicName())).'</td>
+ <td>'.$p->getUnixName().'</td>
+ <td width="40%">'.util_make_link('/project/admin/?group_id='.$p->getID(),_('[Project Admin]')).'</td>
</tr>
';
+ $userProjectsIdArray[] = $p->getID();
+ $i++;
+}
+if ($i > 0) {
+ echo $GLOBALS['HTML']->listTableBottom();
+} else {
+ echo '<p>'._('This user is not a member of any project.').'</p>';
}
-echo $GLOBALS['HTML']->listTableBottom();
-echo '<br />';
+echo '<h2>'._('Add membership to new projects').'</h2>';
+$addToNewProjectsTableTitle = array();
+$addToNewProjectsTableTitle[] = '';
+$addToNewProjectsTableTitle[] = _('Name');
+$addToNewProjectsTableTitle[] = _('Unix name');
+$addToNewProjectsTableTitle[] = _('Operations');
+$addToNewProjectsTableTitle[] = _('Select role');
+$fullListProjectsQueryResult = db_query_params('SELECT group_id from groups where status = $1', array('A'));
+if ($fullListProjectsQueryResult) {
+ echo $GLOBALS['HTML']->listTableTop($addToNewProjectsTableTitle);
+ while ($projectQueryResult = db_fetch_array($fullListProjectsQueryResult)) {
+ $projectObject = group_get_object($projectQueryResult['group_id']);
+ if (!in_array($projectObject->getID(), $userProjectsIdArray)) {
+ print '
+ <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
+ <td><input type="checkbox" name="group_id_add_member[]" value="'.$projectObject->getID().'">
+ <td>'.util_unconvert_htmlspecialchars(htmlspecialchars($projectObject->getPublicName())).'</td>
+ <td>'.$projectObject->getUnixName().'</td>
+ <td>'.util_make_link ('/project/admin/?group_id='.$projectObject->getID(),_('[Project Admin]')).'</td>
+ <td>'.role_box($projectObject->getID(),'role_id-'.$projectObject->getID()).'</td>
+ </tr>
+ ';
+ }
+ }
+ echo $GLOBALS['HTML']->listTableBottom();
+}
+echo '<br/><input type="submit" name="submit" value="'. _('Update').'" />';
+echo '</form>';
site_admin_footer(array());