from and to date can be given as a '-' separeted date

This commit is contained in:
steinm 2012-12-14 08:25:02 +00:00
parent f28657a96d
commit db56298e79

View File

@ -32,11 +32,11 @@ if ($user->isGuest()) {
UI::exitError(getMLText("edit_event"),getMLText("access_denied")); 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")); 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")); UI::exitError(getMLText("add_event"),getMLText("error_occured"));
} }
@ -46,11 +46,21 @@ if (!isset($_POST["name"]) || !isset($_POST["comment"]) ) {
$name = $_POST["name"]; $name = $_POST["name"];
$comment = $_POST["comment"]; $comment = $_POST["comment"];
$from = mktime(0,0,0, intval($_POST["frommonth"]), intval($_POST["fromday"]), intval($_POST["fromyear"])); if(isset($_POST["from"])) {
$to = mktime(23,59,59, intval($_POST["tomonth"]), intval($_POST["today"]), intval($_POST["toyear"])); $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){ if ($to<=$from){
$to= mktime(23,59,59, intval($_POST["frommonth"]), intval($_POST["fromday"]), intval($_POST["fromyear"])); $to = $from + 86400 -1;
} }
$res = addEvent($from, $to, $name, $comment); $res = addEvent($from, $to, $name, $comment);