mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
search for display name and uid (with no display name) since it is possible that not all users have a seperate display name
This commit is contained in:
parent
00a30e6651
commit
9a19c0af4b
1 changed files with 15 additions and 5 deletions
|
|
@ -156,12 +156,22 @@ class OC_User_Database extends OC_User_Backend {
|
|||
public function getDisplayNames($search = '', $limit = null, $offset = null) {
|
||||
$displayNames = array();
|
||||
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`displayname`) LIKE LOWER(?)', $limit, $offset);
|
||||
$result = $query->execute(array($search.'%'));
|
||||
$result = $query->execute(array($search.'%'));
|
||||
$users = array();
|
||||
while ($row = $result->fetchRow()) {
|
||||
$displayName = trim($row['displayname'], ' ');
|
||||
$displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;
|
||||
}
|
||||
while ($row = $result->fetchRow()) {
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue