Example #1
0
        Application::sendJson(["err" => "UNDEFINED_ACTION"]);
    }
    $action = $_POST['action'];
    if (!isset($_POST['id'])) {
        Application::sendJson(["err" => "UNDEFINED_EVENT_ID"]);
    }
    $event = GreaseRatEvent::retrieveByPK(intval($_POST['id']));
    if (!$event) {
        Application::sendJson(["err" => "UNDEFINED_EVENT"]);
    }
    switch ($action) {
        case "DELETE":
            $event->delete();
            Application::sendJson(["err" => "OK"]);
            break;
        case "MOVE":
            if (!isset($_POST["data"])) {
                Application::sendJson(["err" => "UNDEFINED_FORM_DATA"]);
            }
            $_POST["data"]["id"] = intval($_POST['id']);
            Application::sendJson(processForm($_POST["data"]));
            break;
        default:
            Application::sendJson(["err" => "UNDEFINED_ACTION"]);
            break;
    }
});
Macaw::error(function () {
    echo '404 :: Not Found';
});
Macaw::dispatch();