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
15 * This file is part of GForge.
17 * GForge is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * GForge is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with GForge; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 require_once('../env.inc.php');
34 require_once('pre.php');
35 require_once('www/admin/admin_utils.php');
37 $search = getStringFromRequest('search');
38 $substr = getStringFromRequest('substr');
39 $usersearch = getStringFromRequest('usersearch');
42 exit_error(_('Error'), _('Refusing to display whole DB,That would display whole DB. Please use a CLI query if you wish to do this.'));
45 site_admin_header(array('title'=>_('Admin Search Results')));
47 function format_name($name, $status) {
49 return "<strong><strike>$name</strike></strong>";
50 } else if ($status == 'S') {
51 return "<strong><span style=\"text-decoration:underline\">$name</span></strong>";
52 } else if ($status == 'H') {
53 return "<strong><span style=\"text-decoration:underline\">$name</span></strong>";
54 } else if ($status == 'P') {
55 return "<strong><em>$name</em></strong>";
56 } else if ($status == 'I') {
57 return "<strong><em>$name</em></strong>";
67 $search = "%$search%";
76 if ( $sys_database_type == "mysql" ) {
78 WHERE user_id LIKE '$search'
79 OR user_name LIKE '%$search%'
80 OR email LIKE '%$search%'
81 OR realname LIKE '%$search%'";
84 WHERE user_id ILIKE '$search'
85 OR user_name ILIKE '%$search%'
86 OR email ILIKE '%$search%'
87 OR realname ILIKE '%$search%'";
89 $result = db_query($sql);
91 print '<p><strong>' ._('User search with criteria').' "<em>'.$search.'</em>": '
92 .db_numrows($result) .' '. _('matches').'</strong></p>';
94 if (db_numrows($result) < 1) {
102 $title[]=_('Username');
103 $title[]=_('Real Name');
105 $title[]=_('Member since');
106 $title[]=_('Status');
108 echo $GLOBALS['HTML']->listTableTop($title);
110 while ($row = db_fetch_array($result)) {
112 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
113 <td><a href="useredit.php?user_id='.$row['user_id'].'">'.$row['user_id'].'</a></td>
114 <td>'.format_name($row['user_name'], $row['status']).'</td>
115 <td>'.$row['realname'].'</td>
116 <td>'.$row['email'].'</td>
117 <td>'.date($sys_datefmt, $row['add_date']).'</td>
118 <td style="text-align:center">'.format_name($row['status'].'/'.$row['unix_status'], $row['status']).'</td>
123 echo $GLOBALS['HTML']->listTableBottom();
126 } // end if ($usersearch)
129 if (getStringFromRequest('groupsearch')) {
130 $status = getStringFromRequest('status');
131 $is_public = getStringFromRequest('is_public');
132 $crit_desc = getStringFromRequest('crit_desc');
135 $crit_sql .= " AND status='$status'";
136 $crit_desc .= " status=$status";
139 $crit_sql .= " AND is_public='$is_public'";
140 $crit_desc .= " is_public=$is_public";
146 if ( $sys_database_type == "mysql" ) {
148 WHERE (group_id LIKE '%$search%'
149 OR unix_group_name LIKE '%$search%'
150 OR group_name LIKE '%$search%')
154 WHERE (group_id ILIKE '%$search%'
155 OR unix_group_name ILIKE '%$search%'
156 OR group_name ILIKE '%$search%')
159 $result = db_query($sql);
162 $crit_desc = "($crit_desc )";
164 print '<p><strong>' ._('Group search with criteria').'"<em>'.$search.'</em>" '.$crit_desc.': '
165 .db_numrows($result).' '._('matches').'</strong></p>';
167 if (db_numrows($result) < 1) {
173 $title[]=_('UNIX Name');
174 $title[]=_('Full Name');
175 $title[]=_('Registered');
176 $title[]=_('Status');
178 echo $GLOBALS['HTML']->listTableTop($title);
180 while ($row = db_fetch_array($result)) {
183 if (!$row['is_public']) {
184 $extra_status = "/PRV";
188 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
189 <td><a href="groupedit.php?group_id='.$row['group_id'].'">'.$row['group_id'].'</a></td>
190 <td>'.format_name($row['unix_group_name'], $row['status']).'</td>
191 <td>'.$row['group_name'].'</td>
192 <td>'.date($sys_datefmt, $row['register_time']).'</td>
193 <td style="text-align:center">'.format_name($row['status'].$extra_status, $row['status']).'</td>
199 echo $GLOBALS['HTML']->listTableBottom();
204 } //end if($groupsearch)
206 site_admin_footer(array());