Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once("core.php"); |
| 3 | security::checkType(security::ADMIN); |
| 4 | |
| 5 | if (!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 | |
| 16 | if ($c === false) { |
| 17 | security::go("calendars.php?msg=unexpected"); |
| 18 | } |
| 19 | |
| 20 | $calendar_response = calendars::parseFormCalendar($_POST["type"], $c["begins"], $c["ends"], true); |
| 21 | |
| 22 | if ($calendar_response === false) { |
| 23 | security::go("calendars.php?msg=unexpected"); |
| 24 | } |
| 25 | |
| 26 | if (calendars::edit($id, $calendar_response["calendar"])) { |
| 27 | security::go("calendars.php?msg=modified"); |
| 28 | } else { |
| 29 | security::go("calendars.php?msg=unexpected"); |
| 30 | } |