diff options
-rw-r--r-- | lib/AppInfo/Application.php | 3 | ||||
-rw-r--r-- | lib/Listener/BeforeFilesAppTemplateRenderedListener.php | 73 | ||||
-rw-r--r-- | lib/Listener/BeforeTemplateRenderedListener.php | 45 |
3 files changed, 44 insertions, 77 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 333df9f2..95ecc213 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -25,7 +25,6 @@ namespace OCA\FirstRunWizard\AppInfo; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\FirstRunWizard\Listener\AppEnabledListener; -use OCA\FirstRunWizard\Listener\BeforeFilesAppTemplateRenderedListener; use OCA\FirstRunWizard\Listener\BeforeTemplateRenderedListener; use OCA\FirstRunWizard\Notification\Notifier; use OCP\App\ManagerEvent; @@ -44,8 +43,6 @@ class Application extends App implements IBootstrap { public function register(IRegistrationContext $context): void { $context->registerEventListener(ManagerEvent::EVENT_APP_ENABLE, AppEnabledListener::class); $context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class); - // Display the first run wizard only on the files app, - $context->registerEventListener(LoadAdditionalScriptsEvent::class, BeforeFilesAppTemplateRenderedListener::class); } public function boot(IBootContext $context): void { diff --git a/lib/Listener/BeforeFilesAppTemplateRenderedListener.php b/lib/Listener/BeforeFilesAppTemplateRenderedListener.php deleted file mode 100644 index 5730c6d8..00000000 --- a/lib/Listener/BeforeFilesAppTemplateRenderedListener.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php - -declare(strict_types=1); - -/** - * @copyright Copyright (c) 2020 Morris Jobke <hey@morrisjobke.de> - * - * @author Morris Jobke <hey@morrisjobke.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -namespace OCA\FirstRunWizard\Listener; - -use OCA\FirstRunWizard\Notification\AppHint; -use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; -use OCP\BackgroundJob\IJobList; -use OCP\EventDispatcher\Event; -use OCP\EventDispatcher\IEventListener; -use OCP\IConfig; -use OCP\IUser; -use OCP\IUserSession; - -class BeforeFilesAppTemplateRenderedListener implements IEventListener { - /** @var IUserSession */ - private $userSession; - /** @var IConfig */ - private $config; - /** @var AppHint */ - private $appHint; - /** @var IJobList */ - private $jobList; - - public function __construct( - IConfig $config, - IUserSession $userSession, - IJobList $jobList, - AppHint $appHint - ) { - $this->userSession = $userSession; - $this->config = $config; - $this->appHint = $appHint; - $this->jobList = $jobList; - } - - public function handle(Event $event): void { - $user = $this->userSession->getUser(); - if (!$user instanceof IUser) { - return; - } - - if ($this->config->getUserValue($user->getUID(), 'firstrunwizard', 'show', '1') !== '0') { - \OC_Util::addScript('firstrunwizard', 'activate'); - - $this->jobList->add('OCA\FirstRunWizard\Notification\BackgroundJob', ['uid' => $this->userSession->getUser()->getUID()]); - } - $this->appHint->sendAppHintNotifications(); - } -} diff --git a/lib/Listener/BeforeTemplateRenderedListener.php b/lib/Listener/BeforeTemplateRenderedListener.php index 0de4b845..d3d14cfa 100644 --- a/lib/Listener/BeforeTemplateRenderedListener.php +++ b/lib/Listener/BeforeTemplateRenderedListener.php @@ -26,12 +26,43 @@ declare(strict_types=1); namespace OCA\FirstRunWizard\Listener; +use OCA\FirstRunWizard\Notification\AppHint; use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; +use OCP\BackgroundJob\IJobList; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; +use OCP\IConfig; +use OCP\IUser; +use OCP\IUserSession; class BeforeTemplateRenderedListener implements IEventListener { - public function __construct() { + /** + * @var IUserSession + */ + private $userSession; + /** + * @var IConfig + */ + private $config; + /** + * @var AppHint + */ + private $appHint; + /** + * @var IJobList + */ + private $jobList; + + public function __construct( + IConfig $config, + IUserSession $userSession, + IJobList $jobList, + AppHint $appHint + ) { + $this->userSession = $userSession; + $this->config = $config; + $this->appHint = $appHint; + $this->jobList = $jobList; } public function handle(Event $event): void { @@ -39,6 +70,18 @@ class BeforeTemplateRenderedListener implements IEventListener { return; } + $user = $this->userSession->getUser(); + if (!$user instanceof IUser) { + return; + } + + if ($this->config->getUserValue($user->getUID(), 'firstrunwizard', 'show', '1') !== '0') { + \OC_Util::addScript('firstrunwizard', 'activate'); + + $this->jobList->add('OCA\FirstRunWizard\Notification\BackgroundJob', ['uid' => $this->userSession->getUser()->getUID()]); + } + $this->appHint->sendAppHintNotifications(); + \OC_Util::addScript('firstrunwizard', 'about'); } } |