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 | $isAdmin = security::isAdminView(); |
| 7 | $url = ($isAdmin ? "incidents.php?" : "userincidents.php?id=".$_SESSION["id"]."&"); |
| 8 | |
| 9 | if (!security::checkParams("POST", [ |
| 10 | ["id", security::PARAM_ISINT] |
| 11 | ])) { |
| 12 | security::go(visual::getContinueUrl($url, "unexpected", "POST")); |
| 13 | } |
| 14 | |
| 15 | $id = (int)$_POST["id"]; |
| 16 | |
| 17 | $incident = incidents::get($id, true); |
| 18 | if ($incident === false) security::go(visual::getContinueUrl($url, "unexpected", "POST")); |
| 19 | |
| 20 | $istatus = incidents::getStatus($incident); |
| 21 | |
| 22 | if (($isAdmin && !in_array($istatus, incidents::$canRemoveStates)) || (!$isAdmin && !in_array($istatus, incidents::$workerCanRemoveStates))) security::notFound(); |
| 23 | if (!$isAdmin) incidents::checkIncidentIsFromPerson($incident["id"]); |
| 24 | |
| 25 | if (incidents::remove($id)) { |
| 26 | security::go(visual::getContinueUrl($url, "removed", "POST")); |
| 27 | } else { |
| 28 | security::go(visual::getContinueUrl($url, "unexpected", "POST")); |
| 29 | } |