local user backend shall search for both username and displayname, fixes #5401
This commit is contained in:
parent
e0f5fa9ea7
commit
466b6c1ee0
1 changed files with 3 additions and 14 deletions
|
@ -156,25 +156,14 @@ class OC_User_Database extends OC_User_Backend {
|
||||||
public function getDisplayNames($search = '', $limit = null, $offset = null) {
|
public function getDisplayNames($search = '', $limit = null, $offset = null) {
|
||||||
$displayNames = array();
|
$displayNames = array();
|
||||||
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
|
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
|
||||||
.' WHERE LOWER(`displayname`) LIKE LOWER(?)', $limit, $offset);
|
.' WHERE LOWER(`displayname`) LIKE LOWER(?) OR '
|
||||||
$result = $query->execute(array($search.'%'));
|
.'LOWER(`uid`) LIKE LOWER(?)', $limit, $offset);
|
||||||
|
$result = $query->execute(array($search.'%', $search.'%'));
|
||||||
$users = array();
|
$users = array();
|
||||||
while ($row = $result->fetchRow()) {
|
while ($row = $result->fetchRow()) {
|
||||||
$displayNames[$row['uid']] = $row['displayname'];
|
$displayNames[$row['uid']] = $row['displayname'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// let's see if we can also find some users who don't have a display name yet
|
|
||||||
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
|
|
||||||
.' WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset);
|
|
||||||
$result = $query->execute(array($search.'%'));
|
|
||||||
while ($row = $result->fetchRow()) {
|
|
||||||
$displayName = trim($row['displayname'], ' ');
|
|
||||||
if ( empty($displayName) ) {
|
|
||||||
$displayNames[$row['uid']] = $row['uid'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return $displayNames;
|
return $displayNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue