|
|
@ -21,49 +21,48 @@ require_once ('xajax/xajax.inc.php'); |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class Accessurledituserstourl |
|
|
|
class Accessurledituserstourl |
|
|
|
{ |
|
|
|
{ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Search users by username, firstname or lastname, based on the given |
|
|
|
* Search users by username, firstname or lastname, based on the given |
|
|
|
* search string |
|
|
|
* search string |
|
|
|
* @param string Search string |
|
|
|
* @param string Search string |
|
|
|
* @param int Deprecated param |
|
|
|
* @param int Deprecated param |
|
|
|
* @return string Xajax response block |
|
|
|
* @return string Xajax response block |
|
|
|
* @assert () === false |
|
|
|
* @assert () === false |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function search_users($needle, $id) |
|
|
|
function search_users($needle, $id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
global $tbl_user, $tbl_access_url_rel_user; |
|
|
|
global $tbl_user, $tbl_access_url_rel_user; |
|
|
|
$xajax_response = new XajaxResponse(); |
|
|
|
$xajax_response = new XajaxResponse(); |
|
|
|
$return = ''; |
|
|
|
$return = ''; |
|
|
|
|
|
|
|
|
|
|
|
if(!empty($needle)) { |
|
|
|
if (!empty($needle)) { |
|
|
|
// xajax send utf8 datas... datas in db can be non-utf8 datas |
|
|
|
// xajax send utf8 datas... datas in db can be non-utf8 datas |
|
|
|
$charset = api_get_system_encoding(); |
|
|
|
$charset = api_get_system_encoding(); |
|
|
|
$needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
|
|
$needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
|
|
$needle = Database::escape_string($needle); |
|
|
|
$needle = Database::escape_string($needle); |
|
|
|
// search users where username or firstname or lastname begins likes $needle |
|
|
|
// search users where username or firstname or lastname begins likes $needle |
|
|
|
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; |
|
|
|
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; |
|
|
|
$sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u |
|
|
|
$sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u '. |
|
|
|
WHERE (username LIKE "'.$needle.'%" |
|
|
|
' WHERE (username LIKE "'.$needle.'%" '. |
|
|
|
OR firstname LIKE "'.$needle.'%" |
|
|
|
' OR firstname LIKE "'.$needle.'%" '. |
|
|
|
OR lastname LIKE "'.$needle.'%")'. |
|
|
|
' OR lastname LIKE "'.$needle.'%") '. |
|
|
|
$order_clause. |
|
|
|
$order_clause . |
|
|
|
' LIMIT 11'; |
|
|
|
' LIMIT 11'; |
|
|
|
|
|
|
|
|
|
|
|
$rs = Database::query($sql); |
|
|
|
$rs = Database::query($sql); |
|
|
|
$i=0; |
|
|
|
$i=0; |
|
|
|
|
|
|
|
|
|
|
|
while ($user = Database :: fetch_array($rs)) { |
|
|
|
|
|
|
|
$i++; |
|
|
|
|
|
|
|
if ($i<=10) { |
|
|
|
|
|
|
|
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($user['user_id']).'\',\''.api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])).' ('.addslashes($user['username']).')'.'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />'; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$return .= '...<br />'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return)); |
|
|
|
|
|
|
|
return $xajax_response; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ($user = Database :: fetch_array($rs)) { |
|
|
|
|
|
|
|
$i++; |
|
|
|
|
|
|
|
if ($i<=10) { |
|
|
|
|
|
|
|
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($user['user_id']).'\',\''.api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])).' ('.addslashes($user['username']).')'.'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />'; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$return .= '...<br />'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return)); |
|
|
|
|
|
|
|
return $xajax_response; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
?> |
|
|
|
|
|
|
|