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'); } }