Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/firstrunwizard.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Listener/LoadAdditionalScriptsListener.php')
-rw-r--r--lib/Listener/LoadAdditionalScriptsListener.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/Listener/LoadAdditionalScriptsListener.php b/lib/Listener/LoadAdditionalScriptsListener.php
new file mode 100644
index 00000000..b9bccab3
--- /dev/null
+++ b/lib/Listener/LoadAdditionalScriptsListener.php
@@ -0,0 +1,77 @@
+<?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\Files\Event\LoadAdditionalScriptsEvent;
+use OCA\FirstRunWizard\Notification\AppHint;
+use OCP\BackgroundJob\IJobList;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+use OCP\IConfig;
+use OCP\IUser;
+use OCP\IUserSession;
+
+class LoadAdditionalScriptsListener 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 {
+ if (!($event instanceof LoadAdditionalScriptsEvent)) {
+ 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();
+ }
+}