diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-04-17 16:44:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-17 16:44:52 +0300 |
commit | 44719a45d401426dce60a6b92200edceb9503836 (patch) | |
tree | 812387b416e1c665c2578d811b1e4e883c67e75c /lib | |
parent | 83cfbe2e451abfbad3468ea50f3c08865aafae67 (diff) | |
parent | c7e922262180f05891bb32426e2743bf257e2911 (diff) |
Merge pull request #475 from nextcloud/feature/447/hide-download
Implement hide download support for public shares
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/WopiController.php | 5 | ||||
-rw-r--r-- | lib/Db/Wopi.php | 4 | ||||
-rw-r--r-- | lib/Db/WopiMapper.php | 3 | ||||
-rw-r--r-- | lib/TokenManager.php | 3 |
4 files changed, 12 insertions, 3 deletions
diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index 0156c20c..d7619947 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -154,7 +154,10 @@ class WopiController extends Controller { 'LastModifiedTime' => Helper::toISO8601($file->getMTime()), 'EnableInsertRemoteImage' => true, 'EnableShare' => true, - 'HideUserList' => 'desktop' + 'HideUserList' => 'desktop', + 'DisablePrint' => $wopi->getHideDownload(), + 'DisableExport' => $wopi->getHideDownload(), + 'DisableCopy' => $wopi->getHideDownload() ]; if ($wopi->isTemplateToken()) { diff --git a/lib/Db/Wopi.php b/lib/Db/Wopi.php index 941e241b..0c35dacf 100644 --- a/lib/Db/Wopi.php +++ b/lib/Db/Wopi.php @@ -81,6 +81,9 @@ class Wopi extends Entity { /** @var int */ protected $templateDestination; + /** @var bool */ + protected $hideDownload; + public function __construct() { $this->addType('owner_uid', 'string'); $this->addType('editor_uid', 'string'); @@ -92,6 +95,7 @@ class Wopi extends Entity { $this->addType('expiry', 'int'); $this->addType('guest_displayname', 'string'); $this->addType('templateDestination', 'int'); + $this->addType('hide_download', 'bool'); } public function isTemplateToken() { diff --git a/lib/Db/WopiMapper.php b/lib/Db/WopiMapper.php index 01dfded3..f14df181 100644 --- a/lib/Db/WopiMapper.php +++ b/lib/Db/WopiMapper.php @@ -64,7 +64,7 @@ class WopiMapper extends Mapper { * @param int $templateDestination * @return Wopi */ - public function generateFileToken($fileId, $owner, $editor, $version, $updatable, $serverHost, $guestDisplayname, $templateDestination = 0) { + public function generateFileToken($fileId, $owner, $editor, $version, $updatable, $serverHost, $guestDisplayname, $templateDestination = 0, $hideDownload = false) { $token = $this->random->generate(32, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS); $wopi = Wopi::fromParams([ @@ -78,6 +78,7 @@ class WopiMapper extends Mapper { 'expiry' => $this->timeFactory->getTime() + self::TOKEN_LIFETIME_SECONDS, 'guestDisplayname' => $guestDisplayname, 'templateDestination' => $templateDestination, + 'hideDownload' => $hideDownload ]); /** @var Wopi $wopi */ diff --git a/lib/TokenManager.php b/lib/TokenManager.php index 1267569a..a332aced 100644 --- a/lib/TokenManager.php +++ b/lib/TokenManager.php @@ -94,6 +94,7 @@ class TokenManager { $rootFolder = $this->rootFolder; $share = $this->shareManager->getShareByToken($shareToken); $updatable = (bool)($share->getPermissions() & \OCP\Constants::PERMISSION_UPDATE); + $hideDownload = $share->getHideDownload(); $owneruid = $share->getShareOwner(); } else if (!is_null($this->userId)) { try { @@ -156,7 +157,7 @@ class TokenManager { $guest_name = NULL; } - $wopi = $this->wopiMapper->generateFileToken($fileId, $owneruid, $editoruid, $version, (int)$updatable, $serverHost, $guest_name); + $wopi = $this->wopiMapper->generateFileToken($fileId, $owneruid, $editoruid, $version, (int)$updatable, $serverHost, $guest_name, 0, $hideDownload); try { |