fix calculation of expiration date if there is a default expiration date set (but not forced) and the user does not want the link to expire.

This commit is contained in:
Miguel Prokop 2014-11-21 11:01:39 +01:00
parent f8421958b3
commit 1d4d308a6c
1 changed files with 8 additions and 3 deletions

View File

@ -189,20 +189,25 @@ 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;