2020-04-26 11:36:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace OCA\BigBlueButton\AppInfo;
|
|
|
|
|
2020-08-26 10:57:31 +02:00
|
|
|
use \OCP\IConfig;
|
2020-09-02 10:07:20 +02:00
|
|
|
use \OCP\Settings\IManager as ISettingsManager;
|
2020-06-04 09:52:49 +02:00
|
|
|
use \OCP\AppFramework\App;
|
2020-09-07 22:18:23 +02:00
|
|
|
use \OCP\EventDispatcher\IEventDispatcher;
|
2020-06-04 09:52:49 +02:00
|
|
|
use \OCA\BigBlueButton\Middleware\JoinMiddleware;
|
2020-09-07 22:18:23 +02:00
|
|
|
use \OCA\BigBlueButton\Event\RoomCreatedEvent;
|
|
|
|
use \OCA\BigBlueButton\Activity\RoomListener;
|
2020-06-04 09:52:49 +02:00
|
|
|
|
2020-04-26 11:36:41 +02:00
|
|
|
if ((@include_once __DIR__ . '/../../vendor/autoload.php') === false) {
|
|
|
|
throw new \Exception('Cannot include autoload. Did you run install dependencies using composer?');
|
|
|
|
}
|
2020-06-04 09:52:49 +02:00
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
class Application extends App {
|
2020-09-07 22:18:23 +02:00
|
|
|
public const ID = 'bbb';
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
public function __construct(array $urlParams = []) {
|
2020-09-07 22:18:23 +02:00
|
|
|
parent::__construct(self::ID, $urlParams);
|
2020-06-04 09:52:49 +02:00
|
|
|
|
|
|
|
$container = $this->getContainer();
|
|
|
|
|
2020-09-07 22:18:23 +02:00
|
|
|
/* @var IEventDispatcher $eventDispatcher */
|
|
|
|
$dispatcher = $container->query(IEventDispatcher::class);
|
|
|
|
$dispatcher->addServiceListener(RoomCreatedEvent::class, RoomListener::class);
|
|
|
|
$dispatcher->addServiceListener(RoomDeletedEvent::class, RoomListener::class);
|
|
|
|
|
2020-06-04 09:52:49 +02:00
|
|
|
$container->registerMiddleWare(JoinMiddleware::class);
|
2020-08-26 10:57:31 +02:00
|
|
|
|
|
|
|
$config = $container->query(IConfig::class);
|
|
|
|
|
2020-09-07 22:18:23 +02:00
|
|
|
if ($config->getAppValue(self::ID, 'app.navigation') === 'true') {
|
2020-08-26 10:57:31 +02:00
|
|
|
$this->registerAsNavigationEntry();
|
|
|
|
} else {
|
|
|
|
$this->registerAsPersonalSetting();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function registerAsPersonalSetting() {
|
|
|
|
$settingsManager = $this->getContainer()->getServer()->getSettingsManager();
|
|
|
|
|
2020-09-02 10:07:20 +02:00
|
|
|
$settingsManager->registerSetting(ISettingsManager::KEY_PERSONAL_SETTINGS, \OCA\BigBlueButton\Settings\Personal::class);
|
2020-08-26 10:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private function registerAsNavigationEntry() {
|
|
|
|
$server = $this->getContainer()->getServer();
|
|
|
|
|
|
|
|
$server->getNavigationManager()->add(function () use ($server) {
|
|
|
|
return [
|
2020-09-07 22:18:23 +02:00
|
|
|
'id' => self::ID,
|
2020-08-26 10:57:31 +02:00
|
|
|
'order' => 80,
|
|
|
|
'href' => $server->getURLGenerator()->linkToRoute('bbb.page.index'),
|
|
|
|
'icon' => $server->getURLGenerator()->imagePath('bbb', 'app.svg'),
|
|
|
|
'name' => 'BigBlueButton',
|
|
|
|
];
|
|
|
|
});
|
2020-06-04 09:52:49 +02:00
|
|
|
}
|
|
|
|
}
|