4 * Copyright 1999-2000 (c) The SourceForge Crew
5 * Copyright 2010 (c) Franck Villaume - Capgemini
6 * http://fusionforge.org
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once('../env.inc.php');
25 require_once $gfcommon.'include/pre.php';
26 require_once $gfwww.'admin/admin_utils.php';
28 // user must be forge admin to proceed
29 session_require_global_perm ('forge_admin');
31 $HTML->header(array('title'=>_('User List')));
34 * performAction() - Updates the indicated user status
36 * @param string $newStatus - the new user status
37 * @param string $statusString - the status string to display
38 * @param string $user_id - the user id to act upon
40 function performAction($newStatus, $statusString, $user_id) {
41 $u = user_get_object($user_id);
42 if (!$u || !is_object($u)) {
43 exit_error(_('Could Not Get User'),'home');
44 } elseif ($u->isError()) {
45 exit_error($u->getErrorMessage(),'home');
48 if(!$u->setStatus($newStatus)) {
49 exit_error($u->getErrorMessage(),'home');
51 if(!$u->delete(true)) {
52 exit_error($u->getErrorMessage(),'home');
55 if(!$u->setStatus($newStatus)) {
56 exit_error($u->getErrorMessage(),'home');
58 if(!$u->setUnixStatus($newStatus)) {
59 exit_error($u->getErrorMessage(),'home');
63 echo '<p class="feedback">' .sprintf(_('User updated to %1$s status'), $statusString)."</p>";
66 function show_users_list ($users, $filter='') {
71 echo '<p>' ._('Key') .':
72 <span class="active">'._('Active'). '</span>
73 <span class="deleted">' ._('Deleted') .'</span>
74 <span class="suspended">' ._('Suspended'). '</span>
75 <span class="pending">' ._('(*)Pending'). '</span>'.'</p>';
88 '/admin/userlist.php?sortorder=user_name',
89 '/admin/userlist.php?sortorder=add_date',
90 '/admin/userlist.php?sortorder=user_name',
91 '/admin/userlist.php?sortorder=user_name',
92 '/admin/userlist.php?sortorder=user_name',
93 '/admin/userlist.php?sortorder=user_name',
94 '/admin/userlist.php?sortorder=user_name'
97 echo $GLOBALS['HTML']->listTableTop($headers, $headerLinks);
100 foreach ($users as $u) {
101 print '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($count) . '><td class="';
102 if ($u->getStatus() == 'A') print "active";
103 if ($u->getStatus() == 'D') print "deleted";
104 if ($u->getStatus() == 'S') print "suspended";
105 if ($u->getStatus() == 'P') print "pending";
106 print '"><a href="useredit.php?user_id='.$u->getID().'">';
107 if ($u->getStatus() == 'P') print "*";
108 echo $u->getRealName().' ('.$u->getUnixName().')</a>';
110 echo '<td width="15%" style="text-align:center">';
111 echo ($u->getAddDate() ? date(_('Y-m-d H:i'), $u->getAddDate()) : '-');
113 echo '<td width="12%" style="text-align:center">'.util_make_link ('/developer/?form_dev='.$u->getID(),_('[DevProfile]')).'</td>';
114 echo '<td width="12%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=activate&user_id='.$u->getID().$filter,_('[Activate]')).'</td>';
115 echo '<td width="12%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=delete&user_id='.$u->getID().$filter,_('[Delete]')).'</td>';
116 echo '<td width="12%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=suspend&user_id='.$u->getID().$filter,_('[Suspend]')).'</td>';
117 echo '<td width="12%" style="text-align:center">'.util_make_link ('/admin/passedit.php?user_id='.$u->getID().$filter,_('[Change PW]')).'</td>';
122 echo $GLOBALS['HTML']->listTableBottom();
126 // Administrative functions
128 $group_id = getIntFromRequest('group_id');
129 $action = getStringFromRequest('action');
130 $user_id = getIntFromRequest('user_id');
131 $status = getStringFromRequest('status');
133 if ($action=='delete') {
134 performAction('D', "DELETED", $user_id);
135 } else if ($action=='activate') {
136 performAction('A', "ACTIVE", $user_id);
137 } else if ($action=='suspend') {
138 performAction('S', "SUSPENDED", $user_id);
141 // Show list of users
142 print "<p>" ._('User list for project: ');
144 $user_name_search = getStringFromRequest('user_name_search');
146 print "<strong>" ._('All Projects'). "</strong>";
149 if ($user_name_search) {
150 $res = db_query_params ('SELECT user_id FROM users WHERE lower(user_name) LIKE $1 OR lower(lastname) LIKE $1 ORDER BY realname',
151 array (strtolower("$user_name_search%")));
153 $res = db_query_params ('SELECT user_id FROM users WHERE status = $1 ORDER BY realname',
156 $sortorder = getStringFromRequest('sortorder', 'realname');
157 util_ensure_value_in_set ($sortorder,
158 array('realname','user_name','lastname','firstname','user_id','status','add_date')) ;
159 $res = db_query_params('SELECT user_id FROM users ORDER BY '.$sortorder,
163 if (in_array($status,array('D','A','S','P'))) {
164 $filter = '&status='.$status;
166 show_users_list (user_get_objects(util_result_column_to_array($res,0)),$filter);
169 Show list for one project
171 $project = group_get_object($group_id) ;
172 print "<strong>" . $project->getPublicName() . "</strong></p>";
174 show_users_list ($project->getUsers());
177 $HTML->footer(array());
181 // c-file-style: "bsd"