use new function getTsByPeriod()

This commit is contained in:
Uwe Steinmann 2023-09-29 14:30:20 +02:00
parent 01fd55832f
commit 2c01243ec5

View File

@ -53,36 +53,20 @@ if (!isset($_POST["presetexpdate"]) || $_POST["presetexpdate"] == "") {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_expiration_date"));
}
if ($_POST["presetexpdate"] == 'date' && $_POST["expdate"] == "") {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_expiration_date"));
}
switch($_POST["presetexpdate"]) {
case "date":
$expires = makeTsFromDate($_POST["expdate"]);
// $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 "3y":
$tmp = explode('-', date('Y-m-d'));
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]+3);
break;
case "never":
default:
$expires = null;
break;
default:
$expires = getTsByPeriod($_POST["presetexpdate"], 's');
break;
}
if(isset($GLOBALS['SEEDDMS_HOOKS']['setExpires'])) {