From 2a234307a3d13a4e2fd8a1f72e28c09689ff696b Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 27 Feb 2018 18:11:32 +0100 Subject: [PATCH] fix setting of expiration date --- op/op.CheckInDocument.php | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/op/op.CheckInDocument.php b/op/op.CheckInDocument.php index 73fdb7f54..e0c63f32b 100644 --- a/op/op.CheckInDocument.php +++ b/op/op.CheckInDocument.php @@ -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();