Skip to content

Commit

Permalink
Search users by fullname constructed from the lang settings
Browse files Browse the repository at this point in the history
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 d73ff9d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion user/selector/lib.php
Expand Up @@ -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) {
Expand Down

0 comments on commit d73ff9d

Please sign in to comment.