Merge pull request #1390 from schiesbn/search_display_name_and_uid
Search display name and uid
This commit is contained in:
commit
13165bbea2
2 changed files with 18 additions and 14 deletions
|
@ -219,21 +219,14 @@ class OC_Group_Database extends OC_Group_Backend {
|
|||
*/
|
||||
public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||
$displayNames = '';
|
||||
/*
|
||||
|
||||
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
|
||||
FROM Persons
|
||||
INNER JOIN Orders
|
||||
ON Persons.P_Id=Orders.P_Id
|
||||
ORDER BY Persons.LastName
|
||||
*/
|
||||
|
||||
$stmt = OC_DB::prepare('SELECT `*PREFIX*users`.`uid`, `*PREFIX*users`.`displayname` FROM `*PREFIX*users` INNER JOIN `*PREFIX*group_user` ON `*PREFIX*group_user`.`uid` = `*PREFIX*users`.`uid` WHERE `gid` = ? AND `*PREFIX*group_user.uid` LIKE ?', $limit, $offset);
|
||||
$result = $stmt->execute(array($gid, $search.'%'));
|
||||
$users = array();
|
||||
while ($row = $result->fetchRow()) {
|
||||
$displayName = trim($row['displayname'], ' ');
|
||||
$displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;
|
||||
}
|
||||
}
|
||||
return $displayNames;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,12 +156,23 @@ 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