aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Share20/Share.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Share20/Share.php')
-rw-r--r--lib/private/Share20/Share.php45
1 files changed, 26 insertions, 19 deletions
diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php
index 466817efc9a..571efc8c4be 100644
--- a/lib/private/Share20/Share.php
+++ b/lib/private/Share20/Share.php
@@ -14,8 +14,10 @@ use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IUserManager;
+use OCP\Server;
use OCP\Share\Exceptions\IllegalIDChangeException;
use OCP\Share\IAttributes;
+use OCP\Share\IManager;
use OCP\Share\IShare;
class Share implements IShare {
@@ -58,8 +60,7 @@ class Share implements IShare {
private $sendPasswordByTalk = false;
/** @var string */
private $token;
- /** @var int */
- private $parent;
+ private ?int $parent = null;
/** @var string */
private $target;
/** @var \DateTime */
@@ -418,8 +419,8 @@ class Share implements IShare {
* @inheritdoc
*/
public function isExpired() {
- return $this->getExpirationDate() !== null &&
- $this->getExpirationDate() <= new \DateTime();
+ return $this->getExpirationDate() !== null
+ && $this->getExpirationDate() <= new \DateTime();
}
/**
@@ -524,25 +525,12 @@ class Share implements IShare {
return $this->token;
}
- /**
- * Set the parent of this share
- *
- * @param int $parent
- * @return IShare
- * @deprecated 12.0.0 The new shares do not have parents. This is just here for legacy reasons.
- */
- public function setParent($parent) {
+ public function setParent(int $parent): self {
$this->parent = $parent;
return $this;
}
- /**
- * Get the parent of this share.
- *
- * @return int
- * @deprecated 12.0.0 The new shares do not have parents. This is just here for legacy reasons.
- */
- public function getParent() {
+ public function getParent(): ?int {
return $this->parent;
}
@@ -622,4 +610,23 @@ class Share implements IShare {
public function getReminderSent(): bool {
return $this->reminderSent;
}
+
+ public function canSeeContent(): bool {
+ $shareManager = Server::get(IManager::class);
+
+ $allowViewWithoutDownload = $shareManager->allowViewWithoutDownload();
+ // If the share manager allows viewing without download, we can always see the content.
+ if ($allowViewWithoutDownload) {
+ 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;
+ }
}