From 540eff48cc661da02338d44f94c8c467ab5a070f Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Fri, 9 Sep 2022 12:47:52 +0300 Subject: [PATCH] checking download attribute to config --- controller/editorapicontroller.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index ba5f3333..255837b5 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -37,6 +37,7 @@ use OCP\IUserManager; use OCP\IUserSession; use OCP\Share\IManager; +use OCP\Share\IShare; use OCA\Files_Versions\Versions\IVersionManager; use OCA\FilesLock\Service\LockService; @@ -318,6 +319,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok $params["document"]["permissions"]["modifyFilter"] = $permissions_modifyFilter; } + $canDownload = true; $restrictedEditing = false; $fileStorage = $file->getStorage(); if (empty($shareToken) && $fileStorage->instanceOfStorage("\OCA\Files_Sharing\SharedStorage")) { @@ -358,6 +360,14 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok $params["document"]["permissions"]["modifyFilter"] = $modifyFilter; } } + + if (method_exists(IShare::class, "getAttributes")) { + $share = empty($share) ? $fileStorage->getShare() : $share; + $attributes = $share->getAttributes(); + if ($attributes !== null && !$attributes->getAttribute("permissions", "download")) { + $canDownload = false; + } + } } $isTempLock = false; @@ -435,9 +445,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok if (!empty($shareToken)) { if (method_exists($share, "getHideDownload") && $share->getHideDownload()) { - $params["document"]["permissions"]["download"] = false; - $params["document"]["permissions"]["print"] = false; - $params["document"]["permissions"]["copy"] = false; + $canDownload = false; } $node = $share->getNode(); @@ -531,6 +539,12 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok } } + if (!$canDownload) { + $params["document"]["permissions"]["download"] = false; + $params["document"]["permissions"]["print"] = false; + $params["document"]["permissions"]["copy"] = false; + } + if ($inframe === true) { $params["_files_sharing"] = \OC::$server->getAppManager()->isInstalled("files_sharing"); }