summaryrefslogtreecommitdiffstats
path: root/lib/user
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-01-31 12:09:42 +0100
committerBjörn Schießle <schiessle@owncloud.com>2013-01-31 12:09:42 +0100
commit9a19c0af4b6a74f1578c8d86d4ef445a6ca132c2 (patch)
treea0ef116a5219590ad7624f864f418b5593ea4b21 /lib/user
parent00a30e665128352e9b20268ea65400a968903c74 (diff)
downloadnextcloud-server-9a19c0af4b6a74f1578c8d86d4ef445a6ca132c2.tar.gz
nextcloud-server-9a19c0af4b6a74f1578c8d86d4ef445a6ca132c2.zip
search for display name and uid (with no display name) since it is possible that not all users have a seperate display name
Diffstat (limited to 'lib/user')
-rw-r--r--lib/user/database.php20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/user/database.php b/lib/user/database.php
index 7deeb0c4697..a9ec7b1bfe8 100644
--- a/lib/user/database.php
+++ b/lib/user/database.php
@@ -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;
}