Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Rudolf <github.com@daniel-rudolf.de>2020-05-13 22:27:33 +0300
committerDaniel Rudolf <github.com@daniel-rudolf.de>2020-05-13 22:27:33 +0300
commita6d0d02d1d70e25a1d07b666cefb65aff0fcbb45 (patch)
tree087bec2f8c261b07ac4526459aea7ce6f7321ebb /lib
parent349793e11d25b77e58a6e63798c0673e73f8d647 (diff)
Add Manager::searchRoomsByToken()
Signed-off-by: Daniel Rudolf <github.com@daniel-rudolf.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/Manager.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/Manager.php b/lib/Manager.php
index aa539299b..c937262c9 100644
--- a/lib/Manager.php
+++ b/lib/Manager.php
@@ -225,6 +225,42 @@ 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('r.*')
+ ->from('talk_rooms', 'r')
+ ->setMaxResults(1);
+
+ if ($searchToken !== '') {
+ $query->where($query->expr()->iLike('r.token', $query->createNamedParameter(
+ $this->db->escapeLikeParameter($searchToken) . '%'
+ )));
+ }
+
+ $query->setMaxResults($limit)
+ ->setFirstResult($offset);
+ $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[]