mirror of
https://github.com/nextcloud/server.git
synced 2026-03-21 10:00:33 -04:00
feat(share): provide canDownload getter on the share
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
3961a8be67
commit
08495bfc0e
2 changed files with 24 additions and 8 deletions
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
namespace OC\Share20;
|
||||
|
||||
use OCP\Constants;
|
||||
use OCP\Files\Cache\ICacheEntry;
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\FileInfo;
|
||||
|
|
@ -586,6 +587,19 @@ class Share implements IShare {
|
|||
return $this->reminderSent;
|
||||
}
|
||||
|
||||
public function canDownload(): bool {
|
||||
if (($this->getPermissions() & Constants::PERMISSION_READ) === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$attributes = $this->getAttributes();
|
||||
if ($attributes?->getAttribute('permissions', 'download') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canSeeContent(): bool {
|
||||
$shareManager = Server::get(IManager::class);
|
||||
|
||||
|
|
@ -595,13 +609,6 @@ class Share implements IShare {
|
|||
return true;
|
||||
}
|
||||
|
||||
// No "allow preview" header set, so we must check if
|
||||
// the share has not explicitly disabled download permissions
|
||||
$attributes = $this->getAttributes();
|
||||
if ($attributes?->getAttribute('permissions', 'download') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $this->canDownload();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -645,6 +645,15 @@ interface IShare {
|
|||
* Check if the current user can see this share files contents.
|
||||
* This will check the download permissions as well as the global
|
||||
* admin setting to allow viewing files without downloading.
|
||||
*
|
||||
* @since 32.0.0
|
||||
*/
|
||||
public function canSeeContent(): bool;
|
||||
|
||||
/**
|
||||
* Check if it is allowed to download this share.
|
||||
*
|
||||
* @since 34.0.0
|
||||
*/
|
||||
public function canDownload(): bool;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue