4 * Copyright 1999-2000 (c) The SourceForge Crew
6 * This file is part of GForge.
8 * GForge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * GForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GForge; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 require_once('../env.inc.php');
24 require_once $gfcommon.'include/pre.php';
25 require_once $gfwww.'admin/admin_utils.php';
27 session_require_global_perm ('forge_admin');
29 $HTML->header(array('title'=>_('User List')));
30 echo '<h1>' . _('User List') . '</h1>';
33 * performAction() - Updates the indicated user status
35 * @param string $newStatus - the new user status
36 * @param string $statusString - the status string to display
37 * @param string $user_id - the user id to act upon
39 function performAction($newStatus, $statusString, $user_id) {
40 $u =& user_get_object($user_id);
41 if (!$u || !is_object($u)) {
42 exit_error('Error','Could Not Get User');
43 } elseif ($u->isError()) {
44 exit_error('Error',$u->getErrorMessage());
47 if(!$u->delete(true)) {
48 exit_error('Error',$u->getErrorMessage());
51 if(!$u->setStatus($newStatus)) {
52 exit_error('Error',$u->getErrorMessage());
54 if(!$u->setUnixStatus($newStatus)) {
55 exit_error('Error',$u->getErrorMessage());
59 echo "<h2>" .sprintf(_('User updated to %1$s status'), $statusString)."</h2>";
62 function show_users_list ($result) {
63 echo '<p>' ._('Key') .':
64 <span class="active">'._('Active'). '</span>
65 <span class="deleted">' ._('Deleted') .'</span>
66 <span class="suspended">' ._('Suspended'). '</span>
67 <span class="pending">' ._('(*)Pending'). '</span>'.'</p>';
79 '/admin/userlist.php?sortorder=user_name',
80 '/admin/userlist.php?sortorder=add_date',
81 '/admin/userlist.php?sortorder=user_name',
82 '/admin/userlist.php?sortorder=user_name',
83 '/admin/userlist.php?sortorder=user_name',
84 '/admin/userlist.php?sortorder=user_name'
87 echo $GLOBALS['HTML']->listTableTop($headers, $headerLinks);
90 while ($usr = db_fetch_array($result)) {
91 print '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($count) . '><td class="';
92 if ($usr['status'] == 'A') print "active";
93 if ($usr['status'] == 'D') print "deleted";
94 if ($usr['status'] == 'S') print "suspended";
95 if ($usr['status'] == 'P') print "pending";
96 print '"><a href="useredit.php?user_id='.$usr['user_id'].'">';
97 if ($usr['status'] == 'P') print "*";
98 echo $usr['firstname'].' '.$usr['lastname'].' ('.$usr['user_name'].')</a>';
100 echo '<td width="15%" style="text-align:center">';
101 echo ($usr['add_date'] ? date(_('Y-m-d H:i'), $usr['add_date']) : '-');
103 echo '<td width="15%" style="text-align:center">'.util_make_link ('/developer/?form_dev='.$usr['user_id'],_('[DevProfile]')).'</td>';
104 echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=activate&user_id='.$usr['user_id'],_('[Activate]')).'</td>';
105 echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=delete&user_id='.$usr['user_id'],_('[Delete]')).'</td>';
106 echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=suspend&user_id='.$usr['user_id'],_('[Suspend]')).'</td>';
111 echo $GLOBALS['HTML']->listTableBottom();
115 // Administrative functions
117 $group_id = getIntFromRequest('group_id');
118 $action = getStringFromRequest('action');
119 $user_id = getStringFromRequest('user_id');
121 if ($action=='delete') {
122 performAction('D', "DELETED", $user_id);
125 plugin_hook('del_cal_user',$user_id);
126 } else if ($action=='activate') {
127 performAction('A', "ACTIVE", $user_id);
130 plugin_hook('add_cal_user',$user_id);
131 } else if ($action=='suspend') {
132 performAction('S', "SUSPENDED", $user_id);
135 // Show list of users
136 print "<p>" ._('User list for group:');
138 $user_name_search = getStringFromRequest('user_name_search');
140 print "<strong>" ._('All Projects'). "</strong>";
143 if ($user_name_search) {
144 $result = db_query_params ('SELECT user_name,lastname,firstname,user_id,status,add_date FROM users WHERE lower(user_name) LIKE $1 OR lower(lastname) LIKE $1 ORDER BY realname',
145 array (strtolower("$user_name_search%")));
147 $sortorder = getStringFromRequest('sortorder', 'realname');
148 $result = db_query_params('SELECT user_name,lastname,firstname,user_id,status,add_date FROM users ORDER BY $1', array($sortorder));
150 show_users_list ($result);
153 Show list for one group
155 print "<strong>" . group_getname($group_id) . "</strong></p>";
158 $result = db_query_params ('SELECT users.user_id AS user_id,users.user_name AS user_name,users.status AS status, users.add_date AS add_date
159 FROM users,user_group
160 WHERE users.user_id=user_group.user_id AND
161 user_group.group_id=$1 ORDER BY users.user_name',
163 show_users_list ($result);
166 $HTML->footer(array());
170 // c-file-style: "bsd"