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.
30 require_once '../env.inc.php';
31 require_once $gfcommon.'include/pre.php';
32 require_once $gfwww.'admin/admin_utils.php';
34 $search = trim(getStringFromRequest('search'));
35 $usersearch = trim(getStringFromRequest('usersearch'));
37 site_admin_header(array('title'=>_('Admin Search Results')));
39 function format_name($name, $status) {
41 return "<strong><span class=\"strike\">$name</span></strong>";
42 } elseif ($status == 'S') {
43 return "<strong><span style=\"text-decoration:underline\">$name</span></strong>";
44 } elseif ($status == 'H') {
45 return "<strong><span style=\"text-decoration:underline\">$name</span></strong>";
46 } elseif ($status == 'P') {
47 return "<strong><em>$name</em></strong>";
48 } elseif ($status == 'I') {
49 return "<strong><em>$name</em></strong>";
59 $result = db_query_params ('SELECT DISTINCT * FROM users
60 WHERE cast(user_id as text) LIKE $1
61 OR lower(user_name) LIKE $1
62 OR lower(email) LIKE $1
63 OR lower(realname) LIKE $1',
64 array (strtolower("%$search%")));
66 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>';
68 if (db_numrows($result) < 1) {
70 exit_error(db_error(),'admin');
76 $title[]=_('User name');
77 $title[]=_('Real name');
79 $title[]=_('Member since');
82 echo $GLOBALS['HTML']->listTableTop($title);
84 while ($row = db_fetch_array($result)) {
86 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
87 <td><a href="useredit.php?user_id='.$row['user_id'].'">'.$row['user_id'].'</a></td>
88 <td>'.format_name($row['user_name'], $row['status']).'</td>
89 <td>'.$row['realname'].'</td>
90 <td>'.$row['email'].'</td>
91 <td>'.date(_('Y-m-d H:i'), $row['add_date']).'</td>
92 <td class="align-center">'.format_name($row['status'].'/'.$row['unix_status'], $row['status']).'</td>
97 echo $GLOBALS['HTML']->listTableBottom();
100 } // end if ($usersearch)
103 if (getStringFromRequest('groupsearch')) {
104 $status = getStringFromRequest('status');
105 $is_public = getIntFromRequest('is_public', -1);
107 $qpa = db_construct_qpa () ;
109 if(is_numeric($search)) {
110 $qpa = db_construct_qpa ($qpa, 'SELECT DISTINCT * FROM groups
111 WHERE (group_id=$1 OR lower (unix_group_name) LIKE $2 OR lower (group_name) LIKE $2)',
113 strtolower ("%$search%"))) ;
115 $qpa = db_construct_qpa ($qpa, 'SELECT DISTINCT * FROM groups WHERE (lower (unix_group_name) LIKE $1 OR lower (group_name) LIKE $1)',
116 array (strtolower ("%$search%"))) ;
120 $qpa = db_construct_qpa ($qpa, ' AND status=$1', array ($status)) ;
121 $crit_desc .= " status=$status";
125 $crit_desc = "(".trim($crit_desc).")";
128 $result = db_query_qpa ($qpa) ;
129 if (db_numrows($result) < 1) {
134 $ra = RoleAnonymous::getInstance() ;
135 while ($row = db_fetch_array($result)) {
137 if ($is_public == 1) {
138 if ($ra->hasPermission('project_read', $row['group_id'])) {
141 } elseif ($is_public == 0) {
142 if (!$ra->hasPermission('project_read', $row['group_id'])) {
150 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>';
154 $title[]=_('Unix name');
155 $title[]=_('Full Name');
156 $title[]=_('Registered');
157 $title[]=_('Status');
159 echo $GLOBALS['HTML']->listTableTop($title);
162 foreach ($rows as $row) {
164 if (!$ra->hasPermission('project_read', $row['group_id'])) {
165 $extra_status = "/PRV";
169 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
170 <td><a href="groupedit.php?group_id='.$row['group_id'].'">'.$row['group_id'].'</a></td>
171 <td>'.format_name($row['unix_group_name'], $row['status']).'</td>
172 <td>'.$row['group_name'].'</td>
173 <td>'.date(_('Y-m-d H:i'), $row['register_time']).'</td>
174 <td class="align-center">'.format_name($row['status'].$extra_status, $row['status']).'</td>
180 echo $GLOBALS['HTML']->listTableBottom();
185 } //end if($groupsearch)
187 site_admin_footer(array());
191 // c-file-style: "bsd"