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-21 14:51:50 +0300
committerDaniel Rudolf <github.com@daniel-rudolf.de>2020-05-21 14:51:50 +0300
commit9c052b4a066fb45644f5c50662f1d7fae0fb6e46 (patch)
tree0c8c9599cce4ec969443118779e984acca60cca5 /lib
parentbbdfc442f2c2401c514c8160fbaf5fd486c3d2c2 (diff)
Sort results of Manager::searchRoomsByToken() and Room::searchParticipants()
Signed-off-by: Daniel Rudolf <github.com@daniel-rudolf.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/Manager.php11
-rw-r--r--lib/Room.php15
2 files changed, 12 insertions, 14 deletions
diff --git a/lib/Manager.php b/lib/Manager.php
index c937262c9..2c5c0a8dd 100644
--- a/lib/Manager.php
+++ b/lib/Manager.php
@@ -232,18 +232,19 @@ class Manager {
*/
public function searchRoomsByToken(string $searchToken = '', int $limit = null, int $offset = null): array {
$query = $this->db->getQueryBuilder();
- $query->select('r.*')
- ->from('talk_rooms', 'r')
+ $query->select('*')
+ ->from('talk_rooms')
->setMaxResults(1);
if ($searchToken !== '') {
- $query->where($query->expr()->iLike('r.token', $query->createNamedParameter(
- $this->db->escapeLikeParameter($searchToken) . '%'
+ $query->where($query->expr()->iLike('token', $query->createNamedParameter(
+ '%' . $this->db->escapeLikeParameter($searchToken) . '%'
)));
}
$query->setMaxResults($limit)
- ->setFirstResult($offset);
+ ->setFirstResult($offset)
+ ->orderBy('token', 'ASC');
$result = $query->execute();
$rooms = [];
diff --git a/lib/Room.php b/lib/Room.php
index ef0be8f5b..d3e9795af 100644
--- a/lib/Room.php
+++ b/lib/Room.php
@@ -1016,25 +1016,26 @@ class Room {
}
/**
- * @param string $searchUserId
+ * @param string $search
* @param int $limit
* @param int $offset
* @return Participant[]
*/
- public function searchParticipants(string $searchUserId = '', int $limit = null, int $offset = null): array {
+ public function searchParticipants(string $search = '', 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 !== '') {
+ if ($search !== '') {
$query->where($query->expr()->iLike('user_id', $query->createNamedParameter(
- '%' . $this->db->escapeLikeParameter($searchUserId) . '%'
+ '%' . $this->db->escapeLikeParameter($search) . '%'
)));
}
$query->setMaxResults($limit)
- ->setFirstResult($offset);
+ ->setFirstResult($offset)
+ ->orderBy('user_id', 'ASC');
$result = $query->execute();
$participants = [];
@@ -1043,10 +1044,6 @@ class Room {
}
$result->closeCursor();
- uasort($participants, function (Participant $a, Participant $b) {
- return strcasecmp($a->getUser(), $b->getUser());
- });
-
return $participants;
}