2019-09-06 11:48:50 +00:00
|
|
|
<?php
|
|
|
|
|
2019-09-06 23:33:05 +00:00
|
|
|
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN)
|
2019-09-07 11:42:36 +00:00
|
|
|
require_once "server_files/403.php";
|
2019-09-06 23:33:05 +00:00
|
|
|
|
2019-09-06 11:48:50 +00:00
|
|
|
$trigram = htmlspecialchars($_GET["trigram"]);
|
|
|
|
|
2019-09-06 23:33:05 +00:00
|
|
|
$team = Team::fromTrigram($trigram);
|
2019-09-07 23:35:05 +00:00
|
|
|
$tournament = Tournament::fromId($team->getTournamentId());
|
2019-09-06 23:33:05 +00:00
|
|
|
|
|
|
|
if ($team === null)
|
2019-09-07 11:42:36 +00:00
|
|
|
require_once "server_files/404.php";
|
2019-09-06 23:33:05 +00:00
|
|
|
|
2019-09-06 11:48:50 +00:00
|
|
|
if (isset($_POST["validate"])) {
|
2019-09-06 23:33:05 +00:00
|
|
|
$team->setValidationStatus(ValidationStatus::VALIDATED);
|
2020-01-16 22:00:31 +00:00
|
|
|
Mailer::sendValidateTeam($team, $_POST["message"]);
|
2019-09-06 11:48:50 +00:00
|
|
|
}
|
2020-01-16 22:00:31 +00:00
|
|
|
elseif (isset($_POST["unvalidate"])) {
|
|
|
|
$team->setValidationStatus(ValidationStatus::NOT_READY);
|
|
|
|
Mailer::sendUnvalidateTeam($team, $_POST["message"]);
|
|
|
|
}
|
|
|
|
|
2019-09-06 11:48:50 +00:00
|
|
|
|
|
|
|
if (isset($_POST["select"])) {
|
2019-09-06 23:33:05 +00:00
|
|
|
$team->selectForFinal(true);
|
|
|
|
$team->setValidationStatus(ValidationStatus::NOT_READY);
|
2019-09-09 10:15:48 +00:00
|
|
|
$sols = $tournament->getAllSolutions($team->getId());
|
|
|
|
/** @var Solution $sol */
|
|
|
|
foreach ($sols as $sol) {
|
|
|
|
$old_id = $sol->getFileId();
|
2019-09-08 22:41:52 +00:00
|
|
|
do
|
|
|
|
$id = genRandomPhrase(64);
|
2019-09-06 11:48:50 +00:00
|
|
|
while (file_exists("$LOCAL_PATH/files/$id"));
|
|
|
|
|
|
|
|
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
|
|
|
|
|
2019-09-07 23:35:05 +00:00
|
|
|
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
|
2019-09-09 10:15:48 +00:00
|
|
|
$req->execute([$id, $team->getId(), $FINAL->getId(), $sol->getFileId()]);
|
2019-09-06 11:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 10:15:48 +00:00
|
|
|
if (isset($_POST["download_zip"])) {
|
|
|
|
$final = isset($_POST["final"]);
|
2019-09-09 20:42:38 +00:00
|
|
|
$tournament_dest = $final ? $FINAL : $tournament;
|
2019-09-09 10:15:48 +00:00
|
|
|
|
2019-09-09 20:42:38 +00:00
|
|
|
$file_name = getZipFile(DocumentType::PARENTAL_CONSENT, $tournament_dest->getId(), $team->getId());
|
2019-09-09 10:15:48 +00:00
|
|
|
|
|
|
|
header("Content-Type: application/zip");
|
|
|
|
header("Content-Disposition: attachment; filename=\"Documents de l'équipe " . $team->getTrigram() . ".zip\"");
|
|
|
|
header("Content-Length: " . strval(filesize($file_name)));
|
|
|
|
|
|
|
|
readfile($file_name);
|
|
|
|
|
|
|
|
exit();
|
|
|
|
}
|
2019-09-06 11:48:50 +00:00
|
|
|
|
2019-09-07 23:35:05 +00:00
|
|
|
$documents = $tournament->getAllDocuments($team->getId());
|
|
|
|
$documents_final = null;
|
2019-09-06 11:48:50 +00:00
|
|
|
|
2019-09-07 23:35:05 +00:00
|
|
|
if ($team->isSelectedForFinal())
|
|
|
|
$documents_final = $FINAL->getAllDocuments($team->getId());
|
2019-09-06 23:33:05 +00:00
|
|
|
|
2019-09-07 11:42:36 +00:00
|
|
|
require_once "server_files/views/equipe.php";
|