3 * Site Admin generic user/group search page
5 * This is the single page for searching/selection of users/groups for
6 * Site Admin. Currently, it supports querying by (sub)string match in
7 * string user/group properties (names, fullnames, email) and status.
8 * If new search criteria will be required, they should be added here,
9 * not any other (new) page.
11 * Copyright 1999-2001 (c) VA Linux Systems
12 * http://fusionforge.org
14 * This file is part of FusionForge. FusionForge is free software;
15 * you can redistribute it and/or modify it under the terms of the
16 * GNU General Public License as published by the Free Software
17 * Foundation; either version 2 of the Licence, or (at your option)
20 * FusionForge is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License along
26 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
27 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 require_once('../env.inc.php');
32 require_once $gfcommon.'include/pre.php';
33 require_once $gfwww.'admin/admin_utils.php';
35 $search = getStringFromRequest('search');
36 $usersearch = getStringFromRequest('usersearch');
39 exit_error(_('Refusing to display whole DB. Please use a CLI query if you wish to do this.'),'admin');
42 site_admin_header(array('title'=>_('Admin Search Results')));
44 function format_name($name, $status) {
46 return "<strong><strike>$name</strike></strong>";
47 } else if ($status == 'S') {
48 return "<strong><span style=\"text-decoration:underline\">$name</span></strong>";
49 } else if ($status == 'H') {
50 return "<strong><span style=\"text-decoration:underline\">$name</span></strong>";
51 } else if ($status == 'P') {
52 return "<strong><em>$name</em></strong>";
53 } else if ($status == 'I') {
54 return "<strong><em>$name</em></strong>";
64 if (is_numeric($search)) {
65 $result = db_query_params ('SELECT DISTINCT * FROM users
67 OR lower(user_name) LIKE $2
68 OR lower(email) LIKE $2
69 OR lower(realname) LIKE $2',
71 strtolower("%$search%")));
73 $result = db_query_params ('SELECT DISTINCT * FROM users
74 WHERE lower(user_name) LIKE $1
75 OR lower(email) LIKE $1
76 OR lower(realname) LIKE $1',
77 array (strtolower("%$search%")));
80 print '<p><strong>' .sprintf(ngettext('User search with criteria <em>%1$s</em>: %2$s match', 'User search with criteria <em>%1$s</em>: %2$s matches', db_numrows($result)), $search, db_numrows($result)).'</strong></p>';
82 if (db_numrows($result) < 1) {
84 exit_error(db_error(),'admin');
90 $title[]=_('User name');
91 $title[]=_('Real name');
93 $title[]=_('Member since');
96 echo $GLOBALS['HTML']->listTableTop($title);
98 while ($row = db_fetch_array($result)) {
100 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
101 <td><a href="useredit.php?user_id='.$row['user_id'].'">'.$row['user_id'].'</a></td>
102 <td>'.format_name($row['user_name'], $row['status']).'</td>
103 <td>'.$row['realname'].'</td>
104 <td>'.$row['email'].'</td>
105 <td>'.date(_('Y-m-d H:i'), $row['add_date']).'</td>
106 <td style="text-align:center">'.format_name($row['status'].'/'.$row['unix_status'], $row['status']).'</td>
111 echo $GLOBALS['HTML']->listTableBottom();
114 } // end if ($usersearch)
117 if (getStringFromRequest('groupsearch')) {
118 $status = getStringFromRequest('status');
119 $is_public = getIntFromRequest('is_public', -1);
121 $qpa = db_construct_qpa () ;
123 if(is_numeric($search)) {
124 $qpa = db_construct_qpa ($qpa, 'SELECT DISTINCT * FROM groups
125 WHERE (group_id=$1 OR lower (unix_group_name) LIKE $2 OR lower (group_name) LIKE $2)',
127 strtolower ("%$search%"))) ;
129 $qpa = db_construct_qpa ($qpa, 'SELECT DISTINCT * FROM groups WHERE (lower (unix_group_name) LIKE $1 OR lower (group_name) LIKE $1)',
130 array (strtolower ("%$search%"))) ;
134 $qpa = db_construct_qpa ($qpa, ' AND status=$1', array ($status)) ;
135 $crit_desc .= " status=$status";
139 $crit_desc = "(".trim($crit_desc).")";
142 $result = db_query_qpa ($qpa) ;
143 if (db_numrows($result) < 1) {
148 $ra = RoleAnonymous::getInstance() ;
149 while ($row = db_fetch_array($result)) {
151 if ($is_public == 1) {
152 if ($ra->hasPermission('project_read', $row['group_id'])) {
155 } elseif ($is_public == 0) {
156 if (!$ra->hasPermission('project_read', $row['group_id'])) {
164 print '<p><strong>'.sprintf(ngettext('Group search with criteria <em>%s</em>: %d match', 'Group search with criteria <em>%s</em>: %d matches', count($rows)), $crit_desc, count($rows)).'</strong></p>';
168 $title[]=_('Unix name');
169 $title[]=_('Full Name');
170 $title[]=_('Registered');
171 $title[]=_('Status');
173 echo $GLOBALS['HTML']->listTableTop($title);
176 foreach ($rows as $row) {
178 if (!$ra->hasPermission('project_read', $row['group_id'])) {
179 $extra_status = "/PRV";
183 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
184 <td><a href="groupedit.php?group_id='.$row['group_id'].'">'.$row['group_id'].'</a></td>
185 <td>'.format_name($row['unix_group_name'], $row['status']).'</td>
186 <td>'.$row['group_name'].'</td>
187 <td>'.date(_('Y-m-d H:i'), $row['register_time']).'</td>
188 <td style="text-align:center">'.format_name($row['status'].$extra_status, $row['status']).'</td>
194 echo $GLOBALS['HTML']->listTableBottom();
199 } //end if($groupsearch)
201 site_admin_footer(array());
205 // c-file-style: "bsd"