fix setting of expiration date

This commit is contained in:
Uwe Steinmann 2018-02-27 18:11:32 +01:00
parent 0bb1035261
commit 2a234307a3

View File

@ -362,17 +362,35 @@ else
}
}
$expires = false;
if (!isset($_POST['expires']) || $_POST["expires"] != "false") {
if($_POST["expdate"]) {
$tmp = explode('-', $_POST["expdate"]);
$expires = mktime(0,0,0, $tmp[1], $tmp[0], $tmp[2]);
} else {
$expires = mktime(0,0,0, $_POST["expmonth"], $_POST["expday"], $_POST["expyear"]);
}
$oldexpires = $document->getExpires();
switch($_POST["presetexpdate"]) {
case "date":
$tmp = explode('-', $_POST["expdate"]);
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
break;
case "1w":
$tmp = explode('-', date('Y-m-d'));
$expires = mktime(0,0,0, $tmp[1], $tmp[2]+7, $tmp[0]);
break;
case "1m":
$tmp = explode('-', date('Y-m-d'));
$expires = mktime(0,0,0, $tmp[1]+1, $tmp[2], $tmp[0]);
break;
case "1y":
$tmp = explode('-', date('Y-m-d'));
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]+1);
break;
case "2y":
$tmp = explode('-', date('Y-m-d'));
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]+2);
break;
case "never":
default:
$expires = null;
break;
}
if ($expires) {
if($oldexpires != $expires) {
if($document->setExpires($expires)) {
if($notifier) {
$notifyList = $document->getNotifyList();