blob: b58d20765d220167cbf5c155ca92d9b197951683 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once("core.php");
3security::checkType(security::ADMIN);
4
5if (!security::checkParams("POST", [
6 ["id", security::PARAM_NEMPTY],
7 ["type", security::PARAM_ISSET]
8])) {
9 security::go("calendars.php?msg=unexpected");
10}
11
12$id = (int)$_POST["id"];
13
14$c = calendars::get($id);
15
16if ($c === false) {
17 security::go("calendars.php?msg=unexpected");
18}
19
20$calendar_response = calendars::parseFormCalendar($_POST["type"], $c["begins"], $c["ends"], true);
21
22if ($calendar_response === false) {
23 security::go("calendars.php?msg=unexpected");
24}
25
26if (calendars::edit($id, $calendar_response["calendar"])) {
27 security::go("calendars.php?msg=modified");
28} else {
29 security::go("calendars.php?msg=unexpected");
30}