Skip to content

Commit

Permalink
checking download attribute to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Antipkin-A committed Sep 9, 2022
1 parent 8cf64d0 commit 540eff4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions controller/editorapicontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit 540eff4

Please sign in to comment.