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 | |
parent | 83cfbe2e451abfbad3468ea50f3c08865aafae67 (diff) | |
parent | c7e922262180f05891bb32426e2743bf257e2911 (diff) |
Merge pull request #475 from nextcloud/feature/447/hide-download
Implement hide download support for public shares
-rw-r--r-- | appinfo/database.xml | 6 | ||||
-rw-r--r-- | appinfo/info.xml | 2 | ||||
-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 |
6 files changed, 19 insertions, 4 deletions
diff --git a/appinfo/database.xml b/appinfo/database.xml index 9d19a070..1a33e72f 100644 --- a/appinfo/database.xml +++ b/appinfo/database.xml @@ -130,6 +130,12 @@ <notnull>false</notnull> <length>4</length> </field> + <field> + <name>hide_download</name> + <type>boolean</type> + <default>false</default> + <notnull>true</notnull> + </field> <index> <name>rd_wopi_token_idx</name> diff --git a/appinfo/info.xml b/appinfo/info.xml index cde1ff4c..37406a09 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -4,7 +4,7 @@ <name>Collabora Online</name> <summary>Edit office documents directly in your browser.</summary> <description>This application can connect to a Collabora Online server (WOPI Client). Nextcloud is the WOPI Host. Please read the documentation to learn more about that.</description> - <version>3.2.4</version> + <version>3.2.4-1</version> <licence>agpl</licence> <author>Collabora Productivity based on work of Frank Karlitschek, Victor Dubiniuk</author> <types> 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 { |