diff --git a/img/app-grey.svg b/img/app-grey.svg
new file mode 100644
index 0000000..6954a97
--- /dev/null
+++ b/img/app-grey.svg
@@ -0,0 +1,72 @@
+
+
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 4c4a6dd..a9d2589 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -15,6 +15,7 @@ use \OCA\BigBlueButton\Event\RoomShareDeletedEvent;
use \OCA\BigBlueButton\Listener\UserDeletedListener;
use \OCA\BigBlueButton\Middleware\HookMiddleware;
use \OCA\BigBlueButton\Middleware\JoinMiddleware;
+use \OCA\BigBlueButton\Search\Provider;
use \OCP\AppFramework\App;
use \OCP\IConfig;
use \OCP\Settings\IManager as ISettingsManager;
@@ -28,6 +29,7 @@ use OCP\Util;
class Application extends App implements IBootstrap {
public const ID = 'bbb';
+ public const ORDER = 80;
public function __construct(array $urlParams = []) {
parent::__construct(self::ID, $urlParams);
@@ -50,6 +52,8 @@ class Application extends App implements IBootstrap {
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
+ $context->registerSearchProvider(Provider::class);
+
$context->registerMiddleware(JoinMiddleware::class);
$context->registerMiddleware(HookMiddleware::class);
}
diff --git a/lib/Db/RoomMapper.php b/lib/Db/RoomMapper.php
index cd9e6d5..4a773e2 100644
--- a/lib/Db/RoomMapper.php
+++ b/lib/Db/RoomMapper.php
@@ -99,4 +99,21 @@ class RoomMapper extends QBMapper {
/** @var array */
return $this->findEntities($qb);
}
+
+ /**
+ * @return array
+ */
+ public function search(string $userId, string $query): array {
+ /* @var $qb IQueryBuilder */
+ $qb = $this->db->getQueryBuilder();
+ $qb->select('*')
+ ->from($this->tableName, 'r')
+ ->where($qb->expr()->eq('r.user_id', $qb->createNamedParameter($userId)))
+ ->andwhere($qb->expr()->ILike('name',
+ $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($query) . '%', IQueryBuilder::PARAM_STR),
+ IQueryBuilder::PARAM_STR));
+
+ /** @var array */
+ return $this->findEntities($qb);
+ }
}
diff --git a/lib/Search/Provider.php b/lib/Search/Provider.php
new file mode 100644
index 0000000..8efb9c1
--- /dev/null
+++ b/lib/Search/Provider.php
@@ -0,0 +1,97 @@
+service = $service;
+ $this->l10n = $l10n;
+ $this->urlGenerator = $urlGenerator;
+ }
+
+ public function getId(): string {
+ return Application::ID;
+ }
+
+ public function getName(): string {
+ return 'BBB';
+ }
+
+ public function getOrder(string $route, array $routeParameters): int {
+ if (strpos($route, Application::ID . '.') === 0) {
+ return -1;
+ }
+ return Application::ORDER;
+ }
+
+ private function getAccess(string $access): string {
+ switch ($access) {
+ case 'public':
+ $translatedAccess = $this->l10n->t('Public');
+ break;
+ case 'password':
+ $translatedAccess = $this->l10n->t('Internal + Password protection for guests');
+ break;
+ case 'waiting_room':
+ $translatedAccess = $this->l10n->t('Internal + Waiting room for guests');
+ break;
+ case 'waiting_room_all':
+ $translatedAccess = $this->l10n->t('Waiting room for all users');
+ break;
+ case 'internal':
+ $translatedAccess = $this->l10n->t('Internal');
+ break;
+ case 'internal_restricted':
+ $translatedAccess = $this->l10n->t('Internal restricted');
+ break;
+ }
+ return $translatedAccess;
+ }
+
+ public function search(IUser $user, ISearchQuery $query): SearchResult {
+ $rooms = $this->service->search(
+ $user,
+ $query
+ );
+
+ $results = [];
+
+ foreach($rooms as $room) {
+ $results[] = new SearchResultEntry(
+ '',
+ $room->getName(),
+ $this->getAccess($room->getAccess()),
+ $this->urlGenerator->linkToRouteAbsolute('bbb.page.index'),
+ $this->urlGenerator->imagePath('bbb', 'app-grey.svg')
+ );
+ }
+
+ return SearchResult::complete(
+ 'BBB',
+ $results
+ );
+ }
+}
\ No newline at end of file
diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php
index b78b066..061e1ff 100644
--- a/lib/Service/RoomService.php
+++ b/lib/Service/RoomService.php
@@ -13,7 +13,9 @@ use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
+use OCP\IUser;
use OCP\Security\ISecureRandom;
+use OCP\Search\ISearchQuery;
class RoomService {
/** @var RoomMapper */
@@ -84,6 +86,13 @@ class RoomService {
return $this->mapper->findByUserId($userId);
}
+ /**
+ * @return array
+ */
+ public function search(IUser $userId, ISearchQuery $query): array {
+ return $this->mapper->search($userId->getUID(), $query->getTerm());
+ }
+
public function create(string $name, string $welcome, int $maxParticipants, bool $record, string $access, string $userId): \OCP\AppFramework\Db\Entity {
$room = new Room();