diff options
author | Morris Jobke <hey@morrisjobke.de> | 2014-11-26 10:19:12 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-11-26 10:19:12 +0100 |
commit | 60e4aa120f961911a038d272f3130411c24a0808 (patch) | |
tree | 3f6f14ee387a6c243b869d0958e278d4a0c00f44 | |
parent | c5fa8f1bdc08b07d03fcc9f9c84033960ec4e20f (diff) | |
parent | 397f14ed86ce675b11f35f06ffac30af6c17ade0 (diff) | |
download | nextcloud-server-60e4aa120f961911a038d272f3130411c24a0808.tar.gz nextcloud-server-60e4aa120f961911a038d272f3130411c24a0808.zip |
Merge pull request #12350 from mprokop/link_expiration
fix calculation of expiration date if there is a default expiration date...
-rw-r--r-- | lib/private/share/helper.php | 9 | ||||
-rw-r--r-- | tests/lib/share/helper.php | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php index 2418535c9d5..6bbb101db3a 100644 --- a/lib/private/share/helper.php +++ b/lib/private/share/helper.php @@ -189,20 +189,23 @@ class Helper extends \OC\Share\Constants { public static function calculateExpireDate($defaultExpireSettings, $creationTime, $userExpireDate = null) { $expires = false; + $defaultExpires = null; if (!empty($defaultExpireSettings['defaultExpireDateSet'])) { - $expires = $creationTime + $defaultExpireSettings['expireAfterDays'] * 86400; + $defaultExpires = $creationTime + $defaultExpireSettings['expireAfterDays'] * 86400; } if (isset($userExpireDate)) { // if the admin decided to enforce the default expire date then we only take // the user defined expire date of it is before the default expire date - if ($expires && !empty($defaultExpireSettings['enforceExpireDate'])) { - $expires = min($userExpireDate, $expires); + if ($defaultExpires && !empty($defaultExpireSettings['enforceExpireDate'])) { + $expires = min($userExpireDate, $defaultExpires); } else { $expires = $userExpireDate; } + } else if ($defaultExpires && !empty($defaultExpireSettings['enforceExpireDate'])) { + $expires = $defaultExpires; } return $expires; diff --git a/tests/lib/share/helper.php b/tests/lib/share/helper.php index 76046d360bc..7a546410aea 100644 --- a/tests/lib/share/helper.php +++ b/tests/lib/share/helper.php @@ -27,8 +27,8 @@ class Test_Share_Helper extends \Test\TestCase { array(array('defaultExpireDateSet' => false), 2000000000, 2000010000, 2000010000), // no default expire date and no user defined expire date, return false array(array('defaultExpireDateSet' => false), 2000000000, null, false), - // unenforced expire data and no user defined expire date, take default expire date - array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => false), 2000000000, null, 2000086400), + // unenforced expire data and no user defined expire date, return false (because the default is not enforced) + array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => false), 2000000000, null, false), // enforced expire date and no user defined expire date, take default expire date array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => true), 2000000000, null, 2000086400), // unenforced expire date and user defined date > default expire date, take users expire date @@ -49,6 +49,4 @@ class Test_Share_Helper extends \Test\TestCase { $result = \OC\Share\Helper::calculateExpireDate($defaultExpireSettings, $creationTime, $userExpireDate); $this->assertSame($expected, $result); } - - } |