]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow specifying a default expiration date 20587/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Tue, 21 Apr 2020 12:10:33 +0000 (14:10 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Fri, 24 Apr 2020 14:18:20 +0000 (16:18 +0200)
This overrides the max expiration date.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
lib/private/Share20/Manager.php
tests/lib/Share20/ManagerTest.php

index becf29e4cc7bac45a517f13da91a783eab2b3d87..eae26645b55c78007f7a3e0a2135f8525d517bfc 100644 (file)
@@ -396,7 +396,12 @@ class Manager implements IManager {
                if ($fullId === null && $expirationDate === null && $this->shareApiInternalDefaultExpireDate()) {
                        $expirationDate = new \DateTime();
                        $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
@@ -467,7 +472,12 @@ class Manager implements IManager {
                if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
                        $expirationDate = new \DateTime();
                        $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
index 4a7b0e9ae4b4a165fa2333a43f26cf7b6daf6624..b8364cfdc466945bbfad38bab0ecab182b19dfcf 100644 (file)
@@ -808,6 +808,7 @@ class ManagerTest extends \Test\TestCase {
                                ['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
                                ['core', 'shareapi_expire_after_n_days', '7', '3'],
                                ['core', 'shareapi_default_expire_date', 'no', 'yes'],
+                               ['core', 'link_defaultExpDays', 3, '3'],
                        ]);
 
                $expected = new \DateTime();