summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-26 10:48:21 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-26 10:48:21 +0100
commit0795cc373d667dbd515d7631131eebb1be47324c (patch)
tree9290312449f5e70515321397a8cc39486438683e /lib
parent66536f912ebe7b2287dad839ffac66f949c1bf41 (diff)
parent6d4f80d680bfd45293a055b1c2502f512cbf1070 (diff)
downloadnextcloud-server-0795cc373d667dbd515d7631131eebb1be47324c.tar.gz
nextcloud-server-0795cc373d667dbd515d7631131eebb1be47324c.zip
Merge pull request #22646 from owncloud/fix_22642
Set default expiration date if none given on share creation
Diffstat (limited to 'lib')
-rw-r--r--lib/private/share20/manager.php32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index 63119edf504..214126e3414 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -224,7 +224,7 @@ class Manager implements IManager {
* Validate if the expiration date fits the system settings
*
* @param \OCP\Share\IShare $share The share to validate the expiration date of
- * @return \OCP\Share\IShare The expiration date or null if $expireDate was null and it is not required
+ * @return \OCP\Share\IShare The modified share object
* @throws GenericShareException
* @throws \InvalidArgumentException
* @throws \Exception
@@ -245,6 +245,20 @@ class Manager implements IManager {
}
}
+ // If expiredate is empty set a default one if there is a default
+ $fullId = null;
+ try {
+ $fullId = $share->getFullId();
+ } catch (\UnexpectedValueException $e) {
+ // This is a new share
+ }
+
+ if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
+ $expirationDate = new \DateTime();
+ $expirationDate->setTime(0,0,0);
+ $expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
+ }
+
// If we enforce the expiration date check that is does not exceed
if ($this->shareApiLinkDefaultExpireDateEnforced()) {
if ($expirationDate === null) {
@@ -260,20 +274,6 @@ class Manager implements IManager {
}
}
- // If expiredate is empty set a default one if there is a default
- $fullId = null;
- try {
- $fullId = $share->getFullId();
- } catch (\UnexpectedValueException $e) {
- // This is a new share
- }
-
- if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
- $expirationDate = new \DateTime();
- $expirationDate->setTime(0,0,0);
- $expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
- }
-
$accepted = true;
$message = '';
\OCP\Util::emitHook('\OC\Share', 'verifyExpirationDate', [
@@ -289,7 +289,7 @@ class Manager implements IManager {
$share->setExpirationDate($expirationDate);
- return $expirationDate;
+ return $share;
}
/**