Suppression de contenu inutile pour les correspondances

This commit is contained in:
galaxyoyo 2019-09-11 18:41:45 +02:00
parent 07e7b94f5c
commit 340be7faf5
34 changed files with 86 additions and 1985 deletions

View File

@ -6,7 +6,6 @@ require_once "server_files/classes/Document.php";
require_once "server_files/classes/Role.php";
require_once "server_files/classes/SchoolClass.php";
require_once "server_files/classes/Team.php";
require_once "server_files/classes/Tournament.php";
require_once "server_files/classes/User.php";
require_once "server_files/classes/ValidationStatus.php";
require_once "server_files/services/mail.php";
@ -26,8 +25,6 @@ $ROUTES = [];
$ROUTES["^(|accueil|index|accueil\.php|accueil\.html|accueil\.py|index\.php|index\.html|index\.py)$"] = ["server_files/controllers/index.php"];
$ROUTES["^ajouter_equipe$"] = ["server_files/controllers/ajouter_equipe.php"];
$ROUTES["^ajouter_organisateur$"] = ["server_files/controllers/ajouter_organisateur.php"];
$ROUTES["^ajouter_tournoi$"] = ["server_files/controllers/ajouter_tournoi.php"];
$ROUTES["^confirmer_mail/([a-z0-9]*)/?$"] = ["server_files/controllers/confirmer_mail.php", "token"];
$ROUTES["^connexion/(confirmation-mail)/?$"] = ["server_files/controllers/connexion.php", "confirmation-mail"];
$ROUTES["^connexion/(mdp_oublie)/?$"] = ["server_files/controllers/connexion.php", "mdp_oublie"];
@ -42,13 +39,6 @@ $ROUTES["^mon_compte/?$"] = ["server_files/controllers/mon_compte.php"];
$ROUTES["^mon_equipe/(modifier)/?$"] = ["server_files/controllers/mon_equipe.php", "modifier"];
$ROUTES["^mon_equipe/?$"] = ["server_files/controllers/mon_equipe.php"];
$ROUTES["^rejoindre_equipe/?$"] = ["server_files/controllers/rejoindre_equipe.php"];
$ROUTES["^solutions/?$"] = ["server_files/controllers/solutions.php"];
$ROUTES["^solutions_orga/?$"] = ["server_files/controllers/solutions_orga.php"];
$ROUTES["^syntheses/?$"] = ["server_files/controllers/syntheses.php"];
$ROUTES["^syntheses_orga/?$"] = ["server_files/controllers/syntheses_orga.php"];
$ROUTES["^tournoi/(.*)/(modifier)/?$"] = ["server_files/controllers/tournoi.php", "name", "modifier"];
$ROUTES["^tournoi/(.*)/?$"] = ["server_files/controllers/tournoi.php", "name"];
$ROUTES["^tournois/?$"] = ["server_files/controllers/tournois.php"];
# Assets files

View File

@ -5,7 +5,7 @@ class Document
private $file_id;
private $user_id;
private $team_id;
private $tournament_id;
private $problem;
private $type;
private $uploaded_at;
private $version;
@ -37,7 +37,7 @@ class Document
$this->file_id = $data["file_id"];
$this->user_id = $data["user"];
$this->team_id = $data["team"];
$this->tournament_id = $data["tournament"];
$this->problem = $data["problem"];
$this->type = DocumentType::fromName($data["type"]);
$this->uploaded_at = $data["uploaded_at"];
$this->version = isset($data["version"]) ? $data["version"] : 1;
@ -58,9 +58,9 @@ class Document
return $this->team_id;
}
public function getTournamentId()
public function getProblem()
{
return $this->tournament_id;
return $this->problem;
}
public function getType()
@ -77,242 +77,48 @@ class Document
{
return $this->version;
}
}
class Solution
{
private $file_id;
private $team_id;
private $tournament_id;
private $problem;
private $uploaded_at;
private $version;
private function __construct() {}
public static function fromId($id)
public function getAllDocuments($problem)
{
global $DB;
$req = $DB->prepare("SELECT * FROM `solutions` WHERE `file_id` = ?;");
$req->execute([htmlspecialchars($id)]);
$data = $req->fetch();
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
. "INNER JOIN (SELECT `user`, `type`, `problem`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `problem`, `type`, `user`) `t2` "
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`problem` = `t2`.`problem` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`problem` = $problem ORDER BY `t1`.`type`;");
if ($data === false)
return null;
$docs = [];
return self::fromData($data);
}
while (($data = $req->fetch()) !== false)
$docs[] = Document::fromData($data);
public static function fromData($data)
{
$sol = new Solution();
$sol->fill($data);
return $sol;
}
private function fill($data)
{
$this->file_id = $data["file_id"];
$this->team_id = $data["team"];
$this->tournament_id = $data["tournament"];
$this->problem = $data["problem"];
$this->uploaded_at = $data["uploaded_at"];
$this->version = isset($data["version"]) ? $data["version"] : 1;
}
public function getFileId()
{
return $this->file_id;
}
public function getTeamId()
{
return $this->team_id;
}
public function getTournamentId()
{
return $this->tournament_id;
}
public function getProblem()
{
return $this->problem;
}
public function getUploadedAt()
{
return $this->uploaded_at;
}
public function getVersion()
{
return $this->version;
}
}
class Synthesis
{
private $file_id;
private $team_id;
private $tournament_id;
private $dest;
private $uploaded_at;
private $version;
private function __construct() {}
public static function fromId($id)
{
global $DB;
$req = $DB->prepare("SELECT * FROM `syntheses` WHERE `file_id` = ?;");
$req->execute([htmlspecialchars($id)]);
$data = $req->fetch();
if ($data === false)
return null;
return self::fromData($data);
}
public static function fromData($data)
{
$synthese = new Synthesis();
$synthese->fill($data);
return $synthese;
}
private function fill($data)
{
$this->file_id = $data["file_id"];
$this->team_id = $data["team"];
$this->tournament_id = $data["tournament"];
$this->dest = DestType::fromName($data["dest"]);
$this->uploaded_at = $data["uploaded_at"];
$this->version = isset($data["version"]) ? $data["version"] : 1;
}
public function getFileId()
{
return $this->file_id;
}
public function getTeamId()
{
return $this->team_id;
}
public function getTournamentId()
{
return $this->tournament_id;
}
public function getDest()
{
return $this->dest;
}
public function getUploadedAt()
{
return $this->uploaded_at;
}
public function getVersion()
{
return $this->version;
}
}
class DestType
{
const DEFENSEUR = 0;
const OPPOSANT = 1;
const RAPPORTEUR = 2;
public static function getTranslatedName($status) {
switch ($status) {
case self::OPPOSANT:
return "Opposant";
case self::RAPPORTEUR:
return "Rapporteur";
default:
return "Défenseur";
}
}
public static function getName($status) {
switch ($status) {
case self::OPPOSANT:
return "OPPOSANT";
case self::RAPPORTEUR:
return "RAPPORTEUR";
default:
return "DEFENSEUR";
}
}
public static function fromName($name) {
switch ($name) {
case "OPPOSANT":
return self::OPPOSANT;
case "RAPPORTEUR":
return self::RAPPORTEUR;
default:
return self::DEFENSEUR;
}
return $docs;
}
}
class DocumentType
{
const PARENTAL_CONSENT = 0;
const PHOTO_CONSENT = 1;
const SANITARY_PLUG = 2;
const SOLUTION = 3;
const SYNTHESIS = 4;
const PHOTO_CONSENT = 0;
public static function getTranslatedName($type) {
switch ($type) {
case self::PARENTAL_CONSENT:
return "Autorisation parentale";
case self::PHOTO_CONSENT:
return "Autorisation de droit à l'image";
case self::SANITARY_PLUG:
return "Fiche sanitaire";
case self::SOLUTION:
return "Solution";
default:
return "Note de synthèse";
return "Autorisation de droit à l'image";
}
}
public static function getName($type) {
switch ($type) {
case self::PARENTAL_CONSENT:
return "PARENTAL_CONSENT";
case self::PHOTO_CONSENT:
return "PHOTO_CONSENT";
case self::SANITARY_PLUG:
return "SANITARY_PLUG";
case self::SOLUTION:
return "SOLUTION";
default:
return "SYNTHESIS";
return "PHOTO_CONSENT";
}
}
public static function fromName($name) {
switch ($name) {
case "PARENTAL_CONSENT":
return self::PARENTAL_CONSENT;
case "PHOTO_CONSENT":
return self::PHOTO_CONSENT;
case "SANITARY_PLUG":
return self::SANITARY_PLUG;
case "SOLUTION":
return self::SOLUTION;
default:
return self::SYNTHESIS;
return self::PHOTO_CONSENT;
}
}
}

View File

