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 | ["type", security::PARAM_ISINT], |
| 7 | ["worker", security::PARAM_ISINT], |
| 8 | ["firstday", security::PARAM_ISDATE], |
| 9 | ["lastday", security::PARAM_ISDATE], |
| 10 | ["day", security::PARAM_ISARRAY], |
| 11 | ["daytype", security::PARAM_ISARRAY] |
| 12 | ])) { |
| 13 | security::go(visual::getContinueUrl("incidents.php", "empty", "POST")); |
| 14 | } |
| 15 | |
| 16 | $type = (int)$_POST["type"]; |
| 17 | $worker = (int)$_POST["worker"]; |
| 18 | $details = ((isset($_POST["details"]) && is_string($_POST["details"])) ? $_POST["details"] : ""); |
| 19 | $firstday = $_POST["firstday"]; |
| 20 | $lastday = $_POST["lastday"]; |
| 21 | $days = $_POST["day"]; |
| 22 | $typeDays = $_POST["daytype"]; |
| 23 | |
| 24 | if (isset($_POST["allday"]) && $_POST["allday"] == 1) { |
| 25 | $begins = incidents::STARTOFDAY; |
| 26 | $ends = incidents::ENDOFDAY; |
| 27 | } else { |
| 28 | if (!security::checkParams("POST", [ |
| 29 | ["begins", security::PARAM_ISTIME], |
| 30 | ["ends", security::PARAM_ISTIME] |
| 31 | ])) { |
| 32 | security::go(visual::getContinueUrl("incidents.php", "empty", "POST")); |
| 33 | } |
| 34 | |
| 35 | $begins = schedules::time2sec($_POST["begins"]); |
| 36 | $ends = schedules::time2sec($_POST["ends"]); |
| 37 | } |
| 38 | |
| 39 | if (recurringIncidents::add($worker, $type, $details, $firstday, $lastday, $begins, $ends, "ME", $typeDays, $days)) security::go(visual::getContinueUrl("incidents.php", "addedrecurring", "POST")); |
| 40 | else security::go(visual::getContinueUrl("incidents.php", "unexpectedrecurring", "POST")); |