diff --git a/appinfo/app.php b/appinfo/app.php
deleted file mode 100644
index 5d929ce..0000000
--- a/appinfo/app.php
+++ /dev/null
@@ -1,5 +0,0 @@
-query(\OCA\BigBlueButton\AppInfo\Application::class);
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 0b65fae..2bb9f3b 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -15,19 +15,25 @@ 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\AppFramework\QueryException;
+use \OCP\AppFramework\Bootstrap\IBootContext;
+use \OCP\AppFramework\Bootstrap\IBootstrap;
+use \OCP\AppFramework\Bootstrap\IRegistrationContext;
use \OCP\EventDispatcher\IEventDispatcher;
use \OCP\IConfig;
use \OCP\Settings\IManager as ISettingsManager;
use \OCP\User\Events\UserDeletedEvent;
+use \OCP\Util;
if ((@include_once __DIR__ . '/../../vendor/autoload.php') === false) {
throw new \Exception('Cannot include autoload. Did you run install dependencies using composer?');
}
-class Application extends App {
+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 +56,14 @@ class Application extends App {
} else {
$this->registerAsPersonalSetting();
}
+
+ Util::addScript('bbb', 'filelist');
+ }
+
+ public function boot(IBootContext $context): void {}
+
+ public function register(IRegistrationContext $context): void {
+ $context->registerSearchProvider(Provider::class);
}
private function registerAsPersonalSetting(): void {
@@ -77,7 +91,7 @@ class Application extends App {
$server->getNavigationManager()->add(function () use ($server, $name) {
return [
'id' => self::ID,
- 'order' => 80,
+ 'order' => self::ORDER,
'href' => $server->getURLGenerator()->linkToRoute('bbb.page.index'),
'icon' => $server->getURLGenerator()->imagePath('bbb', 'app.svg'),
'name' => $name,
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..615aaf3
--- /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 = array_map(function(Room $room) {
+ return [
+ new SearchResultEntry(
+ '',
+ $room->getName(),
+ $this->getAccess($room->getAccess()),
+ $this->urlGenerator->linkToRoute('bbb.page.index'),
+ $this->urlGenerator->imagePath('bbb', 'app-grey.svg')
+ )
+ ];
+ }, $rooms);
+
+ return SearchResult::complete(
+ 'BBB',
+ $results
+ );
+ }
+}
\ No newline at end of file
diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php
index d8e42b6..181a24e 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 {
@@ -85,6 +87,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();