@ -4,15 +4,12 @@ class Role
{
const PARTICIPANT = 0;
const ENCADRANT = 1;
const ORGANIZER = 2;
const ADMIN = 3;
const ADMIN = 2;
public static function getTranslatedName($role) {
switch ($role) {
case self::ENCADRANT:
return "Encadrant";
case self::ORGANIZER:
return "Organisateur";
case self::ADMIN:
return "Administrateur";
default:
@ -24,8 +21,6 @@ class Role
switch ($role) {
case self::ENCADRANT:
return "ENCADRANT";
case self::ORGANIZER:
return "ORGANIZER";
case self::ADMIN:
return "ADMIN";
default:
@ -37,8 +32,6 @@ class Role
switch ($name) {
case "ENCADRANT":
return self::ENCADRANT;
case "ORGANIZER":
return self::ORGANIZER;
case "ADMIN":
return self::ADMIN;
default:

View File

@ -1,357 +0,0 @@
<?php
/** @noinspection SqlAggregates */
class Tournament
{
private $id;
private $name;
private $size;
private $place;
private $price;
private $description;
private $date_start, $date_end;
private $date_inscription;
private $date_solutions;
private $date_syntheses;
private $final;
private $organizers = [];
private $year;
private function __construct()
{
}
public static function fromId($id)
{
global $DB;
$req = $DB->prepare("SELECT * FROM `tournaments` WHERE `id` = ?;");
$req->execute([htmlspecialchars($id)]);
$data = $req->fetch();
if ($data === false)
return null;
$tournament = new Tournament();
$tournament->fill($data);
return $tournament;
}
public static function fromName($name)
{
global $DB, $YEAR;
$req = $DB->prepare("SELECT * FROM `tournaments` WHERE `name` = ? AND `year` = $YEAR;");
$req->execute([htmlspecialchars($name)]);
$data = $req->fetch();
if ($data === false)
return null;
$tournament = new Tournament();
$tournament->fill($data);
return $tournament;
}
public static function getFinalTournament()
{
global $DB, $YEAR;
$req = $DB->query("SELECT * FROM `tournaments` WHERE `final` AND `year` = $YEAR;");
$data = $req->fetch();
if ($data === false)
return null;
$tournament = new Tournament();
$tournament->fill($data);
return $tournament;
}
public static function getAllTournaments($include_final = true, $only_future = false)
{
global $DB, $YEAR;
$sql = "SELECT * FROM `tournaments` WHERE ";
if (!$include_final)
$sql .= "`final` = 0 AND ";
if ($only_future)
$sql .= "`date_start` > CURRENT_DATE AND ";
$sql .= "`year` = $YEAR ORDER BY `date_start`, `name`;";
$req = $DB->query($sql);
$tournaments = [];
while (($data = $req->fetch()) !== false) {
$tournament = new Tournament();
$tournament->fill($data);
$tournaments[] = $tournament;
}
return $tournaments;
}
private function fill($data)
{
$this->id = $data["id"];
$this->name = $data["name"];
$this->size = $data["size"];
$this->place = $data["place"];
$this->price = $data["price"];
$this->description = $data["description"];
$this->date_start = $data["date_start"];
$this->date_end = $data["date_end"];
$this->date_inscription = $data["date_inscription"];
$this->date_solutions = $data["date_solutions"];
$this->date_syntheses = $data["date_syntheses"];
$this->final = $data["final"] == true;
$this->year = $data["year"];
global $DB;
$req = $DB->prepare("SELECT `organizer` FROM `organizers` WHERE `tournament` = ?;");
$req->execute([$this->id]);
while (($data = $req->fetch()) !== false)
$this->organizers[] = User::fromId($data["organizer"]);
}
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
global $DB;
$this->name = $name;
$DB->prepare("UPDATE `tournaments` SET `name` = ? WHERE `id` = ?;")->execute([$name, $this->id]);
}
public function getSize()
{
return $this->size;
}
public function setSize($size)
{
global $DB;
$this->size = $size;
$DB->prepare("UPDATE `tournaments` SET `size` = ? WHERE `id` = ?;")->execute([$size, $this->id]);
}
public function getPlace()
{
return $this->place;
}
public function setPlace($place)
{
global $DB;
$this->place = $place;
$DB->prepare("UPDATE `tournaments` SET `place` = ? WHERE `id` = ?;")->execute([$place, $this->id]);
}
public function getPrice()
{
return $this->price;
}
public function setPrice($price)
{
global $DB;
$this->price = $price;
$DB->prepare("UPDATE `tournaments` SET `price` = ? WHERE `id` = ?;")->execute([$price, $this->id]);
}
public function getDescription()
{
return $this->description;
}
public function setDescription($desc)
{
global $DB;
$this->description = $desc;
$DB->prepare("UPDATE `tournaments` SET `description` = ? WHERE `id` = ?;")->execute([$desc, $this->id]);
}
public function getStartDate()
{
return $this->date_start;
}
public function setStartDate($date)
{
global $DB;
$this->date_start = $date;
$DB->prepare("UPDATE `tournaments` SET `date_start` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
}
public function getEndDate()
{
return $this->date_end;
}
public function setEndDate($date)
{
global $DB;
$this->date_end = $date;
$DB->prepare("UPDATE `tournaments` SET `date_end` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
}
public function getInscriptionDate()
{
return $this->date_inscription;
}
public function setInscriptionDate($date)
{
global $DB;
$this->date_inscription = $date;
$DB->prepare("UPDATE `tournaments` SET `date_inscription` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
}
public function getSolutionsDate()
{
return $this->date_solutions;
}
public function setSolutionsDate($date)
{
global $DB;
$this->date_solutions = $date;
$DB->prepare("UPDATE `tournaments` SET `date_solutions` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
}
public function getSynthesesDate()
{
return $this->date_syntheses;
}
public function setSynthesesDate($date)
{
global $DB;
$this->date_syntheses = $date;
$DB->prepare("UPDATE `tournaments` SET `date_syntheses` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
}
public function isFinal()
{
return $this->final;
}
public function setFinal($final)
{
global $DB;
$this->final = $final;
$DB->prepare("UPDATE `tournaments` SET `final` = ? WHERE `id` = ?;")->execute([$final, $this->id]);
}
public function getAllTeams()
{
global $DB, $YEAR;
if ($this->final)
$req = $DB->query("SELECT `id` FROM `teams` WHERE `final_selection` AND `year` = $YEAR;");
else
$req = $DB->query("SELECT `id` FROM `teams` WHERE `tournament` = $this->id AND `year` = $YEAR;");
$teams = [];
while (($data = $req->fetch()) !== false)
$teams[] = Team::fromId($data["id"]);
return $teams;
}
public function getOrganizers()
{
return $this->organizers;
}
public function organize($user_id)
{
foreach ($this->organizers as $organizer) {
if ($organizer->getId() == $user_id)
return true;
}
return false;
}
public function addOrganizer(User $user)
{
global $DB;
$this->organizers[] = $user;
$req = $DB->prepare("INSERT INTO `organizers`(`organizer`, `tournament`) VALUES(?, ?);");
$req->execute([$user->getId(), $this->id]);
}
public function clearOrganizers()
{
global $DB;
$this->organizers = [];
$req = $DB->prepare("DELETE FROM `organizers` WHERE `tournament` = ?;");
$req->execute([$this->id]);
}
public function getYear()
{
return $this->year;
}
public function getAllDocuments($team_id = -1)
{
global $DB;
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
. "INNER JOIN (SELECT `user`, `type`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `tournament`, `team`, `type`, `user`) `t2` "
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`tournament` = `t2`.`tournament` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`type`;");
$docs = [];
while (($data = $req->fetch()) !== false)
$docs[] = Document::fromData($data);
return $docs;
}
public function getAllSolutions($team_id = -1)
{
global $DB;
$req = $DB->query("SELECT * FROM `solutions` AS `t1` "
. "INNER JOIN (SELECT `team`, `problem`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `solutions` GROUP BY `tournament`, `team`, `problem`) `t2` "
. "ON `t1`.`team` = `t2`.`team` AND `t1`.`problem` = `t2`.`problem` AND `t1`.`tournament` = `t2`.`tournament` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`problem`;");
$sols = [];
while (($data = $req->fetch()) !== false)
$sols[] = Solution::fromData($data);
return $sols;
}
public function getAllSyntheses($team_id = -1)
{
global $DB;
$req = $DB->query("SELECT * FROM `syntheses` AS `t1` "
. "INNER JOIN (SELECT `team`, `dest`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `syntheses` GROUP BY `tournament`, `team`, `dest`) `t2` "
. "ON `t1`.`team` = `t2`.`team` AND `t1`.`dest` = `t2`.`dest` AND `t1`.`tournament` = `t2`.`tournament` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`dest`;");
$syntheses = [];
while (($data = $req->fetch()) !== false)
$syntheses[] = Synthesis::fromData($data);
return $syntheses;
}
}

View File

@ -220,13 +220,13 @@ class User
return $this->inscription_date;
}
public function getAllDocuments($tournament_id)
public function getAllDocuments($problem)
{
global $DB;
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
. "INNER JOIN (SELECT `user`, `type`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `tournament`, `type`, `user`) `t2` "
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`tournament` = `t2`.`tournament` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $tournament_id AND `t1`.`user` = $this->id ORDER BY `t1`.`type`;");
. "INNER JOIN (SELECT `user`, `type`, `problem`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `problem`, `type`, `user`) `t2` "
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`problem` = `t2`.`problem` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`problem` = $problem AND `t1`.`user` = $this->id ORDER BY `t1`.`type`;");
$docs = [];
@ -235,17 +235,4 @@ class User
return $docs;
}
public function getOrganizedTournaments()
{
global $DB;
$req = $DB->query("SELECT `tournament` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $this->id ORDER BY `date_start`, `name`;");
$tournaments = [];
while (($data = $req->fetch()) !== false)
$tournaments[] = Tournament::fromId($data["tournament"]);
return $tournaments;
}
}

View File

@ -52,7 +52,7 @@ class NewTeam {
$_SESSION["team"] = Team::fromTrigram($this->trigram);
$_SESSION["user"]->setTeamId($_SESSION["team"]->getId());
Mailer::sendAddTeamMail($_SESSION["user"], $_SESSION["team"], $this->problem);
Mailer::sendAddTeamMail($_SESSION["user"], $_SESSION["team"]);
}
}

View File

@ -1,57 +0,0 @@
<?php
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
$has_error = false;
$error_message = null;
if (isset($_POST["submitted"])) {
$orga = new NewOrganizer($_POST);
try {
$orga->makeVerifications();
$orga->register();
}
catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
class NewOrganizer {
public $surname;
public $first_name;
public $email;
public $admin;
public $password;
public function __construct($data)
{
foreach ($data as $key => $value)
$this->$key = htmlspecialchars($value);
}
public function makeVerifications()
{
ensure($this->surname != null && $this->surname != "", "Le nom est invalide.");
ensure($this->first_name != null && $this->first_name != "", "Le prénom est invalide.");
ensure(filter_var($this->email, FILTER_VALIDATE_EMAIL), "L'adresse e-mail est invalide.");
$this->email = strtolower($this->email);
ensure(!userExists($this->email), "Cette adresse e-mail est déjà utilisée.");
$this->admin = $this->admin == "on" ? true : false;
}
public function register() {
global $DB, $YEAR;
$this->password = genRandomPhrase(16, true);
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `surname`, `first_name`, `role`, `year`)
VALUES (?, ?, ?, ?, ?, ?);");
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->surname, $this->first_name, $this->admin ? "ADMIN" : "ORGANIZER", $YEAR]);
Mailer::sendAddOrganizerMail($this);
}
}
require_once "server_files/views/ajouter_organisateur.php";

View File

@ -1,99 +0,0 @@
<?php
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
$has_error = false;
$error_message = null;
if (isset($_POST["submitted"])) {
$tournament = new NewTournament($_POST);
try {
$tournament->makeVerifications();
$tournament->register();
}
catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
class NewTournament {
public $name;
public $organizers;
public $size;
public $place;
public $price;
public $date_start;
public $date_end;
public $date_inscription;
public $time_inscription;
public $date_solutions;
public $time_solutions;
public $date_syntheses;
public $time_syntheses;
public $description;
public $final;
public $tournament;
public function __construct($data)
{
foreach ($data as $key => $value)
$this->$key = ($key == "organizers" ? $value : htmlspecialchars($value));
}
public function makeVerifications()
{
global $FINAL;
ensure($this->name != null && $this->name != "", "Le nom est invalide.");
ensure(!tournamentExists($this->name), "Un tournoi existe déjà avec ce nom.");
ensure(sizeof($this->organizers) > 0, "Aucun organisateur n'a été choisi.");
$orgas = [];
foreach ($this->organizers as $orga_id) {
$orga = User::fromId($orga_id);
ensure($orga != null, "Un organisateur spécifié n'existe pas.");
ensure($orga->getRole() == Role::ORGANIZER || $orga->getRole() == Role::ADMIN, "Une personne indiquée ne peut pas organiser de tournoi.");
$orgas[] = $orga;
}
$this->organizers = $orgas;
ensure(preg_match("#[0-9]*#", $this->size), "Le nombre d'équipes indiqué n'est pas un nombre valide.");
$this->size = intval($this->size);
ensure($this->size >= 3 && $this->size <= 15, "Un tournoi doit avoir au moins 3 et au plus 15 équipes.");
ensure(dateWellFormed($this->date_start), "La date de début n'est pas valide.");
ensure(dateWellFormed($this->date_end), "La date de fin n'est pas valide.");
ensure(dateWellFormed($this->date_inscription . " " . $this->time_inscription), "La date de clôture des inscriptions n'est pas valide.");
ensure(dateWellFormed($this->date_solutions . " " . $this->time_solutions), "La date limite de remise des solutions n'est pas valide.");
ensure(dateWellFormed($this->date_syntheses . " " . $this->time_syntheses), "La date limite de remise des notes de synthèse n'est pas valide.");
$this->final = $this->final ? 1 : 0;
ensure(!$this->final || $FINAL == NULL, "Une finale nationale est déjà enregistrée.");
}
public function register()
{
global $DB, $YEAR;
$req = $DB->prepare("INSERT INTO `tournaments` (`name`, `size`, `place`, `price`, `description`,
`date_start`, `date_end`, `date_inscription`, `date_solutions`, `date_syntheses`, `final`, `year`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
$req->execute([$this->name, $this->size, $this->place, $this->price, $this->description, $this->date_start, $this->date_end,
"$this->date_inscription $this->time_inscription", "$this->date_solutions $this->time_solutions", "$this->date_syntheses $this->time_syntheses", $this->final ? 1 : 0, $YEAR]);
$this->tournament = Tournament::fromName($this->name);
/** @var User $organizer */
foreach ($this->organizers as $organizer) {
$this->tournament->addOrganizer($organizer);
Mailer::sendAddOrganizerForTournamentMail($organizer, $this->tournament);
}
}
}
require_once "server_files/views/ajouter_tournoi.php";

View File

@ -1,6 +1,6 @@
<?php
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN)
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
$trigram = htmlspecialchars($_GET["trigram"]);
@ -15,9 +15,7 @@ if (isset($_POST["validate"])) {
}
if (isset($_POST["download_zip"])) {
$final = isset($_POST["final"]);
$file_name = getZipFile(DocumentType::PARENTAL_CONSENT, $tournament->getId(), $team->getId());
$file_name = getZipFile(DocumentType::PHOTO_CONSENT, $team->getProblem(), $team->getId());
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"Documents de l'équipe " . $team->getTrigram() . ".zip\"");
@ -28,7 +26,6 @@ if (isset($_POST["download_zip"])) {
exit();
}
$documents = $tournament->getAllDocuments($team->getId());
$documents_final = null;
$documents = Document::getAllDocuments($team->getId());
require_once "server_files/views/equipe.php";

View File

@ -6,7 +6,7 @@ if (!isset($_SESSION["role"]))
$id = $_GET["id"];
$user = User::fromId($id);
if ($_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN) {
if ($_SESSION["role"] != Role::ADMIN) {
if ($user->getId() != $_SESSION["user_id"] && ($user->getTeamId() == null || $user->getTeamId() != $_SESSION["user"]->getTeamId()))
require_once "server_files/403.php";
}
@ -17,7 +17,7 @@ if ($user === null)
$team = Team::fromId($user->getTeamId());
if ($team != null) {
//$documents = $user->getAllDocuments($team->getTournamentId());
$documents = $user->getAllDocuments($team->getProblem());
}
require_once "server_files/views/informations.php";

View File

@ -33,7 +33,7 @@ if (isset($_POST["team_edit"])) {
}
if (isset($_POST["request_validation"])) {
if (!canValidate($team, $tournament))
if (!canValidate($team))
$error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
else
$_SESSION["team"]->setValidationStatus(ValidationStatus::WAITING);
@ -47,7 +47,7 @@ if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"]
$user = $_SESSION["user"];
$team = $_SESSION["team"];
//$documents = $user->getAllDocuments($team->getTournamentId());
$documents = $user->getAllDocuments($team->getProblem());
}
else
require_once "server_files/403.php";
@ -75,7 +75,7 @@ class SendDocument
public function sendDocument()
{
global $LOCAL_PATH, $DB, $FINAL;
global $LOCAL_PATH, $DB;
do
$id = genRandomPhrase(64);
@ -84,9 +84,9 @@ class SendDocument
if (!rename($this->file["tmp_name"], "$LOCAL_PATH/files/$id"))
throw new AssertionError("Une erreur est survenue lors de l'envoi du fichier.");
$req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `tournament`, `type`)
$req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `problem`, `type`)
VALUES (?, ?, ?, ?, ?);");
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team"]->getId(), $_SESSION["team"]->isSelectedForFinal() ? $FINAL->getId() : $_SESSION["team"]->getTournamentId(), $this->type]);
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team"]->getId(), $_SESSION["team"]->getProblem(), $this->type]);
}
}
@ -94,9 +94,9 @@ class MyTeam
{
public $name;
public $trigram;
public $tournament_id;
public $problem;
/** @var Team */
private $team;
private $tournament;
public function __construct($data)
{
@ -105,7 +105,6 @@ class MyTeam
$this->trigram = strtoupper($this->trigram);
$this->team = $_SESSION["team"];
$this->tournament = Tournament::fromId($this->tournament_id);
}
public function makeVerifications()
@ -114,8 +113,8 @@ class MyTeam
ensure($this->name == $this->team->getName() || !teamExists($this->name), "Une équipe existe déjà avec ce nom.");
ensure(preg_match("#^[A-Z]{3}$#", $this->trigram), "Le trigramme n'est pas valide.");
ensure($this->trigram == $this->team->getTrigram() || !trigramExists($this->trigram), "Une équipe a déjà choisi ce trigramme.");
ensure($this->tournament != null, "Le tournoi indiqué n'existe pas.");
ensure(date("y-m-d H:i:s") <= $this->tournament->getInscriptionDate(), "Les inscriptions sont terminées.");
ensure(preg_match("#^[1-4]$#", $this->problem), "Le problème indiqué n'existe pas.");
// ensure(date("y-m-d H:i:s") <= $this->tournament->getInscriptionDate(), "Les inscriptions sont terminées.");
ensure($this->team->getValidationStatus() == ValidationStatus::NOT_READY, "Votre équipe est déjà validée ou en cours de validation.");
}
@ -125,9 +124,7 @@ class MyTeam
$this->team->setName($this->name);
$this->team->setTrigram($this->trigram);
$this->team->setTournamentId($this->tournament_id);
$_SESSION["tournament"] = $this->tournament;
$this->team->setProblem($this->problem);
header("Location: $URL_BASE/mon_equipe");
}

View File

@ -35,8 +35,8 @@ class JoinTeam
ensure($this->team != null, "Ce code d'accès est invalide.");
ensure($this->team->getValidationStatus() == ValidationStatus::NOT_READY, "Cette équipe est déjà validée ou en cours de validation, vous ne pouvez pas la rejoindre.");
for ($i = 1; $i <= $_SESSION["role"] == Role::PARTICIPANT ? 6 : 2; ++$i) {
if (($_SESSION["role"] == Role::PARTICIPANT ? $this->team->getParticipants()[$i - 1] : $this->team->getEncadrants()[$i - 1]) == NULL)
for ($i = 1; $i <= $_SESSION["role"] == Role::PARTICIPANT ? 6 : 1; ++$i) {
if (($_SESSION["role"] == Role::PARTICIPANT ? $this->team->getParticipants()[$i - 1] : $this->team->getEncadrantId()) == NULL)
break;
}
@ -52,14 +52,13 @@ class JoinTeam
$user->setTeamId($this->team->getId());
if ($_SESSION["role"] == Role::ENCADRANT)
$this->team->setEncadrant($this->min_null_index, $user->getId());
$this->team->setEncadrant($user->getId());
else
$this->team->setParticipant($this->min_null_index, $user->getId());
$_SESSION["team"] = $this->team;
$tournament = $_SESSION["tournament"] = Tournament::fromId($this->team->getTournamentId());
Mailer::sendJoinTeamMail($user, $this->team, $tournament);
Mailer::sendJoinTeamMail($user, $this->team);
}
}

View File

@ -1,72 +0,0 @@
<?php
if (!isset($_SESSION["team"]))
require_once "server_files/403.php";
/**
* @var Team $team
* @var Tournament $tournament
*/
$team = $_SESSION["team"];
$tournament = Tournament::fromId($team->getTournamentId());
$has_error = false;
$error_message = null;
if (isset($_POST["send_solution"])) {
$save_solution = new SaveSolution();
try {
$save_solution->makeVerifications();
$save_solution->saveSolution();
} catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
$solutions = $tournament->getAllSolutions($team->getId());
$solutions_final = null;
if ($team->isSelectedForFinal())
$solutions_final = $FINAL->getAllSolutions($team->getId());
class SaveSolution
{
private $problem;
private $file;
public function __construct()
{
$this->file = $_FILES["document"];
$this->problem = htmlspecialchars($_POST["problem"]);
}
public function makeVerifications()
{
global $LOCAL_PATH;
ensure(preg_match("#[1-9]#", $this->problem), "Le numéro du problème est invalide.");
ensure($this->file["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
ensure(!$this->file["error"], "Une erreur est survenue.");
ensure(finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]) == "application/pdf", "Le fichier doit être au format PDF.");
ensure(is_dir("$LOCAL_PATH/files") || mkdir("$LOCAL_PATH/files"), "Un problème est survenue dans l'envoi du fichier. Veuillez contacter l'administrateur du serveur.");
}
public function saveSolution()
{
global $LOCAL_PATH, $DB, $team, $tournament, $FINAL;
do
$id = genRandomPhrase(64);
while (file_exists("$LOCAL_PATH/files/$id"));
if (!rename($this->file["tmp_name"], "$LOCAL_PATH/files/$id"))
throw new AssertionError("Une erreur est survenue lors de l'envoi du fichier.");
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $this->problem]);
return false;
}
}
require_once "server_files/views/solutions.php";

