Skip to content

Commit

Permalink
Add status RegClosedRequestsOpen, remove temp fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thehowl committed Aug 5, 2017
1 parent 0e9048c commit e1ba8df
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions classes/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
class Status {
const Organising = 0;
const Open = 1;
const RegClosed = 2;
const AwaitRound = 3;
const Playing = 4;
const Closed = 5;
const RegClosedRequestsOpen = 2;
const RegClosed = 3;
const AwaitRound = 4;
const Playing = 5;
const Closed = 6;
}
5 changes: 2 additions & 3 deletions methods/beatmaps/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ function run_method($state)
error_message("Tournament does not exist.");
return;
}
// TODO: temporary fix
/*if ($tourn["max_beatmap_requests"] < 1 || $tourn["status"] != Status::Open) {
if ($tourn["max_beatmap_requests"] < 1 || $tourn["status"] > Status::RegClosedRequestsOpen) {
error_message("Tournament does not accept beatmap requests.");
return;
}*/
}

// Decode POST body and check tournament is set
$maps = json_decode(file_get_contents('php://input'));
Expand Down
3 changes: 2 additions & 1 deletion methods/invites/accept.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

require_once __DIR__ . "/../../registration_validation.php";
require_once __DIR__ . "/../../classes/Status.php";

function run_method($state) {
$tok = $state->getAccessToken();
Expand Down Expand Up @@ -29,7 +30,7 @@ function run_method($state) {

$tournID = $state->db->fetch("SELECT tournament FROM teams WHERE id = ? LIMIT 1", $teamID)["tournament"];

if (!validate_registration($state, $tournID, $uid)) {
if (!validate_registration($state, $tournID, $uid, Status::RegClosedRequestsOpen)) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions registration_validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once __DIR__ . "/classes/Status.php";

function validate_registration($state, $tournID, $uid) {
function validate_registration($state, $tournID, $uid, $minStatus = 1) {
// Get information about our tournament
$tourn = $state->db->fetch("SELECT status, created_at, team_size, min_team_size, exclusivity_starts, exclusivity_ends FROM tournaments WHERE id = ?", [$tournID]);
if (!$tourn || $tourn["status"] == Status::Organising) {
Expand All @@ -13,7 +13,7 @@ function validate_registration($state, $tournID, $uid) {
$starts = $tourn["exclusivity_starts"];
$ends = $tourn["exclusivity_ends"];

if ($tourn["status"] > 2) { // TODO make this for registrations only, not invites
if ($tourn["status"] > $minStatus) {
error_message("No more registrations are allowed.", 403);
return false;
}
Expand Down

0 comments on commit e1ba8df

Please sign in to comment.