Skip to content

Commit

Permalink
Search also the email and displayname in user mangement for groups
Browse files Browse the repository at this point in the history
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Aug 4, 2020
1 parent 0ecef7d commit a0a1a95
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions lib/private/Group/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,27 @@ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$this->fixDI();

$query = $this->dbConn->getQueryBuilder();
$query->select('uid')
->from('group_user')
$query->select('g.uid')
->from('group_user', 'g')
->where($query->expr()->eq('gid', $query->createNamedParameter($gid)))
->orderBy('uid', 'ASC');
->orderBy('g.uid', 'ASC');

if ($search !== '') {
$query->andWhere($query->expr()->like('uid', $query->createNamedParameter(
'%' . $this->dbConn->escapeLikeParameter($search) . '%'
)));
$query->leftJoin('g', 'users', 'u', $query->expr()->eq('g.uid', 'u.uid'))
->leftJoin('u', 'preferences', 'p', $query->expr()->andX(
$query->expr()->eq('userid', 'u.uid'),
$query->expr()->eq('appid', $query->expr()->literal('settings')),
$query->expr()->eq('configkey', $query->expr()->literal('email')))
)
// sqlite doesn't like re-using a single named parameter here
->andWhere(
$query->expr()->orX(
$query->expr()->ilike('g.uid', $query->createNamedParameter('%' . $this->dbConn->escapeLikeParameter($search) . '%')),
$query->expr()->ilike('displayname', $query->createNamedParameter('%' . $this->dbConn->escapeLikeParameter($search) . '%')),
$query->expr()->ilike('configvalue', $query->createNamedParameter('%' . $this->dbConn->escapeLikeParameter($search) . '%'))
)
)
->orderBy('uid_lower', 'ASC');
}

if ($limit !== -1) {
Expand Down

0 comments on commit a0a1a95

Please sign in to comment.