Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once("core.php"); |
| 3 | security::checkType(security::WORKER, security::METHOD_NOTFOUND); |
| 4 | security::checkWorkerUIEnabled(); |
| 5 | |
| 6 | $url = (security::isAllowed(security::ADMIN) ? "incidents.php" : "userincidents.php?id=".(int)$_SESSION["id"]); |
| 7 | |
| 8 | if (!security::checkParams("POST", [ |
| 9 | ["id", security::PARAM_ISINT], |
| 10 | ["name", security::PARAM_NEMPTY] |
| 11 | ])) { |
| 12 | security::go(visual::getContinueUrl($url, "unexpected", "POST")); |
| 13 | |
| 14 | } |
| 15 | |
| 16 | $id = (int)$_POST["id"]; |
| 17 | $name = $_POST["name"]; |
| 18 | |
| 19 | $incident = incidents::get($id, true); |
| 20 | if ($incident === false) security::go(visual::getContinueUrl($url, "unexpected", "POST")); |
| 21 | |
| 22 | if (!security::isAllowed(security::ADMIN)) incidents::checkIncidentIsFromPerson($incident["id"]); |
| 23 | |
| 24 | security::go(visual::getContinueUrl($url, (incidents::deleteAttachment($id, $name) ? "attachmentdeleted" : "unexpected"), "POST")); |