diff --git a/www/games/update.php b/www/games/update.php index be56b31..886a2c0 100644 --- a/www/games/update.php +++ b/www/games/update.php @@ -32,12 +32,17 @@ if (LOGGED_IN && isset($_GET["game"])) { ]); $game = $stmt->fetch(PDO::FETCH_OBJ); - define("GAME_IS_OPEN", $game->status_id === STATUS_ENROLLING); - $title = "Update: {$game->name}"; $description = "Update your submission for the " . $game->name . " vote."; } +define( + "CAN_SUBMIT", + $game->status_id === STATUS_ENROLLING || + ($game->status_id === STATUS_REVIEW && + in_array($submission->status, [0, 2])) +); + if ($_SERVER["REQUEST_METHOD"] === "POST"): define("NEW_MANUSCRIPT", $_POST["keep-manuscript"] === "0"); define("EXISTING_MANUSCRIPT", $_POST["keep-manuscript"] === "1"); @@ -62,16 +67,16 @@ if ($_SERVER["REQUEST_METHOD"] === "POST"): $errors["game"] = "The chosen game doesn't exist."; } - if (GAME_IS_OPEN && NEW_MANUSCRIPT && !RULES_WERE_FOLLOWED) { + if (CAN_SUBMIT && NEW_MANUSCRIPT && !RULES_WERE_FOLLOWED) { $errors["agreements"] = "Please accept the Terms & Conditions and the Submission Guidelines."; } - if (GAME_IS_OPEN && NEW_MANUSCRIPT && FILE_EMPTY) { + if (CAN_SUBMIT && NEW_MANUSCRIPT && FILE_EMPTY) { $errors["filesize"] = "A file upload is required."; } elseif (NEW_MANUSCRIPT && FILE_TOO_BIG) { $errors["filesize"] = "Your document is too large."; - } elseif (GAME_IS_OPEN && NEW_MANUSCRIPT) { + } elseif (CAN_SUBMIT && NEW_MANUSCRIPT) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime_type = finfo_file($finfo, $_FILES["manuscript"]["tmp_name"]); finfo_close($finfo); @@ -83,19 +88,15 @@ if ($_SERVER["REQUEST_METHOD"] === "POST"): $errors["mimetype"] = "Only PDF submissions are allowed."; } - if (GAME_IS_OPEN && (!isset($_POST["title"]) || !trim($_POST["title"]))) { + if (CAN_SUBMIT && (!isset($_POST["title"]) || !trim($_POST["title"]))) { $errors["title"] = "Please enter a title."; } - if (GAME_IS_OPEN && !isset($_SESSION["account"])) { + if (CAN_SUBMIT && !isset($_SESSION["account"])) { $errors["account"] = "We can't upload a document without knowing which account it belongs to."; } - if (GAME_IS_OPEN && !isset($_POST["tx-id"])) { - $errors["payment"] = "You must submit a payment."; - } - if (count($errors) > 0) { http_response_code(400); define( @@ -109,13 +110,13 @@ if ($_SERVER["REQUEST_METHOD"] === "POST"): } } else { $params = [ - "submission_id" => $submission->id, + "submission_id" => $submission->id, "title" => $_POST["title"], "doc_is_public" => isset($_POST["public-doc"]) ? 1 : 0, "name_is_public" => isset($_POST["public-name"]) ? 1 : 0, ]; - if (GAME_IS_OPEN && NEW_MANUSCRIPT) { + if (CAN_SUBMIT && NEW_MANUSCRIPT) { $basename = md5(microtime() . $game->id . $_SESSION["account"]->id) . ".pdf"; @@ -175,7 +176,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST"): } } - if (GAME_IS_OPEN && EXISTING_MANUSCRIPT) { + if (CAN_SUBMIT && EXISTING_MANUSCRIPT) { $stmt = $db["data"] ->prepare("UPDATE submissions SET (title, doc_is_public, name_is_public) = (:title, :doc_is_public, :name_is_public) WHERE id = :submission_id"); @@ -185,7 +186,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST"): http_response_code(303); header("Location: /games/" . $_GET["game"]); } - if (!GAME_IS_OPEN) { + if ($game->status_id !== STATUS_ENROLLING) { $stmt = $db["data"] ->prepare("UPDATE submissions SET (doc_is_public, name_is_public) = (:doc_is_public, :name_is_public) WHERE id = :submission_id"); @@ -213,7 +214,7 @@ include "partials/head.php"; + if (CAN_SUBMIT) { ?>
If you would like to withdraw your submission, please email us at sixfold@sixfold.org.
This game's submissions are now locked, and you may only edit your work's public visibility.
@@ -264,7 +265,7 @@ include "partials/head.php"; ) { ?>= $errors[ "account" ] ?>
- + - -