Permalink
Browse files

Search users by fullname constructed from the lang settings

Designed for the langs, such as zh-cn, zh-tw and hu, which don't use the "firstname lastname" style
  • Loading branch information...
sunner committed Jan 25, 2011
1 parent 17e0390 commit d73ff9d3aa82aa14902ea94f1e1f6ab7252c58ab
Showing with 16 additions and 1 deletion.
  1. +16 −1 user/selector/lib.php
View
@@ -422,8 +422,23 @@ protected function search_sql($search, $u) {
// If we have a $search string, put a field LIKE '$search%' condition on each field.
if ($search) {
// Construct SQL fullname from lang defination
$nameordercheck = new stdClass();
$nameordercheck->firstname = 'a';
$nameordercheck->lastname = 'b';
$ordered_fullname = fullname($nameordercheck);
if ($ordered_fullname == 'b a' ) {
$sql = $DB->sql_fullname($u . 'lastname', $u . 'firstname');
} else if ($ordered_fullname == 'a b' ) {
$sql = $DB->sql_fullname($u . 'firstname', $u . 'lastname');
} else if ($ordered_fullname == 'ba' ) { // zh-cn and zh-tw use this style fullname
$sql = $DB->sql_concat($u . 'lastname', $u . 'firstname');
} else {
$sql = $DB->sql_concat($u . 'firstname', $u . 'lastname');
}
$conditions = array(
$DB->sql_fullname($u . 'firstname', $u . 'lastname'),
$sql,
$conditions[] = $u . 'lastname'
);
foreach ($this->extrafields as $field) {

0 comments on commit d73ff9d

Please sign in to comment.