blob: d9750f413a55c354f5b242cd53b7ae64dc40c268 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once("core.php");
3security::checkType(security::WORKER, security::METHOD_NOTFOUND);
4security::checkWorkerUIEnabled();
5
6$isAdmin = security::isAdminView();
7$url = ($isAdmin ? "incidents.php?" : "userincidents.php?id=".$_SESSION["id"]."&");
8
9if (!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);
18if ($incident === false) security::go(visual::getContinueUrl($url, "unexpected", "POST"));
19
20$istatus = incidents::getStatus($incident);
21
22if (($isAdmin && !in_array($istatus, incidents::$canRemoveStates)) || (!$isAdmin && !in_array($istatus, incidents::$workerCanRemoveStates))) security::notFound();
23if (!$isAdmin) incidents::checkIncidentIsFromPerson($incident["id"]);
24
25if (incidents::remove($id)) {
26 security::go(visual::getContinueUrl($url, "removed", "POST"));
27} else {
28 security::go(visual::getContinueUrl($url, "unexpected", "POST"));
29}