function content() { $event = NULL; if (isset($_GET['name'])) { $event = new Event($_GET['name']); eventForm($event); } elseif (strcmp($_POST['mode'], "Create New Event") == 0) { if (Player::getSessionPlayer()->isHost()) { if (isset($_POST['insert'])) { insertEvent(); eventList(); } else { eventForm(); } } else { authFailed(); } } elseif (strcmp($_GET['mode'], "create") == 0) { eventForm(); } elseif (isset($_POST['name'])) { $event = new Event($_POST['name']); if (!$event->authCheck($_SESSION['username'])) { authFailed(); } else { if (strcmp($_POST['mode'], "Parse DCI Files") == 0) { dciInput(); } elseif (strcmp($_POST['mode'], "Auto-Input Event Data") == 0) { autoInput(); } elseif (strcmp($_POST['mode'], "Update Registration") == 0) { updateReg(); } elseif (strcmp($_POST['mode'], "Update Match Listing") == 0) { updateMatches(); } elseif (strcmp($_POST['mode'], "Update Medals") == 0) { updateMedals(); } elseif (strcmp($_POST['mode'], "Upload Trophy") == 0) { if (insertTrophy()) { $event->hastrophy = 1; } } elseif (strcmp($_POST['mode'], "Update Event Info") == 0) { $event = updateEvent(); } eventForm($event); } } else { echo "<table style=\"border-width: 0px;\" align=\"center\">"; echo "<tr><td>"; echo "<form action=\"event.php\" method=\"post\">"; echo "<input type=\"submit\" name=\"mode\" value=\"Create New Event\">"; echo "</form></td><td>"; echo "<form action=\"format.php\" method=\"post\">"; echo "<input type=\"submit\" name=\"mode\" value=\"View/Add Formats\">"; echo "</form></td></tr>"; echo "</table><br><br>"; eventList($_POST['series'], $_POST['season']); } }
function content() { $event = NULL; // Prevent surplufous warnings. TODO: fix the code so we don't try to access these if unset. if (!isset($_GET['action'])) { $_GET['action'] = ''; } if (!isset($_POST['mode'])) { $_POST['mode'] = ''; } if (!isset($_GET['mode'])) { $_GET['mode'] = ''; } if (!isset($_GET['series'])) { $_GET['series'] = ''; } if (!isset($_GET['season'])) { $_GET['season'] = ''; } $player = Player::getSessionPlayer(); if ((isset($_GET['name']) || isset($_POST['name'])) && !mode_is("Create New Event")) { if (isset($_POST['name'])) { $eventname = $_POST['name']; } else { $eventname = $_GET['name']; } $event = new Event($eventname); } // if -- can create new events if (Player::getSessionPlayer()->isSteward()) { if (mode_is("Create New Event")) { if (isset($_POST['insert'])) { $event = insertEvent(); eventForm($event); } else { eventForm(); } return; } elseif (mode_is("Create Next Event")) { $oldevent = new Event($_POST['name']); $newevent = new Event(""); $newevent->season = $oldevent->season; $newevent->number = $oldevent->number + 1; $newevent->format = $oldevent->format; $newevent->start = strftime("%Y-%m-%d %H:00:00", strtotime($oldevent->start) + 86400 * 7); $newevent->kvalue = $oldevent->kvalue; $newevent->finalized = 0; $newevent->player_editdecks = 1; $newevent->player_reportable = $oldevent->player_reportable; $newevent->prereg_allowed = $oldevent->prereg_allowed; $newevent->series = $oldevent->series; $newevent->host = $oldevent->host; $newevent->cohost = $oldevent->cohost; $newevent->mainrounds = $oldevent->mainrounds; $newevent->mainstruct = $oldevent->mainstruct; $newevent->finalrounds = $oldevent->finalrounds; $newevent->finalstruct = $oldevent->finalstruct; $newevent->name = sprintf("%s %d.%02d", $newevent->series, $newevent->season, $newevent->number); eventForm($newevent, true); return; } else { if (!isset($event)) { if (!isset($_POST['series'])) { $_POST['series'] = ''; } if (!isset($_POST['season'])) { $_POST['season'] = ''; } eventList($_POST['series'], $_POST['season']); } } } if ($event && $event->authCheck($player)) { if (strcmp($_GET['action'], "undrop") == 0) { $event->undropPlayer($_GET['player']); } if (mode_is("Start Event")) { $event->active = 1; $event->save(); $entries = $event->getEntries(); Standings::startEvent($entries, $event->name); $event->pairCurrentRound(); } if (mode_is("Recalculate Standings")) { $structure = $event->mainstruct; $event->recalculateScores($structure); Standings::updateStandings($event->name, $event->mainid, 1); } if (mode_is("Reset Event")) { $event->resetEvent(); } if (mode_is("Delete Matches and Re-Pair Round")) { $event->repairRound(); } if (mode_is("Reactivate Event")) { $event->active = 1; $event->player_editdecks = 1; $event->finalized = 0; $event->save(); } if (mode_is("Assign Medals")) { $event->assignMedals(); } if (mode_is("Parse DCI Files")) { dciInput(); } elseif (mode_is("Parse DCIv3 Files")) { dci3Input(); } elseif (mode_is("Auto-Input Event Data")) { autoInput(); } elseif (mode_is("Update Registration")) { updateReg(); } elseif (mode_is("Update Match Listing")) { updateMatches(); } elseif (mode_is("Update Medals")) { updateMedals(); } elseif (mode_is("Update Adjustments")) { updateAdjustments(); } elseif (mode_is("Upload Trophy")) { if (insertTrophy()) { $event->hastrophy = 1; } } elseif (mode_is("Update Event Info")) { $event = updateEvent(); } eventForm($event); } else { authFailed(); } }