diff options
author | Daniel Rudolf <github.com@daniel-rudolf.de> | 2020-05-21 13:18:39 +0300 |
---|---|---|
committer | Daniel Rudolf <github.com@daniel-rudolf.de> | 2020-05-21 13:18:39 +0300 |
commit | db4caaf2aee8b437798cb7388c59335263e6c063 (patch) | |
tree | 41f47e56d2714ea97522519c9c1180f4af7ef7cd /lib | |
parent | ac41ca22a310c341bbdd7ed79a6d9ea8f4b1c442 (diff) |
Add Room::searchParticipants()
Signed-off-by: Daniel Rudolf <github.com@daniel-rudolf.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Room.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/Room.php b/lib/Room.php index d087a2112..ef0be8f5b 100644 --- a/lib/Room.php +++ b/lib/Room.php @@ -1016,6 +1016,41 @@ class Room { } /** + * @param string $searchUserId + * @param int $limit + * @param int $offset + * @return Participant[] + */ + public function searchParticipants(string $searchUserId = '', int $limit = null, int $offset = null): array { + $query = $this->db->getQueryBuilder(); + $query->select('*') + ->from('talk_participants') + ->where($query->expr()->eq('room_id', $query->createNamedParameter($this->getId()))); + + if ($searchUserId !== '') { + $query->where($query->expr()->iLike('user_id', $query->createNamedParameter( + '%' . $this->db->escapeLikeParameter($searchUserId) . '%' + ))); + } + + $query->setMaxResults($limit) + ->setFirstResult($offset); + $result = $query->execute(); + + $participants = []; + while ($row = $result->fetch()) { + $participants[] = $this->manager->createParticipantObject($this, $row); + } + $result->closeCursor(); + + uasort($participants, function (Participant $a, Participant $b) { + return strcasecmp($a->getUser(), $b->getUser()); + }); + + return $participants; + } + + /** * @return Participant[] */ public function getParticipantsInCall(): array { |