* not any other (new) page.
*
* Copyright 1999-2001 (c) VA Linux Systems
+ * Copyright 2013, French Ministry of National Education
+ * Copyright 2013, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
-require_once('../env.inc.php');
+require_once '../env.inc.php';
require_once $gfcommon.'include/pre.php';
require_once $gfwww.'admin/admin_utils.php';
-$search = getStringFromRequest('search');
-$usersearch = getStringFromRequest('usersearch');
-
-if (!$search) {
- exit_error(_('Refusing to display whole DB. Please use a CLI query if you wish to do this.'),'admin');
-}
+$search = trim(getStringFromRequest('search'));
+$usersearch = trim(getStringFromRequest('usersearch'));
site_admin_header(array('title'=>_('Admin Search Results')));
function format_name($name, $status) {
if ($status == 'D') {
- return "<strong><strike>$name</strike></strong>";
- } else if ($status == 'S') {
+ return "<strong><span class=\"strike\">$name</span></strong>";
+ } elseif ($status == 'S') {
return "<strong><span style=\"text-decoration:underline\">$name</span></strong>";
- } else if ($status == 'H') {
+ } elseif ($status == 'H') {
return "<strong><span style=\"text-decoration:underline\">$name</span></strong>";
- } else if ($status == 'P') {
+ } elseif ($status == 'P') {
return "<strong><em>$name</em></strong>";
- } else if ($status == 'I') {
+ } elseif ($status == 'I') {
return "<strong><em>$name</em></strong>";
}
Main code
*/
if ($usersearch) {
- if (is_numeric($search)) {
- $result = db_query_params ('SELECT DISTINCT * FROM users
-WHERE user_id = $1
-OR lower(user_name) LIKE $2
-OR lower(email) LIKE $2
-OR lower(realname) LIKE $2',
- array ($search,
- strtolower("%$search%")));
- } else {
- $result = db_query_params ('SELECT DISTINCT * FROM users
-WHERE lower(user_name) LIKE $1
-OR lower(email) LIKE $1
-OR lower(realname) LIKE $1',
- array (strtolower("%$search%")));
- }
+ $result = db_query_params ('SELECT DISTINCT * FROM users
+ WHERE cast(user_id as text) LIKE $1
+ OR lower(user_name) LIKE $1
+ OR lower(email) LIKE $1
+ OR lower(realname) LIKE $1',
+ array (strtolower("%$search%")));
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>';
- if (db_numrows($result) < 1) {
-
- exit_error(db_error(),'admin');
-
- } else {
-
+ if (db_numrows($result) >= 1) {
$title=array();
$title[]=_('ID');
$title[]=_('User name');
$title[]=_('Email');
$title[]=_('Member since');
$title[]=_('Status');
-
+
echo $GLOBALS['HTML']->listTableTop($title);
$i = 0 ;
while ($row = db_fetch_array($result)) {
<td>'.$row['realname'].'</td>
<td>'.$row['email'].'</td>
<td>'.date(_('Y-m-d H:i'), $row['add_date']).'</td>
- <td style="text-align:center">'.format_name($row['status'].'/'.$row['unix_status'], $row['status']).'</td>
+ <td class="align-center">'.format_name($row['status'].'/'.$row['unix_status'], $row['status']).'</td>
</tr>
- ';
+ ';
}
echo $GLOBALS['HTML']->listTableBottom();
-
- }
+ } else {
+ echo '<p class="information">'._('No user found.').'</p>';
+ }
} // end if ($usersearch)
if (getStringFromRequest('groupsearch')) {
$status = getStringFromRequest('status');
$is_public = getIntFromRequest('is_public', -1);
- $crit_desc = '' ;
+ $crit_desc = '';
$qpa = db_construct_qpa () ;
-
+
if(is_numeric($search)) {
$qpa = db_construct_qpa ($qpa, 'SELECT DISTINCT * FROM groups
-WHERE (group_id=$1 OR lower (unix_group_name) LIKE $2 OR lower (group_name) LIKE $2)',
+ WHERE (group_id=$1 OR lower (unix_group_name) LIKE $2 OR lower (group_name) LIKE $2)',
array ($search,
strtolower ("%$search%"))) ;
} else {
}
$result = db_query_qpa ($qpa) ;
- if (db_numrows($result) < 1) {
- echo db_error();
- } else {
-
+ if (db_numrows($result) >= 1) {
$rows = array();
$ra = RoleAnonymous::getInstance() ;
while ($row = db_fetch_array($result)) {
-
+
if ($is_public == 1) {
if ($ra->hasPermission('project_read', $row['group_id'])) {
$rows[] = $row;
$rows[] = $row;
}
}
-
+
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>';
$title=array();
if (!$ra->hasPermission('project_read', $row['group_id'])) {
$extra_status = "/PRV";
}
-
+
print '
<tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
<td><a href="groupedit.php?group_id='.$row['group_id'].'">'.$row['group_id'].'</a></td>
<td>'.format_name($row['unix_group_name'], $row['status']).'</td>
<td>'.$row['group_name'].'</td>
<td>'.date(_('Y-m-d H:i'), $row['register_time']).'</td>
- <td style="text-align:center">'.format_name($row['status'].$extra_status, $row['status']).'</td>
+ <td class="align-center">'.format_name($row['status'].$extra_status, $row['status']).'</td>
</tr>
';
-
- }
-
- echo $GLOBALS['HTML']->listTableBottom();
-
- }
+ }
+ echo $GLOBALS['HTML']->listTableBottom();
+ } else {
+ echo '<p class="information">'._('No project found.').'</p>';
+ }
} //end if($groupsearch)
site_admin_footer(array());
// mode: php
// c-file-style: "bsd"
// End:
-
-?>