Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit be8cc3e3 authored by Akhil's avatar Akhil
Browse files

Add check for if OO is enabled

parent 9135efd9
Loading
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -8,18 +8,22 @@ use \OCP\EventDispatcher\IEventListener;
use OCP\Util;
use OCP\IUserSession;
use OCP\IRequest;
use OCP\App\IAppManager;

class BeforeTemplateRenderedListener implements IEventListener {
	private $util;
	private $userSession;
	private $request;
	private $appName;
	private Util $util;
	private IUserSession $userSession;
	private IRequest $request;
	private string $appName;
	private IAppManager $appManager;
	private const ONLYOFFICE_APP_ID = 'onlyoffice';

	public function __construct($appName, Util $util, IUserSession $userSession, IRequest $request) {
	public function __construct($appName, Util $util, IUserSession $userSession, IRequest $request, IAppManager $appManager) {
		$this->appName = $appName;
		$this->util = $util;
		$this->userSession = $userSession;
		$this->request = $request;
		$this->appManager = $appManager;
	}
	public function handle(Event $event): void {
		if (!($event instanceof BeforeTemplateRenderedEvent)) {
@@ -28,9 +32,12 @@ class BeforeTemplateRenderedListener implements IEventListener {
		$pathInfo = $this->request->getPathInfo();
		if ($this->userSession->isLoggedIn()) {
			$this->util->addStyle($this->appName, 'icons');
			$this->util->addScript($this->appName, $this->appName . '-onlyoffice-handler');
			$this->util->addScript($this->appName, $this->appName . '-unified-search-encryption-message');
			$this->util->addStyle($this->appName, 'unified-search-encryption-message');

			if($this->appManager->isEnabledForUser(self::ONLYOFFICE_APP_ID)) {			
				$this->util->addScript($this->appName, $this->appName . '-onlyoffice-handler');
			}
		}
		if (strpos($pathInfo, '/apps/files/') !== false) {
			$this->util->addStyle($this->appName, 'files');