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
}