Implement hide download support for public shares

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2019-04-12 11:33:32 +02:00
Родитель f269b915bd
Коммит c7e9222621
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4C614C6ED2CDE6DF
6 изменённых файлов: 19 добавлений и 4 удалений

Просмотреть файл

@ -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>

Просмотреть файл

@ -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>

Просмотреть файл

@ -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()) {

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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 */

Просмотреть файл

@ -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 {