diff --git a/op/op.AddEvent.php b/op/op.AddEvent.php index 068adf37a..dbf2f9b97 100644 --- a/op/op.AddEvent.php +++ b/op/op.AddEvent.php @@ -32,11 +32,11 @@ if ($user->isGuest()) { UI::exitError(getMLText("edit_event"),getMLText("access_denied")); } -if (!isset($_POST["frommonth"]) || !isset($_POST["fromday"]) || !isset($_POST["fromyear"]) ) { +if (!isset($_POST["from"]) && !(isset($_POST["frommonth"]) && isset($_POST["fromday"]) && isset($_POST["fromyear"])) ) { UI::exitError(getMLText("add_event"),getMLText("error_occured")); } -if (!isset($_POST["tomonth"]) || !isset($_POST["today"]) || !isset($_POST["toyear"]) ) { +if (!isset($_POST["to"]) && !(isset($_POST["tomonth"]) && isset($_POST["today"]) && isset($_POST["toyear"])) ) { UI::exitError(getMLText("add_event"),getMLText("error_occured")); } @@ -46,11 +46,21 @@ if (!isset($_POST["name"]) || !isset($_POST["comment"]) ) { $name = $_POST["name"]; $comment = $_POST["comment"]; -$from = mktime(0,0,0, intval($_POST["frommonth"]), intval($_POST["fromday"]), intval($_POST["fromyear"])); -$to = mktime(23,59,59, intval($_POST["tomonth"]), intval($_POST["today"]), intval($_POST["toyear"])); +if(isset($_POST["from"])) { + $tmp = explode('-', $_POST["from"]); + $from = mktime(0,0,0, $tmp[1], $tmp[0], $tmp[2]); +} else { + $from = mktime(0,0,0, intval($_POST["frommonth"]), intval($_POST["fromday"]), intval($_POST["fromyear"])); +} +if(isset($_POST["to"])) { + $tmp = explode('-', $_POST["to"]); + $to = mktime(23,59,59, $tmp[1], $tmp[0], $tmp[2]); +} else { + $to = mktime(23,59,59, intval($_POST["tomonth"]), intval($_POST["today"]), intval($_POST["toyear"])); +} -if ($to<$from){ - $to= mktime(23,59,59, intval($_POST["frommonth"]), intval($_POST["fromday"]), intval($_POST["fromyear"])); +if ($to<=$from){ + $to = $from + 86400 -1; } $res = addEvent($from, $to, $name, $comment);