diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2020-06-02 18:03:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-02 18:03:58 +0300 |
commit | 21b0d4655936fcc071cbe5ef9733743e8c7d0262 (patch) | |
tree | 1de2fc687eafc592a1267dfe7414f1199b5aa1f3 /lib/Manager.php | |
parent | d3de4491b4b236bddb20ea4863b08a95a263c003 (diff) | |
parent | 0b13f861f82dd17d2b789f20884b5a4a67c01a6d (diff) |
Merge pull request #3505 from PhrozenByte/feature/cmd-room-followup
Improve talk:room:* CLI commands
Diffstat (limited to 'lib/Manager.php')
-rw-r--r-- | lib/Manager.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/Manager.php b/lib/Manager.php index 43c4bf180..c96e5f2c8 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -225,6 +225,43 @@ class Manager { } /** + * @param string $searchToken + * @param int $limit + * @param int $offset + * @return Room[] + */ + public function searchRoomsByToken(string $searchToken = '', int $limit = null, int $offset = null): array { + $query = $this->db->getQueryBuilder(); + $query->select('*') + ->from('talk_rooms') + ->setMaxResults(1); + + if ($searchToken !== '') { + $query->where($query->expr()->iLike('token', $query->createNamedParameter( + '%' . $this->db->escapeLikeParameter($searchToken) . '%' + ))); + } + + $query->setMaxResults($limit) + ->setFirstResult($offset) + ->orderBy('token', 'ASC'); + $result = $query->execute(); + + $rooms = []; + while ($row = $result->fetch()) { + if ($row['token'] === null) { + // FIXME Temporary solution for the Talk6 release + continue; + } + + $rooms[] = $this->createRoomObject($row); + } + $result->closeCursor(); + + return $rooms; + } + + /** * @param string $participant * @param bool $includeLastMessage * @return Room[] |