View File

@ -1,24 +0,0 @@
<?php
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
require_once "server_files/403.php";
if (isset($_POST["download_zip"])) {
$id = $_POST["tournament"];
$tournament = Tournament::fromId($id);
$file_name = getZipFile(DocumentType::SOLUTION, $id);
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"Solutions du tournoi de " . $tournament->getName() . ".zip\"");
header("Content-Length: " . strval(filesize($file_name)));
readfile($file_name);
exit();
}
$user = $_SESSION["user"];
$tournaments = $_SESSION["role"] == Role::ADMIN ? Tournament::getAllTournaments() : $user->getOrganizedTournaments();
require_once "server_files/views/solutions_orga.php";

View File

@ -1,68 +0,0 @@
<?php
if (!isset($_SESSION["team"]))
require_once "server_files/403.php";
/**
* @var Team $team
* @var Tournament $tournament
*/
$team = $_SESSION["team"];
$tournament = Tournament::fromId($team->getTournamentId());
if (isset($_POST["send_synthesis"])) {
$save_synthesis = new SaveSynthesis();
try {
$save_synthesis->makeVerifications();
$save_synthesis->saveSynthesis();
} catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
$syntheses = $tournament->getAllSyntheses($team->getId());
$syntheses_final = null;
if ($team->isSelectedForFinal())
$syntheses_final = $FINAL->getAllSyntheses($team->getId());
class SaveSynthesis
{
private $dest;
private $file;
public function __construct()
{
$this->file = $_FILES["document"];
$this->dest = DestType::fromName(strtoupper(htmlspecialchars($_POST["problem"])));
}
public function makeVerifications()
{
global $LOCAL_PATH;
ensure($this->dest != DestType::DEFENSEUR, "Le destinataire est invalide.");
ensure($this->file["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
ensure(!$this->file["error"], "Une erreur est survenue.");
ensure(finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]) == "application/pdf", "Le fichier doit être au format PDF.");
ensure(is_dir("$LOCAL_PATH/files") || mkdir("$LOCAL_PATH/files"), "Un problème est survenue dans l'envoi du fichier. Veuillez contacter l'administrateur du serveur.");
}
public function saveSynthesis()
{
global $LOCAL_PATH, $DB, $team, $tournament, $FINAL;
do
$id = genRandomPhrase(64);
while (file_exists("$LOCAL_PATH/files/$id"));
if (!rename($this->file["tmp_name"], "$LOCAL_PATH/files/$id"))
throw new AssertionError("Une erreur est survenue lors de l'envoi du fichier.");
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $this->dest]);
return false;
}
}
require_once "server_files/views/syntheses.php";

