mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
Inherit hide download from share attributes
When resharing by link, if the download permission was removed through share attributes, convert it to the hide download flag. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
parent
3cfb4cbf94
commit
bbb5043c07
2 changed files with 29 additions and 0 deletions
|
|
@ -47,6 +47,7 @@ namespace OCA\Files_Sharing\Controller;
|
|||
use OC\Files\FileInfo;
|
||||
use OCA\Files_Sharing\Exceptions\SharingRightsException;
|
||||
use OCA\Files_Sharing\External\Storage;
|
||||
use OCA\Files_Sharing\SharedStorage;
|
||||
use OCA\Files\Helper;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
|
|
@ -549,6 +550,14 @@ class ShareAPIController extends OCSController {
|
|||
throw new OCSNotFoundException($this->l->t('Public link sharing is disabled by the administrator'));
|
||||
}
|
||||
|
||||
if ($share->getNode()->getStorage()->instanceOfStorage(SharedStorage::class)) {
|
||||
/** @var \OCA\Files_Sharing\SharedStorage $storage */
|
||||
$inheritedAttributes = $share->getNode()->getStorage()->getShare()->getAttributes();
|
||||
if ($inheritedAttributes !== null && $inheritedAttributes->getAttribute('permissions', 'download') === false) {
|
||||
$share->setHideDownload(true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($publicUpload === 'true') {
|
||||
// Check if public upload is allowed
|
||||
if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
|
||||
|
|
@ -1125,6 +1134,24 @@ class ShareAPIController extends OCSController {
|
|||
$share->setHideDownload(false);
|
||||
}
|
||||
|
||||
$userFolder = $this->rootFolder->getUserFolder($this->currentUser);
|
||||
// get the node with the point of view of the current user
|
||||
$nodes = $userFolder->getById($share->getNode()->getId());
|
||||
if (count($nodes) > 0) {
|
||||
$node = $nodes[0];
|
||||
$storage = $node->getStorage();
|
||||
if ($storage->instanceOfStorage(SharedStorage::class)) {
|
||||
/** @var \OCA\Files_Sharing\SharedStorage $storage */
|
||||
$inheritedAttributes = $storage->getShare()->getAttributes();
|
||||
if ($inheritedAttributes !== null && $inheritedAttributes->getAttribute('permissions', 'download') === false) {
|
||||
if ($hideDownload === 'false') {
|
||||
throw new OCSBadRequestException($this->l->t('Cannot increate permissions'));
|
||||
}
|
||||
$share->setHideDownload(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$newPermissions = null;
|
||||
if ($publicUpload === 'true') {
|
||||
$newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE;
|
||||
|
|
|
|||
|
|
@ -175,6 +175,8 @@ class DefaultShareProvider implements IShareProvider {
|
|||
if (method_exists($share, 'getParent')) {
|
||||
$qb->setValue('parent', $qb->createNamedParameter($share->getParent()));
|
||||
}
|
||||
|
||||
$qb->setValue('hide_download', $qb->createNamedParameter($share->getHideDownload() ? 1 : 0, IQueryBuilder::PARAM_INT));
|
||||
} else {
|
||||
throw new \Exception('invalid share type!');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue