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 * Copyright 2013, French Ministry of National Education
13 * Copyright 2013, Franck Villaume - TrivialDev
14 * http://fusionforge.org
16 * This file is part of FusionForge. FusionForge is free software;
17 * you can redistribute it and/or modify it under the terms of the
18 * GNU General Public License as published by the Free Software
19 * Foundation; either version 2 of the Licence, or (at your option)
22 * FusionForge 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 along
28 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
29 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 require_once '../env.inc.php';
33 require_once $gfcommon.'include/pre.php';
34 require_once $gfwww.'admin/admin_utils.php';
36 $search = trim(getStringFromRequest('search'));
37 $usersearch = trim(getStringFromRequest('usersearch'));
39 site_admin_header(array('title'=>_('Admin Search Results')));
41 function format_name($name, $status) {
43 return "<strong><span class=\"strike\">$name</span></strong>";
44 } elseif ($status == 'S') {
45 return "<strong><span style=\"text-decoration:underline\">$name</span></strong>";
46 } elseif ($status == 'H') {
47 return "<strong><span style=\"text-decoration:underline\">$name</span></strong>";
48 } elseif ($status == 'P') {
49 return "<strong><em>$name</em></strong>";
50 } elseif ($status == 'I') {
51 return "<strong><em>$name</em></strong>";
61 $result = db_query_params ('SELECT DISTINCT * FROM users
62 WHERE cast(user_id as text) LIKE $1
63 OR lower(user_name) LIKE $1
64 OR lower(email) LIKE $1
65 OR lower(realname) LIKE $1',
66 array (strtolower("%$search%")));
68 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>';
70 if (db_numrows($result) >= 1) {
73 $title[]=_('User Name');
74 $title[]=_('Real Name');
76 $title[]=_('Member since');
79 echo $GLOBALS['HTML']->listTableTop($title);
81 while ($row = db_fetch_array($result)) {
83 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
84 <td><a href="useredit.php?user_id='.$row['user_id'].'">'.$row['user_id'].'</a></td>
85 <td>'.format_name($row['user_name'], $row['status']).'</td>
86 <td>'.$row['realname'].'</td>
87 <td>'.$row['email'].'</td>
88 <td>'.date(_('Y-m-d H:i'), $row['add_date']).'</td>
89 <td class="align-center">'.format_name($row['status'].'/'.$row['unix_status'], $row['status']).'</td>
94 echo $GLOBALS['HTML']->listTableBottom();
96 echo '<p class="information">'._('No user found.').'</p>';
98 } // end if ($usersearch)
100 if (getStringFromRequest('groupsearch')) {
101 $status = getStringFromRequest('status');
102 $is_public = getIntFromRequest('is_public', -1);
104 $qpa = db_construct_qpa () ;
106 if(is_numeric($search)) {
107 $qpa = db_construct_qpa ($qpa, 'SELECT DISTINCT * FROM groups
108 WHERE (group_id=$1 OR lower (unix_group_name) LIKE $2 OR lower (group_name) LIKE $2)',
110 strtolower ("%$search%"))) ;
112 $qpa = db_construct_qpa ($qpa, 'SELECT DISTINCT * FROM groups WHERE (lower (unix_group_name) LIKE $1 OR lower (group_name) LIKE $1)',
113 array (strtolower ("%$search%"))) ;
117 $qpa = db_construct_qpa ($qpa, ' AND status=$1', array ($status)) ;
118 $crit_desc .= " status=$status";
122 $crit_desc = "(".trim($crit_desc).")";
125 $result = db_query_qpa ($qpa) ;
126 if (db_numrows($result) >= 1) {
128 $ra = RoleAnonymous::getInstance() ;
129 while ($row = db_fetch_array($result)) {
131 if ($is_public == 1) {
132 if ($ra->hasPermission('project_read', $row['group_id'])) {
135 } elseif ($is_public == 0) {
136 if (!$ra->hasPermission('project_read', $row['group_id'])) {
144 print '<p><strong>'.sprintf(ngettext('Project search with criteria <em>%s</em>: %d match', 'Project search with criteria <em>%s</em>: %d matches', count($rows)), $crit_desc, count($rows)).'</strong></p>';
148 $title[]=_('Unix Name');
149 $title[]=_('Full Name');
150 $title[]=_('Registered');
151 $title[]=_('Status');
153 echo $GLOBALS['HTML']->listTableTop($title);
156 foreach ($rows as $row) {
158 if (!$ra->hasPermission('project_read', $row['group_id'])) {
159 $extra_status = "/PRV";
163 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
164 <td><a href="groupedit.php?group_id='.$row['group_id'].'">'.$row['group_id'].'</a></td>
165 <td>'.format_name($row['unix_group_name'], $row['status']).'</td>
166 <td>'.$row['group_name'].'</td>
167 <td>'.date(_('Y-m-d H:i'), $row['register_time']).'</td>
168 <td class="align-center">'.format_name($row['status'].$extra_status, $row['status']).'</td>
174 echo $GLOBALS['HTML']->listTableBottom();
176 echo '<p class="information">'._('No project found.').'</p>';
178 } //end if($groupsearch)
180 site_admin_footer(array());
184 // c-file-style: "bsd"