View File

@ -1,22 +0,0 @@
<?php if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
require_once "server_files/403.php";
if (isset($_POST["download_zip"])) {
$id = $_POST["tournament"];
$tournament = Tournament::fromId($id);
$file_name = getZipFile(DocumentType::SYNTHESIS, $id);
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"Notes de syntèses du tournoi de " . $tournament->getName() . ".zip\"");
header("Content-Length: " . filesize($file_name));
readfile($file_name);
exit();
}
$user = $_SESSION["user"];
$tournaments = $_SESSION["role"] == Role::ADMIN ? Tournament::getAllTournaments() : $user->getOrganizedTournaments();
require_once "server_files/views/syntheses_orga.php";

View File

@ -1,120 +0,0 @@
<?php
$tournament_name = htmlspecialchars($_GET["name"]);
$tournament = Tournament::fromName($tournament_name);
if ($tournament === null)
require_once "server_files/404.php";
if (isset($_GET["modifier"]) && $_SESSION["role"] != Role::ADMIN && !$tournament->organize($_SESSION["user_id"]))
require_once "server_files/403.php";
$has_error = false;
$error_message = null;
if (isset($_POST["edit_tournament"])) {
$update_tournament = new UpdateTournament($_POST);
try {
$update_tournament->makeVerifications();
$update_tournament->updateTournament();
} catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
$orgas = $tournament->getOrganizers();
$teams = $tournament->getAllTeams();
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
class UpdateTournament
{
public $name;
public $organizers;
public $size;
public $place;
public $price;
public $date_start;
public $date_end;
public $date_inscription;
public $time_inscription;
public $date_solutions;
public $time_solutions;
public $date_syntheses;
public $time_syntheses;
public $description;
public $final;
public function __construct($data)
{
global $tournament;
foreach ($data as $key => $value)
$this->$key = ($key == "organizers" ? $value : htmlspecialchars($value));
if ($_SESSION["role"] != Role::ADMIN) {
$this->organizers = [];
/** @var User $organizer */
foreach ($tournament->getOrganizers() as $organizer)
$this->organizers[] = $organizer->getId();
}
}
public function makeVerifications()
{
global $tournament;
ensure($this->name != null && $this->name != "", "Le nom est invalide.");
ensure($this->name == $tournament->getName() || !tournamentExists($this->name), "Un tournoi existe déjà avec ce nom.");
ensure(sizeof($this->organizers) > 0, "Aucun organisateur n'a été choisi.");
$orgas = [];
foreach ($this->organizers as $orga_id) {
$orga = User::fromId($orga_id);
ensure($orga != null, "Un organisateur spécifié n'existe pas.");
ensure($orga->getRole() == Role::ORGANIZER || $orga->getRole() == Role::ADMIN, "Une personne indiquée ne peut pas organiser de tournoi.");
$orgas[] = $orga;
}
$this->organizers = $orgas;
ensure(preg_match("#[0-9]*#", $this->size), "Le nombre d'équipes indiqué n'est pas un nombre valide.");
$this->size = intval($this->size);
ensure($this->size >= 3 && $this->size <= 15, "Un tournoi doit avoir au moins 3 et au plus 15 équipes.");
ensure(dateWellFormed($this->date_start), "La date de début n'est pas valide.");
ensure(dateWellFormed($this->date_end), "La date de fin n'est pas valide.");
ensure(dateWellFormed($this->date_inscription . " " . $this->time_inscription), "La date de clôture des inscriptions n'est pas valide.");
ensure(dateWellFormed($this->date_solutions . " " . $this->time_solutions), "La date limite de remise des solutions n'est pas valide.");
ensure(dateWellFormed($this->date_syntheses . " " . $this->time_syntheses), "La date limite de remise des notes de synthèse n'est pas valide.");
}
public function updateTournament()
{
global $URL_BASE, $tournament;
$tournament->setName($this->name);
$tournament->setSize($this->size);
$tournament->setPlace($this->place);
$tournament->setPrice($this->price);
$tournament->setStartDate($this->date_start);
$tournament->setEndDate($this->date_end);
$tournament->setInscriptionDate("$this->date_inscription $this->time_inscription");
$tournament->setSolutionsDate("$this->date_solutions $this->time_solutions");
$tournament->setSynthesesDate("$this->date_syntheses $this->time_syntheses");
foreach ($this->organizers as $organizer) {
if (!$tournament->organize($organizer->getId()))
Mailer::sendAddOrganizerForTournamentMail($organizer, $tournament);
}
$tournament->clearOrganizers();
/** @var User $organizer */
foreach ($this->organizers as $organizer)
$tournament->addOrganizer($organizer);
header("Location: $URL_BASE/tournoi/" . $this->name);
exit();
}
}
require_once "server_files/views/tournoi.php";

View File

@ -1,5 +0,0 @@
<?php
$tournaments = Tournament::getAllTournaments();
require_once "server_files/views/tournois.php";

View File

@ -10,64 +10,22 @@ if (!isset($_SESSION["user_id"]))
$id = htmlspecialchars($_GET["file_id"]);
$type = DocumentType::SOLUTION;
$file = Solution::fromId($id);
if ($file === null) {
$type = DocumentType::SYNTHESIS;
$file = Synthesis::fromId($id);
if ($file === null) {
$file = Document::fromId($id);
$type = DocumentType::PARENTAL_CONSENT;
}
}
$file = Document::fromId($id);
if ($file !== null) {
$team = Team::fromId($file->getTeamId());
$tournament = Tournament::fromId($file->getTournamentId());
$team = Team::fromId($file->getTeamId());;
$trigram = $team->getTrigram();
if ($_SESSION["role"] == Role::ORGANIZER && !$tournament->organize($_SESSION["user_id"]))
$user = User::fromId($file->getUserId());
$type = $file->getType();
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && $user->getId() != $_SESSION["user_id"])
require_once "server_files/403.php";
if ($type == DocumentType::SOLUTION) {
$problem = $file->getProblem();
$name = "Problème $problem $trigram.pdf";
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId()))
require_once "server_files/403.php";
}
else if ($type == DocumentType::SYNTHESIS) {
$dest = $file->getDest();
$name = "Note de synthèse $trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf";
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId()))
require_once "server_files/403.php";
}
else {
$user = User::fromId($file->getUserId());
$type = $file->getType();
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && $user->getId() != $_SESSION["user_id"])
require_once "server_files/403.php";
$surname = $user->getSurname();
$first_name = $user->getFirstName();
switch ($type) {
case DocumentType::PARENTAL_CONSENT:
$name = "Autorisation parentale";
break;
case DocumentType::PHOTO_CONSENT:
$name = "Autorisation de droit à l'image";
break;
case DocumentType::SANITARY_PLUG:
$name = "Fiche sanitaire";
break;
}
$name .= " de $first_name $surname.pdf";
}
}
else
$surname = $user->getSurname();
$first_name = $user->getFirstName();
$name = "Autorisation de droit à l'image de $first_name $surname.pdf";
} else
require_once "server_files/404.php";
header("Content-Type: application/pdf");

View File

@ -2,11 +2,10 @@
function loadUserValues()
{
$_SESSION["user"] = $_SESSION["team"] = $_SESSION["tournament"] = null;
$_SESSION["user"] = $_SESSION["team"] = null;
unset($_SESSION["user"]);
unset($_SESSION["role"]);
unset($_SESSION["team"]);
unset($_SESSION["tournament"]);
if (isset($_SESSION["user_id"])) {
$user = $_SESSION["user"] = User::fromId($_SESSION["user_id"]);
@ -21,12 +20,6 @@ function loadUserValues()
exit();
}
if (isset($_GET["be-organizer"])) {
quitTeam();
$user->setRole(Role::ORGANIZER);
exit();
}
if (isset($_GET["be-participant"])) {
quitTeam();
$user->setRole(Role::PARTICIPANT);
@ -52,14 +45,16 @@ function quitTeam()
$user_id = $user->getId();
$role = $user->getRole();
if ($role == Role::ADMIN || $role == Role::ORGANIZER)
if ($role == Role::ADMIN)
return;
for ($i = 1; $i <= ($role == Role::ENCADRANT ? 2 : 6); ++$i)
/** @noinspection SqlResolve */
$DB->exec("UPDATE `teams` SET `" . strtolower(Role::getName($role)) . "_$i` = NULL WHERE `" . strtolower(Role::getName($role)) . "_$i` = $user_id;");
if ($role == Role::PARTICIPANT)
for ($i = 1; $i <= 6; ++$i)
/** @noinspection SqlResolve */
$DB->exec("UPDATE `teams` SET `participant_$i` = NULL WHERE `participant_$i` = $user_id;");
else
$DB->exec("UPDATE `teams` SET `encadrant` = NULL WHERE `encadrant` = $user_id;");
$user->setTeamId(null);
$DB->exec("UPDATE `teams` SET `encadrant_1` = `encadrant_2`, `encadrant_2` = NULL WHERE `encadrant_1` IS NULL;");
for ($i = 1; $i <= 5; ++$i) {
/** @noinspection SqlResolve */
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
@ -70,19 +65,6 @@ function quitTeam()
unlink("$URL_BASE/files/" . $data["file_id"]);
$DB->exec("DELETE FROM `documents` WHERE `user` = $user_id;");
if ($DB->exec("DELETE FROM `teams` WHERE `encadrant_1` IS NULL AND `participant_1` IS NULL;") > 0) {
$team_id = $user->getTeamId();
$req = $DB->query("SELECT `file_id` FROM `solutions` WHERE `team` = $team_id;");
while (($data = $req->fetch()) !== false)
unlink("$URL_BASE/files/" . $data["file_id"]);
$DB->exec("DELETE FROM `solutions` WHERE `team` = $team_id;");
$req = $DB->query("SELECT `file_id` FROM `syntheses` WHERE `team` = $team_id;");
while (($data = $req->fetch()) !== false)
unlink("$URL_BASE/files/" . $data["file_id"]);
$DB->exec("DELETE FROM `syntheses` WHERE `team` = $team_id;");
}
$_SESSION["team"] = null;
unset($_SESSION["team"]);
}
@ -114,57 +96,29 @@ function trigramExists($trigram)
return $req->fetch();
}
function tournamentExists($name)
function canValidate(Team $team)
{
global $DB, $YEAR;
$req = $DB->prepare("SELECT `id` FROM `tournaments` WHERE `name` = ? AND `year` = '$YEAR';");
$req->execute([$name]);
return $req->fetch();
}
function canValidate(Team $team, Tournament $tournament)
{
global $DB, $YEAR;
global $DB;
$can_validate = $team->getValidationStatus() == ValidationStatus::NOT_READY;
$can_validate &= $team->getEncadrants()[0] != NULL;
$can_validate &= $team->getParticipants()[3] != NULL;
for ($i = 1; $i <= 2; ++$i) {
if ($team->getEncadrants()[$i - 1] === NULL)
continue;
$can_validate &= $team->getEncadrantId() != null;
$can_validate &= $team->getParticipants()[3] != null;
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? AND `type` = ?;");
$req->execute([$team->getEncadrants()[$i - 1], $tournament->getId(), "PHOTO_CONSENT"]);
$d = $req->fetch();
$can_validate &= $d["version"] > 0;
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? AND `type` = ?;");
$req->execute([$team->getEncadrants()[$i - 1], $tournament->getId(), "SANITARY_PLUG"]);
if ($team->getEncadrantId() != null) {
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `problem` = ? AND `type` = ?;");
$req->execute([$team->getEncadrantId(), $team->getProblem(), "PHOTO_CONSENT"]);
$d = $req->fetch();
$can_validate &= $d["version"] > 0;
}
for ($i = 1; $i <= 6; ++$i) {
if ($team->getParticipants()[$i] === NULL)
continue;
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? AND `type` = ?;");
$req->execute([$team->getParticipants()[$i], $tournament->getId(), "PHOTO_CONSENT"]);
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `problem` = ? AND `type` = ?;");
$req->execute([$team->getParticipants()[$i], $team->getProblem(), "PHOTO_CONSENT"]);
$d = $req->fetch();
$can_validate &= $d["version"] > 0;
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? AND `type` = ?;");
$req->execute([$team->getParticipants()[$i], $tournament->getId(), "SANITARY_PLUG"]);
$d = $req->fetch();
$can_validate &= $d["version"] > 0;
$birth_date = $DB->query("SELECT `birth_date` FROM `users` WHERE `id` = " . $team->getParticipants()[$i] . ";")->fetch()["birth_date"];
if ($birth_date > strval($YEAR - 18) . substr($tournament->getStartDate(), 4)) {
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? AND `type` = ?;");
$req->execute([$team->getParticipants()[$i], $tournament->getId(), "PARENTAL_CONSENT"]);
$d = $req->fetch();
$can_validate &= $d["version"] > 0;
}
}
return $can_validate;
@ -185,11 +139,9 @@ function printDocuments($documents)
}
}
function getZipFile($document_type, $tournament_id, $team_id = -1)
function getZipFile($problem, $team_id = -1)
{
global $LOCAL_PATH;
$tournament = Tournament::fromId($tournament_id);
global $LOCAL_PATH, $DB;
$zip = new ZipArchive();
@ -199,44 +151,16 @@ function getZipFile($document_type, $tournament_id, $team_id = -1)
die("Impossible de créer le fichier zip.");
}
switch ($document_type) {
case DocumentType::SOLUTION:
$data = $tournament->getAllSolutions($team_id);
break;
case DocumentType::SYNTHESIS:
$data = $tournament->getAllSyntheses($team_id);
break;
default:
$data = $tournament->getAllDocuments($team_id);
break;
}
// TODO Replace DB query
$resp = $DB->query("SELECT * FROM `documents` WHERE `problem` = $problem" . ($team_id >= 0 ? " AND `team` = $team_id" : "") . ";");
/** @var Document | Solution | Synthesis $file */
foreach ($data as $file) {
/** @var Document $file */
//foreach ($data as $file) {
while (($data = $resp->fetch()) != false) {
$file = Document::fromData($data);
$file_id = $file->getFileId();
$team = Team::fromId($file->getTeamId());
switch ($document_type) {
case DocumentType::SOLUTION:
$name = "Problème " . $file->getProblem() . " " . $team->getTrigram() . ".pdf";
break;
case DocumentType::SYNTHESIS:
$name = "Note de synthèse " . $team->getTrigram() . " pour " . ($file->getDest() == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf";
break;
default:
$user = User::fromId($file->getUserId());
switch ($file->getType()) {
case DocumentType::PARENTAL_CONSENT:
$name = "Autorisation parentale de " . $user->getFirstName() . " " . $user->getSurname() . ".pdf";
break;
case DocumentType::PHOTO_CONSENT:
$name = "Autorisation de droit à l'image de " . $user->getFirstName() . " " . $user->getSurname() . ".pdf";
break;
default:
$name = "Fiche sanitaire de " . $user->getFirstName() . " " . $user->getSurname() . ".pdf";
break;
}
break;
}
$user = User::fromId($file->getUserId());
$name = "Autorisation de droit à l'image de " . $user->getFirstName() . " " . $user->getSurname() . ".pdf";
$zip->addFile("$LOCAL_PATH/files/$file_id", $name);
}

View File

@ -75,7 +75,7 @@ class Mailer
self::sendMail($user->getEmail(), "Mot de passe changé Correspondances des Jeunes Mathématicien·ne·s", $content);
}
public static function sendAddTeamMail(User $user, Team $team, $problem)
public static function sendAddTeamMail(User $user, Team $team)
{
global $YEAR;
@ -84,13 +84,13 @@ class Mailer
$content = preg_replace("#{SURNAME}#", $user->getSurname(), $content);
$content = preg_replace("#{TEAM_NAME}#", $team->getName(), $content);
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
$content = preg_replace("#{PROBLEM}#", $problem, $content);
$content = preg_replace("#{PROBLEM}#", $team->getProblem(), $content);
$content = preg_replace("#{ACCESS_CODE}#", $team->getAccessCode(), $content);
self::sendMail($user->getEmail(), "Ajout d'une équipe Correspondances des Jeunes Mathématicien·ne·s $YEAR", $content);
}
public static function sendJoinTeamMail(User $user, Team $team, Tournament $tournament)
public static function sendJoinTeamMail(User $user, Team $team)
{
global $YEAR;
@ -99,32 +99,8 @@ class Mailer
$content = preg_replace("#{SURNAME}#", $user->getSurname(), $content);
$content = preg_replace("#{TEAM_NAME}#", $team->getName(), $content);
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
$content = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $content);
$content = preg_replace("#{PROBLEM}#", $team->getProblem(), $content);
self::sendMail($user->getEmail(), "Équipe rejointe Correspondances des Jeunes Mathématicien·ne·s $YEAR", $content);
}
public static function sendAddOrganizerMail(NewOrganizer $new_orga)
{
global $YEAR;
$content = self::getTemplate("add_organizer");
$content = preg_replace("#{FIRST_NAME}#", $new_orga->first_name, $content);
$content = preg_replace("#{SURNAME}#", $new_orga->surname, $content);
$content = preg_replace("#{PASSWORD}#", $new_orga->password, $content);
self::sendMail($new_orga->email, "Ajout d'un organisateur Correspondances des Jeunes Mathématicien·ne·s $YEAR", $content);
}
public static function sendAddOrganizerForTournamentMail(User $organizer, Tournament $tournament)
{
global $YEAR;
$content = self::getTemplate("add_organizer_for_tournament");
$content = preg_replace("#{FIRST_NAME}#", $organizer->getFirstName(), $content);
$content = preg_replace("#{SURNAME}#", $organizer->getSurname(), $content);
$content = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $content);
self::sendMail($organizer->getEmail(), "Ajout d'un organisateur pour le tournoi " . $tournament->getName() . " Correspondances des Jeunes Mathématicien·ne·s $YEAR", $content);
}
}

