Browse Source

Allow specifying a default expiration date

This overrides the max expiration date.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
pull/20587/head
Roeland Jago Douma 6 years ago
parent
commit
f4b8623d33
No known key found for this signature in database GPG Key ID: F941078878347C0C
  1. 14
      lib/private/Share20/Manager.php
  2. 1
      tests/lib/Share20/ManagerTest.php

14
lib/private/Share20/Manager.php

@ -396,7 +396,12 @@ class Manager implements IManager {
if ($fullId === null && $expirationDate === null && $this->shareApiInternalDefaultExpireDate()) { if ($fullId === null && $expirationDate === null && $this->shareApiInternalDefaultExpireDate()) {
$expirationDate = new \DateTime(); $expirationDate = new \DateTime();
$expirationDate->setTime(0,0,0); $expirationDate->setTime(0,0,0);
$expirationDate->add(new \DateInterval('P'.$this->shareApiInternalDefaultExpireDays().'D'));
$days = (int)$this->config->getAppValue('core', 'internal_defaultExpDays', $this->shareApiLinkDefaultExpireDays());
if ($days > $this->shareApiLinkDefaultExpireDays()) {
$days = $this->shareApiLinkDefaultExpireDays();
}
$expirationDate->add(new \DateInterval('P'.$days.'D'));
} }
// If we enforce the expiration date check that is does not exceed // If we enforce the expiration date check that is does not exceed
@ -467,7 +472,12 @@ class Manager implements IManager {
if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) { if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
$expirationDate = new \DateTime(); $expirationDate = new \DateTime();
$expirationDate->setTime(0,0,0); $expirationDate->setTime(0,0,0);
$expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
$days = (int)$this->config->getAppValue('core', 'link_defaultExpDays', $this->shareApiLinkDefaultExpireDays());
if ($days > $this->shareApiLinkDefaultExpireDays()) {
$days = $this->shareApiLinkDefaultExpireDays();
}
$expirationDate->add(new \DateInterval('P'.$days.'D'));
} }
// If we enforce the expiration date check that is does not exceed // If we enforce the expiration date check that is does not exceed

1
tests/lib/Share20/ManagerTest.php

@ -808,6 +808,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_enforce_expire_date', 'no', 'yes'], ['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
['core', 'shareapi_expire_after_n_days', '7', '3'], ['core', 'shareapi_expire_after_n_days', '7', '3'],
['core', 'shareapi_default_expire_date', 'no', 'yes'], ['core', 'shareapi_default_expire_date', 'no', 'yes'],
['core', 'link_defaultExpDays', 3, '3'],
]); ]);
$expected = new \DateTime(); $expected = new \DateTime();

Loading…
Cancel
Save