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 $gfwww.'include/pre.php';
25 require_once $gfwww.'admin/admin_utils.php';
26 session_require(array('group'=>'1','admin_flags'=>'A'));
28 $HTML->header(array('title'=>_(': User List')));
31 * performAction() - Updates the indicated user status
33 * @param string $newStatus - the new user status
34 * @param string $statusString - the status string to display
35 * @param string $user_id - the user id to act upon
37 function performAction($newStatus, $statusString, $user_id) {
38 $u =& user_get_object($user_id);
39 if (!$u || !is_object($u)) {
40 exit_error('Error','Could Not Get User');
41 } elseif ($u->isError()) {
42 exit_error('Error',$u->getErrorMessage());
45 if(!$u->delete(true)) {
46 exit_error('Error',$u->getErrorMessage());
49 if(!$u->setStatus($newStatus)) {
50 exit_error('Error',$u->getErrorMessage());
53 echo "<h2>" .sprintf(_('User updated to %1$s status'), $statusString)."</h2>";
56 function show_users_list ($result) {
57 echo '<p>' ._('Key') .':
58 <span class="active">'._('Active'). '</span>
59 <span class="deleted">' ._('Deleted') .'</span>
60 <span class="suspended">' ._('Suspended'). '</span>
61 <span class="pending">' ._('(*)Pending'). '</span>'.'</p>';
73 '/admin/userlist.php?sortorder=user_name',
74 '/admin/userlist.php?sortorder=add_date',
75 '/admin/userlist.php?sortorder=user_name',
76 '/admin/userlist.php?sortorder=user_name',
77 '/admin/userlist.php?sortorder=user_name',
78 '/admin/userlist.php?sortorder=user_name'
81 echo $GLOBALS['HTML']->listTableTop($headers, $headerLinks);
84 while ($usr = db_fetch_array($result)) {
85 print '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($count) . '><td class="';
86 if ($usr['status'] == 'A') print "active";
87 if ($usr['status'] == 'D') print "deleted";
88 if ($usr['status'] == 'S') print "suspended";
89 if ($usr['status'] == 'P') print "pending";
90 print '"><a href="useredit.php?user_id='.$usr['user_id'].'">';
91 if ($usr['status'] == 'P') print "*";
92 echo $usr['firstname'].' '.$usr['lastname'].' ('.$usr['user_name'].')</a>';
94 echo '<td width="15%" style="text-align:center">';
95 echo ($usr['add_date'] ? date(_('Y-m-d H:i'), $usr['add_date']) : '-');
97 echo '<td width="15%" style="text-align:center">'.util_make_link ('/developer/?form_dev='.$usr['user_id'],_('[DevProfile]')).'</td>';
98 echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=activate&user_id='.$usr['user_id'],_('[Activate]')).'</td>';
99 echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=delete&user_id='.$usr['user_id'],_('[Delete]')).'</td>';
100 echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=suspend&user_id='.$usr['user_id'],_('[Suspend]')).'</td>';
105 echo $GLOBALS['HTML']->listTableBottom();
109 // Administrative functions
111 $group_id = getIntFromRequest('group_id');
112 $action = getStringFromRequest('action');
113 $user_id = getStringFromRequest('user_id');
115 if ($action=='delete') {
116 performAction('D', "DELETED", $user_id);
119 plugin_hook('del_cal_user',$user_id);
120 } else if ($action=='activate') {
121 performAction('A', "ACTIVE", $user_id);
124 plugin_hook('add_cal_user',$user_id);
125 } else if ($action=='suspend') {
126 performAction('S', "SUSPENDED", $user_id);
129 // Add a user to this group
130 if (getStringFromRequest('action') == 'add_to_group') {
131 echo "ACTION NOT SUPPORTED";
134 // Show list of users
135 print "<p>" ._('User list for group:');
137 $user_name_search = getStringFromRequest('user_name_search');
139 print "<strong>" ._('All Groups'). "</strong>";
142 if ($user_name_search) {
143 $sql = 'SELECT user_name,lastname,firstname,user_id,status,add_date FROM users WHERE user_name ';
144 $sql .= $sys_database_type == 'mysql' ? 'LIKE' : 'ILIKE';
145 $sql .= ' \''.$user_name_search.'%\' OR lastname ';
146 $sql .= $sys_database_type == 'mysql' ? 'LIKE' : 'ILIKE';
147 $sql .= ' \''.$user_name_search.'%\' ORDER BY lastname';
148 $result = db_query($sql);
150 $sortorder = getStringFromRequest('sortorder', 'user_name');
151 $result = db_query("SELECT user_name,lastname,firstname,user_id,status,add_date FROM users ORDER BY ".$sortorder);
153 show_users_list ($result);
156 Show list for one group
158 print "<strong>" . group_getname($group_id) . "</strong></p>";
161 $result = db_query("SELECT users.user_id AS user_id,users.user_name AS user_name,users.status AS status, users.add_date AS add_date "
162 . "FROM users,user_group "
163 . "WHERE users.user_id=user_group.user_id AND "
164 . "user_group.group_id='$group_id' ORDER BY users.user_name");
165 show_users_list ($result);
168 Show a form so a user can be added to this group
173 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
174 <input type="hidden" name="action" value="add_to_group" />
175 <input name="user_id" type="TEXT" value="" />
177 Add User to Group (<?php print group_getname($group_id); ?>):
179 <input type="hidden" name="group_id" value="<?php print $group_id; ?>" />
181 <input type="submit" name="Submit" value="<?php echo _('Submit'); ?>" />
187 $HTML->footer(array());
191 // c-file-style: "bsd"