View File

@ -1,21 +0,0 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Organisateur des Correspondances des Jeunes Mathématicien·ne·s</title>
</head>
<body>
Bonjour {FIRST_NAME} {SURNAME},<br />
<br />
Vous recevez ce message (envoyé automatiquement) car vous êtes organisateur d'un des tournois des Correspondances des Jeunes Mathématicien·ne·s.
Veuillez trouver ci-dessous vos informations d'utilisateur pour le site officiel des inscriptions. Elles vous permettront de gérer les inscriptions des équipes de votre tournoi.<br />
<br />
Votre mot de passe est : <strong style="color: red; font-size: 18px;">{PASSWORD}</strong><br />
<br />
Notez bien que ce mot de passe est temporaire, et pour des raisons de sécurité vous devrez le changer lors de votre prochaine connexion sur le site.<br />
<br />
Merci beaucoup pour votre aide !<br />
<br />
Le comité d'organisation des Correspondances des Jeunes Mathématicien·ne·s
</body>
</html>

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<!--suppress HtmlUnknownTarget -->
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Organisateur du tournoi de {TOURNAMENT_NAME} Correspondances des Jeunes Mathématicien·ne·s</title>
</head>
<body>
Bonjour {FIRST_NAME} {SURNAME},<br />
<br />
Vous venez d'être promu organisateur du tournoi <a href="{URL_BASE}/tournoi/{TOURNAMENT_NAME}">{TOURNAMENT_NAME}</a> des Correspondances des Jeunes Mathématicien·ne·s {YEAR}.<br />
<br />
Cordialement,<br />
<br />
Le comité d'organisation des Correspondances des Jeunes Mathématicien·ne·s
</body>
</html>

View File

@ -7,7 +7,7 @@
<body>
Bonjour {FIRST_NAME} {SURNAME},<br/>
<br/>
Vous venez de rejoindre l'équipe « {TEAM_NAME} » ({TRIGRAM}) pour les Correspondances des Jeunes Mathématicien·ne·s de {TOURNAMENT_NAME} et nous vous en
Vous venez de rejoindre l'équipe « {TEAM_NAME} » ({TRIGRAM}) pour les Correspondances des Jeunes Mathématicien·ne·s pour le problème {PROBLEM} et nous vous en
remercions.<br/>
<br/>
Cordialement,<br/>

View File

@ -1,57 +0,0 @@
<?php
require_once "header.php";
if (isset($orga)) {
if ($has_error) {
echo "<h2>Erreur : " . $error_message . "</h2>";
} else {
echo "<h2>Organisateur ajouté avec succès ! Ses identifiants ont été transmis par mail.</h2>";
}
} ?>
<form method="POST">
<input type="hidden" name="submitted" value="true"/>
<table style="width: 100%;">
<tbody>
<tr>
<td style="width: 30%;">
<label for="surname">Nom :</label>
</td>
<td style="width: 70%;">
<input style="width: 100%;" type="text" id="surname" name="surname"/>
</td>
</tr>
<tr>
<td>
<label for="first_name">Prénom :</label>
</td>
<td>
<input style="width: 100%;" type="text" id="first_name" name="first_name"/>
</td>
</tr>
<tr>
<td>
<label for="email">Email :</label>
</td>
<td>
<input style="width: 100%;" type="email" id="email" name="email"/>
</td>
</tr>
<tr>
<td>
<label for="admin">Compte administrateur :</label>
</td>
<td>
<input style="width: 100%;" type="checkbox" id="admin" name="admin"/>
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" value="Ajouter un organisateur"/>
</td>
</tr>
</tbody>
</table>
</form>
<?php require_once "footer.php" ?>

View File

@ -1,127 +0,0 @@
<?php
require_once "header.php";
if (isset($tournament)) {
if ($has_error) {
echo "<h2>Erreur : " . $error_message . "</h2>";
}
else {
echo "<h2>Tournoi de " . htmlspecialchars($_POST["name"]) . " ajouté avec succès !</h2>";
}
}?>
<form method="POST">
<input type="hidden" name="submitted" value="true" />
<table style="width: 100%;">
<tbody>
<tr>
<td style="width: 30%;">
<label for="name">Nom :</label>
</td>
<td style="width: 70%;">
<input style="width: 100%;" type="text" id="name" name="name" required />
</td>
</tr>
<tr>
<td>
<label for="organizers">Organisateurs :</label>
</td>
<td>
<select style="width: 100%;" id="organizers" name="organizers[]" multiple size="4" required>
<?php
while (($data = $orgas_response->fetch()) !== FALSE) {
echo "<option value=\"" . $data["id"] . "\">" . $data["first_name"] . " " . $data["surname"] . "</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td>
<label for="size">Nombre d'équipes :</label>
</td>
<td>
<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="6" required />
</td>
</tr>
<tr>
<td>
<label for="place">Lieu :</label>
</td>
<td>
<input style="width: 100%;" type="text" id="place" name="place" required />
</td>
</tr>
<tr>
<td>
<label for="price">Prix par participant</label>
</td>
<td>
<input style="width: 100%;" type="number" id="price" name="price" min="0" max="50" value="21" required />
</td>
</tr>
<tr>
<td>
<label for="date_start">Dates :</label>
</td>
<td>
Du <input style="width: 45%;" type="date" id="date_start" name="date_start" required /> au <!--suppress HtmlFormInputWithoutLabel -->
<input style="width: 45%;" type="date" id="date_end" name="date_end" required />
</td>
</tr>
<tr>
<td>
<label for="date_inscription">Date limite d'inscription :</label>
</td>
<td>
<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" required />
<!--suppress HtmlFormInputWithoutLabel -->
<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" required />
</td>
</tr>
<tr>
<td>
<label for="date_solutions">Date limite pour rendre les solutions :</label>
</td>
<td>
<input style="width: 49%;" type="date" id="date_solutions" name="date_solutions" required />
<!--suppress HtmlFormInputWithoutLabel -->
<input style="width: 49%;" type="time" id="time_solutions" name="time_solutions" required />
</td>
</tr>
<tr>
<td>
<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
</td>
<td>
<input style="width: 49%;" type="date" id="date_syntheses" name="date_syntheses" required />
<!--suppress HtmlFormInputWithoutLabel -->
<input style="width: 49%;" type="time" id="time_syntheses" name="time_syntheses" required />
</td>
</tr>
<tr>
<td>
<label for="description">Description :</label>
</td>
<td>
<textarea style="width: 100%;" name="description" id="description" required></textarea>
</td>
</tr>
<tr>
<td>
<label for="final">Ce tournoi est la finale nationale :</label>
</td>
<td>
<input style="width: 100%;" type="checkbox" id="final" name="final" />
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" value="Ajouter un tournoi" />
</td>
</tr>
</tbody>
</table>
</form>
<?php require_once "footer.php" ?>

View File

@ -25,7 +25,6 @@
<ul id="menu">
<li id="menu-logo"><img src="<?= $URL_BASE ?>/logo.png" alt="Logo Corres2Math"></li>
<li><a href="<?= $URL_BASE ?>/">Accueil</a></li>
<!-- <li><a href="<?= $URL_BASE ?>/tournois">Liste des tournois</a></li> -->
<?php if (!isset($_SESSION["user_id"])) { ?>
<li><a href="<?= $URL_BASE ?>/connexion">Connexion</a></li>
<li><a href="<?= $URL_BASE ?>/inscription">Inscription</a></li>
@ -38,29 +37,17 @@
<?php } else { ?>
<li><a href="<?= $URL_BASE ?>/mon_equipe">Mon équipe</a></li>
<?php if ($_SESSION["team"]->getValidationStatus() == ValidationStatus::VALIDATED || true) { ?>
<li><a href="https://paypal.me/galaxyoyo42">Paiement</a></li>
<!--<li><a href="<?= $URL_BASE ?>/solutions">Solutions</a></li>
<li><a href="<?= $URL_BASE ?>/syntheses">Notes de synthèse</a></li> -->
<?php } ?>
<?php } ?>
<?php } ?>
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
<li><a href="<?= $URL_BASE ?>/ajouter_tournoi">Ajouter un tournoi</a></li>
<li><a href="<?= $URL_BASE ?>/ajouter_organisateur">Ajouter un organisateur</a></li>
<?php } ?>
<?php if ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER) { ?>
<!-- <li><a href="<?= $URL_BASE ?>/solutions_orga">Solutions</a></li>
<li><a href="<?= $URL_BASE ?>/syntheses_orga">Notes de synthèse</a></li> -->
<?php } ?>
<li><a href="<?= $URL_BASE ?>/deconnexion">Déconnexion</a></li>
<hr />
<?php
if ($_SESSION["role"] != Role::ADMIN) {
echo "<li><a href=\"?be-admin=1\">Devenir administrateur</a></li>\n";
}
if ($_SESSION["role"] != Role::ORGANIZER) {
echo "<li><a href=\"?be-organizer=1\">Devenir organisateur</a></li>\n";
}
if ($_SESSION["role"] != Role::PARTICIPANT) {
echo "<li><a href=\"?be-participant=1\">Devenir participant</a></li>\n";
}

View File

@ -129,7 +129,7 @@ for ($i = 1; $i <= 6; ++$i) {
</td>
<?php
// TODO check end of inscription
#$can_validate = canValidate($team, $tournament);
$can_validate = canValidate($team);
if (true) { ?>
<td style="width: 50%;">
<form method="post">

View File

@ -1,75 +0,0 @@
<?php
require_once "header.php";
if ($has_error) {
echo "<h2>Erreur : " . $error_message . "</h2>";
} elseif (isset($save_solution)) {
echo "<h2>Le fichier a été correctement envoyé !</h2>";
}
?>
<?php if (date("yyyy-mm-dd") < $tournament->getSolutionsDate()) { ?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
<table style="width: 100%;">
<tbody>
<tr>
<td>
<label for="problem">Problème :</label>
</td>
<td>
<select style="width: 100%;" id="problem" name="problem">
<?php
for ($i = 1; $i <= 9; ++$i) {
echo "<option value=\"$i\">$i</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td>
<label for="file">Fichier :</label>
</td>
<td>
<input type="file" id="file" name="solution"/>
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="send_solution" value="Envoyer"/>
</td>
</tr>
</tbody>
</table>
</form>
<?php } ?>
<hr/>
<h2>Solutions soumises :</h2>
<?php
/** @var Solution $sol */
foreach ($solutions as $sol) {
$file_id = $sol->getFileId();
$problem = $sol->getProblem();
$version = $sol->getVersion();
echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
if ($team->isSelectedForFinal()) { ?>
<hr/>
<h2>Solutions soumises pour la finale :</h2>
<?php
/** @var Solution $sol */
foreach ($solutions_final as $sol) {
$file_id = $sol->getFileId();
$problem = $sol->getProblem();
$version = $sol->getVersion();
echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
}
require_once "footer.php";

View File

@ -1,25 +0,0 @@
<?php
require_once "server_files/views/header.php";
foreach ($tournaments as $tournament) {
echo "<h1>Tournoi de " . $tournament->getName() . "</h1>\n";
$sols = $tournament->getAllSolutions();
/** @var Solution $sol */
foreach ($sols as $sol) {
$file_id = $sol->getFileId();
$problem = $sol->getProblem();
$version = $sol->getVersion();
$team = Team::fromId($sol->getTeamId());
$team_name = $team->getName();
$team_trigram = $team->getTrigram();
echo "Problème n°$problem de l'équipe $team_name ($team_trigram), version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
echo "<form method=\"POST\">\n";
echo "<input type=\"hidden\" name=\"tournament\" value=\"" . $tournament->getId() . "\" />\n";
echo "<input style=\"width: 100%\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
echo "</form><hr />\n";
}
require_once "server_files/views/footer.php";

View File

@ -1,79 +0,0 @@
<?php
require_once "header.php";
if (date("yyyy-mm-dd") < $tournament->getSolutionsDate()) {
echo "<h3>Il est trop tôt pour se préoccuper des notes de synthèse, attendez le tirage des poules.</h3>";
require_once "server_files/views/footer.php";
}
if (isset($error_message)) {
if ($error_message !== false) {
echo "<h2>Erreur : " . $error_message . "</h2>";
}
else {
echo "<h2>Le fichier a été correctement envoyé !</h2>";
}
}?>
<?php if (date("yyyy-mm-dd") < $tournament->getSynthesesDate()) { ?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
<table style="width: 100%;">
<tbody>
<tr>
<td>
<label for="dest">Destination de la note de synthèse :</label>
</td>
<td>
<select style="width: 100%;" id="dest" name="dest">
<option value="opposant">Opposant</option>
<option value="rapporteur">Rapporteur</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="file">Fichier :</label>
</td>
<td>
<input type="file" id="file" name="synthese" />
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="send_synthesis" value="Envoyer" />
</td>
</tr>
</tbody>
</table>
</form>
<?php } ?>
<div style="padding: 20px"></div>
<h2>Notes de synthèse soumises :</h2>
<?php
/** @var Synthesis $synthesis */
foreach ($syntheses as $synthesis) {
$file_id = $synthesis->getFileId();
$dest = $synthesis->getDest();
$version = $synthesis->getVersion();
echo "Note de synthèse pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . " (version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
if ($team->isSelectedForFinal()) { ?>
<hr/>
<h2>Notes de synthèse soumises pour la finale :</h2>
<?php
/** @var Synthesis $sol */
foreach ($syntheses_final as $synthesis) {
$file_id = $synthesis->getFileId();
$dest = $synthesis->getDest();
$version = $synthesis->getVersion();
echo "Note de synthèse pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . " (version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
}
require_once "footer.php";

View File

@ -1,27 +0,0 @@
<?php
require_once "server_files/views/header.php";
/** @var Tournament $tournament */
foreach ($tournaments as $tournament) {
echo "<h1>Tournoi de " . $tournament->getName() . "</h1>\n";
$syntheses = $tournament->getAllSyntheses();
/** @var Synthesis $synthesis */
foreach ($syntheses as $synthesis) {
$file_id = $synthesis->getFileId();
$dest = $synthesis->getDest();
$version = $synthesis->getVersion();
$team = Team::fromId($synthesis->getTeamId());
$team_name = $team->getName();
$team_trigram = $team->getTrigram();
echo "Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur")
. ", version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
}
echo "<form method=\"POST\">\n";
echo "<input type=\"hidden\" name=\"tournament\" value=\"" . $tournament->getId() . "\" />\n";
echo "<input style=\"width: 100%\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
echo "</form><hr />\n";
}
require_once "server_files/views/footer.php";

View File

@ -1,220 +0,0 @@
<?php require_once "header.php" ?>
<?php
if ($has_error)
echo "<h2>Erreur : $error_message</h2>";
?>
<h2>Tournoi de <?= $tournament->getName() ?></h2>
<strong>Organisateur<?= sizeof($orgas) >= 2 ? 's' : '' ?> :</strong>
<?php
$s = "";
/** @var User $orga */
foreach ($orgas as $orga) {
$orga_id = $orga->getId();
$orga_name = $orga->getFirstName() . " " . $orga->getSurname();
if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN)
$s .= "<a href=\"$URL_BASE/informations/$orga_id/$orga_name\">$orga_name</a>";
else
$s .= $orga_name;
$s .= ", ";
}
echo substr($s, 0, -2);
?>
<br />
<strong>Nombre d'équipes maximal :</strong> <?= $tournament->getSize() ?><br />
<strong>Lieu :</strong> <?= $tournament->getPlace() ?><br />
<strong>Prix par partipant :</strong> <?= $tournament->getPrice() == 0 ? "Gratuit" : $tournament->getPrice() . "" ?><br />
<strong>Dates :</strong> Du <?= formatDate($tournament->getStartDate()) ?> au <?= formatDate($tournament->getEndDate()) ?><br />
<strong>Clôture des inscriptions :</strong> <?= formatDate($tournament->getInscriptionDate(), true) ?><br />
<strong>Date limite d'envoi des solutions :</strong> <?= formatDate($tournament->getSolutionsDate(), true) ?><br />
<strong>Date limite d'envoi des notes de synthèse :</strong> <?= formatDate($tournament->getSynthesesDate(), true) ?><br />
<strong>Description :</strong> <?= $tournament->getDescription() ?><br />
<?php
if ($tournament->isFinal())
echo "<strong>Ce tournoi est la finale nationale du TFJM² 2020.</strong><br />";
?>
<?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))) { ?>
<a href="<?= $URL_BASE ?>/tournoi/<?= $tournament->getName() ?>/modifier">Éditer le tournoi</a>
<?php } ?>
<?php if (!isset($_GET["modifier"])) { ?>
<hr/>
<h2>Équipes inscrites à ce tournoi :</h2>
<table style="border: 1px solid black; width: 100%;">
<thead>
<tr>
<th style="border: 1px solid black; text-align: center">
Équipe
</th>
<th style="border: 1px solid black; text-align: center">
Trigramme
</th>
<th style="border: 1px solid black; text-align: center">
Date d'inscription
</th>
<th style="border: 1px solid black; text-align: center">
État de validation de l'inscription
</th>
</tr>
</thead>
<tbody>
<?php
/** @var Team $team */
foreach ($teams as $team) {
?>
<tr>
<td style="border: 1px solid black; text-align: center">
<?php
if (isset($_SESSION["role"]) && ($_SESSION["role"] == Role::ADMIN || ($_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))))
echo "<a href=\"$URL_BASE/equipe/" . $team->getTrigram() . "\">" . $team->getName(). "</a>";
else
echo $team->getName();
?>
</td>
<td style="border: 1px solid black; text-align: center"><?= $team->getTrigram() ?></td>
<td style="border: 1px solid black; text-align: center"><?= formatDate($team->getInscriptionDate()) ?></td>
<td style="border: 1px solid black; text-align: center"><?= ValidationStatus::getTranslatedName($team->getValidationStatus()) ?></td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<th style="border: 1px solid black; text-align: center">
Équipe
</th>
<th style="border: 1px solid black; text-align: center">
Trigramme
</th>
<th style="border: 1px solid black; text-align: center">
Date d'inscription
</th>
<th style="border: 1px solid black; text-align: center">
État de validation de l'inscription
</th>
</tr>
</tfoot>
</table>
<?php
}
else {
?>
<form method="POST">
<input type="hidden" name="submitted" value="true" />
<table style="width: 100%;">
<tbody>
<tr>
<td style="width: 30%;">
<label for="name">Nom :</label>
</td>
<td style="width: 70%;">
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $tournament->getName() ?>" required />
</td>
</tr>
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
<tr>
<td>
<label for="organizers">Organisateur :</label>
</td>
<td>
<select style="width: 100%;" id="organizers" name="organizers[]" multiple size="4" required>
<?php
while (($orga_data = $orgas_response->fetch()) !== FALSE) {
echo "<option value=\"" . $orga_data["id"] . "\" " . ($tournament->organize($orga_data["id"]) ? "selected" : "")
. ">" . $orga_data["first_name"] . " " . $orga_data["surname"] . "</option>\n";
}
?>
</select>
</td>
</tr>
<?php } ?>
<tr>
<td>
<label for="size">Nombre d'équipes :</label>
</td>
<td>
<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="<?= $tournament->getSize() ?>" required />
</td>
</tr>
<tr>
<td>
<label for="place">Lieu :</label>
</td>
<td>
<input style="width: 100%;" type="text" id="place" name="place" value="<?= $tournament->getPlace() ?>" required />
</td>
</tr>
<tr>
<td>
<label for="price">Prix par participant</label>
</td>
<td>
<input style="width: 100%;" type="number" id="price" name="price" min="0" max="50" value="<?= $tournament->getPrice() ?>" required />
</td>
</tr>
<tr>
<td>
<label for="date_start">Dates :</label>
</td>
<td>
Du <input style="width: 45%;" type="date" id="date_start" name="date_start" value="<?= $tournament->getStartDate() ?>" required />
au <input style="width: 45%;" type="date" id="date_end" name="date_end" value="<?= $tournament->getEndDate() ?>" required />
</td>
</tr>
<tr>
<td>
<label for="date_inscription">Date limite d'inscription :</label>
</td>
<td>
<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" value="<?= substr($tournament->getInscriptionDate(), 0, 10) ?>" required />
<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" value="<?= substr($tournament->getInscriptionDate(), 11) ?>" required />
</td>
</tr>
<tr>
<td>
<label for="date_solutions">Date limite pour rendre les solutions :</label>
</td>
<td>
<input style="width: 49%;" type="date" id="date_solutions" name="date_solutions" value="<?= substr($tournament->getSolutionsDate(), 0, 10) ?>" required />
<input style="width: 49%;" type="time" id="time_solutions" name="time_solutions" value="<?= substr($tournament->getSolutionsDate(),11) ?>" required />
</td>
</tr>
<tr>
<td>
<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
</td>
<td>
<input style="width: 49%;" type="date" id="date_syntheses" name="date_syntheses"
value="<?= substr($tournament->getSynthesesDate(), 0, 10) ?>" required/>
<input style="width: 49%;" type="time" id="time_syntheses" name="time_syntheses"
value="<?= substr($tournament->getSynthesesDate(), 11) ?>" required/>
</td>
</tr>
<tr>
<td>
<label for="description">Description :</label>
</td>
<td>
<textarea style="width: 100%;" name="description" id="description" required><?= $tournament->getDescription() ?></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 100%;" type="submit" name="edit_tournament" value="Modifier le tournoi" />
</td>
</tr>
</tbody>
</table>
</form>
<?php } ?>
<?php require_once "footer.php" ?>

View File

@ -1,41 +0,0 @@
<?php require_once "header.php" ?>
<h2>Liste des tournois</h2>
<table style="border: 1px solid black; width: 100%">
<thead style="border: 1px solid black">
<tr>
<th style="border: 1px solid black; text-align: center">Nom</th>
<th style="border: 1px solid black; text-align: center">Dates</th>
<th style="border: 1px solid black; text-align: center">Inscription avant le</th>
<th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th>
<th style="border: 1px solid black; text-align: center">Places disponibles</th>
</tr>
</thead>
<tbody style="border: 1px solid black">
<?php
foreach ($tournaments as $tournament) {
?>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; text-align: center"><a href="<?= $URL_BASE ?>/tournoi/<?= $tournament->getName() ?>"><?= $tournament->getName() ?></a></td>
<td style="border: 1px solid black; text-align: center">Du <?= formatDate($tournament->getStartDate()) ?> au <?= formatDate($tournament->getEndDate()) ?></td>
<td style="border: 1px solid black; text-align: center"><?= formatDate($tournament->getSolutionsDate()) ?></td>
<td style="border: 1px solid black; text-align: center"><?= formatDate($tournament->getSynthesesDate()) ?></td>
<td style="border: 1px solid black; text-align: center"><?= $tournament->getSize() ?></td>
</tr>
<?php
}
?>
</tbody>
<tfoot style="border: 1px solid black">
<tr>
<th style="border: 1px solid black; text-align: center">Nom</th>
<th style="border: 1px solid black; text-align: center">Dates</th>
<th style="border: 1px solid black; text-align: center">Inscription avant le</th>
<th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th>
<th style="border: 1px solid black; text-align: center">Places disponibles</th>
</tr>
</tfoot>
</table>
<?php require_once "footer.php" ?>