1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

improved ajax user search (admin) - search by/show email when appropriate

This commit is contained in:
secretr 2012-04-24 11:28:58 +00:00
parent 87d4d6ed22
commit 8bb8b88ca9

View File

@ -27,18 +27,28 @@ function usersearch_shortcode($parm)
{
$search_field = 'user_name';
}
// search by email - based on site settings
$emailSrch = '';
if(e107::getPref('predefinedLoginName'))
{
if($search_field != 'user_email')
{
$emailSrch = " OR user_email LIKE '".$tp->toDb($posted)."%'";
}
}
$ret = "<ul>";
$qry = "
SELECT u.user_id, u.user_name, u.user_loginname, u.user_customtitle, u.user_email FROM #user AS u
WHERE {$search_field} LIKE '".$tp->toDb($posted)."%'
WHERE {$search_field} LIKE '".$tp->toDb($posted)."%'{$emailSrch}
";
if($sql->db_Select_gen($qry))
{
while($row = $sql->db_Fetch())
{
$ret .= "<li id='{$row['user_id']}'>{$row[$search_field]}<span class='informal'> [{$row['user_id']}] ".$row[$info_field]." </span></li>";
if($emailSrch) $info_field = 'user_email';
$ret .= "<li id='{$row['user_id']}'>{$row[$search_field]}<span class='informal'> [{$row['user_id']}] ".$row[$info_field].$email." </span></li>";
}
}
$ret .= "</ul>";