From 533d310b1b71b59e6ecd01dd2fc32de0e25f7b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 8 May 2024 12:18:19 +0200 Subject: [PATCH] fix: Avoid loading file actions if app is disabled for users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Listener/LoadAdditionalListener.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Listener/LoadAdditionalListener.php b/lib/Listener/LoadAdditionalListener.php index 3ed0f56b10..2e4e09a274 100644 --- a/lib/Listener/LoadAdditionalListener.php +++ b/lib/Listener/LoadAdditionalListener.php @@ -3,6 +3,7 @@ namespace OCA\Richdocuments\Listener; use OCA\Richdocuments\AppInfo\Application; +use OCA\Richdocuments\PermissionManager; use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; @@ -10,14 +11,18 @@ /** @template-implements IEventListener */ class LoadAdditionalListener implements IEventListener { + public function __construct( + private PermissionManager $permissionManager, + private ?string $userId, + ) { + } + public function handle(Event $event): void { - // If not a LoadAdditionalScriptsEvent, we should do nothing if (!($event instanceof LoadAdditionalScriptsEvent)) { return; } - // If we can add an init script, we add the file-actions script - if (method_exists(Util::class, 'addInitScript')) { + if ($this->permissionManager->isEnabledForUser() && $this->userId !== null) { Util::addInitScript(Application::APPNAME, 'richdocuments-fileActions'); } }