]> source.dussan.org Git - nextcloud-server.git/commitdiff
search for display name and uid (with no display name) since it is possible that...
authorBjörn Schießle <schiessle@owncloud.com>
Thu, 31 Jan 2013 11:09:42 +0000 (12:09 +0100)
committerBjörn Schießle <schiessle@owncloud.com>
Thu, 31 Jan 2013 11:09:42 +0000 (12:09 +0100)
lib/user/database.php

index 7deeb0c4697b1320cbd599a240e1c92be0a8920e..a9ec7b1bfe806bcaaab2119e1861fd34e7d62ec4 100644 (file)
@@ -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);\r
-               $result = $query->execute(array($search.'%'));\r
+               $result = $query->execute(array($search.'%'));
                $users = array();\r
-               while ($row = $result->fetchRow()) {
-                       $displayName =  trim($row['displayname'], ' ');\r
-                       $displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;\r
-               }\r
+               while ($row = $result->fetchRow()) {\r
+                       $displayNames[$row['uid']] = $row['displayname'];\r
+               }
+               
+               // 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);\r
+               $result = $query->execute(array($search.'%'));
+               while ($row = $result->fetchRow()) {\r
+                       $displayName =  trim($row['displayname'], ' ');
+                       if ( empty($displayName) )\r
+                       $displayNames[$row['uid']] = $row['uid'];\r
+               }
+               
+               \r
                return $displayNames;\r
        }