115 lines
4.2 KiB
PHP
115 lines
4.2 KiB
PHP
<?php
|
|
$title = "Games";
|
|
$description = "View previous games.";
|
|
|
|
if (!isset($_SESSION["account"])) {
|
|
$title = "Log In";
|
|
$description = "Login to view details about this vote.";
|
|
http_response_code(401);
|
|
}
|
|
|
|
if (LOGGED_IN && isset($_GET["game"])) {
|
|
$sql = "SELECT games.id, games.name, games.status_id,
|
|
games.submitstart, games.submitend,
|
|
games.onestart, games.twostart, games.threestart, games.gameend
|
|
FROM games
|
|
JOIN game_status ON games.status_id = game_status.id
|
|
WHERE games.id = :id";
|
|
|
|
$stmt = $db["data"]->prepare($sql);
|
|
$stmt->execute([
|
|
"id" => $_GET["game"],
|
|
]);
|
|
|
|
$game = $stmt->fetch(PDO::FETCH_OBJ);
|
|
unset($stmt);
|
|
|
|
$title = "Game: " . $game->name;
|
|
$description = "View details about the " . $game->name . " vote.";
|
|
}
|
|
|
|
include "partials/head.php";
|
|
?>
|
|
<body>
|
|
<?php include "partials/header.php"; ?>
|
|
<main id="main" class="flow">
|
|
<header>
|
|
<h1><?= $title ?></h1>
|
|
</header>
|
|
<?php if (!LOGGED_IN) {
|
|
include "partials/login-form.php";
|
|
} else {
|
|
|
|
$stmt = $db["data"]->prepare(
|
|
"SELECT * FROM assignments WHERE assignments.game_id = :game_id"
|
|
);
|
|
$stmt->execute([
|
|
"game_id" => $_GET["game"],
|
|
]);
|
|
$assignments = $stmt->execute();
|
|
|
|
$stmt = $db["data"]->prepare(
|
|
"SELECT * FROM submissions WHERE game_id = :game_id AND member_id = :member_id"
|
|
);
|
|
$stmt->execute([
|
|
"game_id" => $_GET["game"],
|
|
"member_id" => $_SESSION["account"]->id,
|
|
]);
|
|
$submission = $stmt->fetch(PDO::FETCH_OBJ);
|
|
unset($stmt);
|
|
?>
|
|
<article class="single-game">
|
|
<div class="flow">
|
|
<h2>Your Submission</h2>
|
|
<?php
|
|
$IS_PAID = $submission && $submission->transaction_id !== null;
|
|
if (
|
|
in_array($game->status_id, [
|
|
STATUS_ENROLLING,
|
|
STATUS_REVIEW,
|
|
]) &&
|
|
$submission &&
|
|
!$IS_PAID
|
|
) { ?>
|
|
<aside class="alert"><p>You have not yet paid for your submission.</p></aside>
|
|
<?php }
|
|
if ($submission) {
|
|
include "partials/submission-details.php"; ?>
|
|
<ul role="list" class="flow">
|
|
<?php if (
|
|
!$IS_PAID &&
|
|
in_array($game->status_id, [
|
|
STATUS_ENROLLING,
|
|
STATUS_REVIEW,
|
|
])
|
|
) { ?><li><a href="/games/<?= $game->id ?>/submit" class='call-to-action'>Pay submission fee</a></li><?php } ?>
|
|
<li><a href="/games/<?= $game->id ?>/update" class='call-to-action'>Update submission<?php !in_array(
|
|
$game->status_id,
|
|
[STATUS_ENROLLING, STATUS_REVIEW]
|
|
)
|
|
? " visibility"
|
|
: ""; ?></a></li>
|
|
<?php if ($game->status_id === STATUS_DONE) { ?><li><a href="/games/<?= $game->id ?>/results" class='call-to-action'>View full results</a></li><?php } ?>
|
|
</ul>
|
|
<?php include "partials/feedback.php"; ?>
|
|
<?php include "partials/assignments.php"; ?>
|
|
<?php
|
|
}
|
|
?>
|
|
<?php if (
|
|
$game->status_id === STATUS_ENROLLING &&
|
|
!$submission
|
|
) { ?>
|
|
<p>You haven't submitted work to this contest.</p>
|
|
<p><a href="/games/<?= $game->id ?>/submit" class='call-to-action'>Submit to <?= $game->name ?></a></p>
|
|
<?php } else if ($game->status_id !== STATUS_DONE && !$submission) { ?>
|
|
<p>You didn't submit a work to this contest.</p>
|
|
<?php } ?>
|
|
</div>
|
|
<hr/>
|
|
<?php include "partials/contest-schedule.php"; ?>
|
|
</article>
|
|
<?php
|
|
} ?>
|
|
</main>
|
|
<?php include "partials/footer.php"; ?>
|