75 lines
2.0 KiB
PHP
75 lines
2.0 KiB
PHP
<?php
|
|
|
|
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ADMIN)
|
|
require_once "server_files/403.php";
|
|
|
|
$trigram = htmlspecialchars($_GET["trigram"]);
|
|
|
|
$team = Team::fromTrigram($trigram);
|
|
|
|
if ($team === null)
|
|
require_once "server_files/404.php";
|
|
|
|
if (isset($_POST["validate"])) {
|
|
$team->setValidationStatus(ValidationStatus::VALIDATED);
|
|
Mailer::sendValidateTeam($team);
|
|
}
|
|
elseif (isset($_POST["unvalidate"])) {
|
|
$team->setValidationStatus(ValidationStatus::NOT_READY);
|
|
Mailer::sendUnvalidateTeam($team);
|
|
}
|
|
|
|
if (isset($_POST["download_zip"])) {
|
|
$file_name = getZipFile($team->getProblem(), $team->getId());
|
|
|
|
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();
|
|
}
|
|
|
|
if (isset($_POST["update_video_teams"])) {
|
|
$update_video_teams = new UpdateVideoTeams($_POST);
|
|
try {
|
|
$update_video_teams->makeVerifications();
|
|
$update_video_teams->update();
|
|
} catch (AssertionError $e) {
|
|
$has_error = true;
|
|
$error_message = $e->getMessage();
|
|
}
|
|
}
|
|
|
|
class UpdateVideoTeams
|
|
{
|
|
private $other_teams;
|
|
|
|
public function __construct($data)
|
|
{
|
|
foreach ($data as $key => $value)
|
|
$this->$key = $value;
|
|
}
|
|
|
|
public function makeVerifications()
|
|
{
|
|
ensure(Phase::getCurrentPhase() < Phase::PHASE2, "Il est trop tard pour réaffecter les vidéos aux équipes.");
|
|
ensure(sizeof($this->other_teams) == 2, "L'équipe doit recevoir exactement deux vidéos.");
|
|
ensure(Team::fromId($this->other_teams[0]) != null, "La première équipe n'existe pas.");
|
|
ensure(Team::fromId($this->other_teams[1]) != null, "La seconde équipe n'existe pas.");
|
|
}
|
|
|
|
public function update()
|
|
{
|
|
global $team;
|
|
|
|
$team->setVideoTeamIds($this->other_teams);
|
|
}
|
|
}
|
|
|
|
$other_teams = Team::getAllTeams($team->getProblem());
|
|
$documents = Document::getAllDocuments($team->getProblem(), $team->getId());
|
|
|
|
require_once "server_files/views/equipe.php";
|