mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-26 06:22:22 +00:00
Utilisation des nouvelles classes, amélioration du code
This commit is contained in:
parent
b5d567e364
commit
bffaf4b360
@ -1,17 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
class Role
|
||||||
class Role extends SplEnum
|
|
||||||
{
|
{
|
||||||
const __default = self::PARTICIPANT;
|
|
||||||
|
|
||||||
const PARTICIPANT = 0;
|
const PARTICIPANT = 0;
|
||||||
const ENCADRANT = 1;
|
const ENCADRANT = 1;
|
||||||
const ORGANIZER = 2;
|
const ORGANIZER = 2;
|
||||||
const ADMIN = 3;
|
const ADMIN = 3;
|
||||||
|
|
||||||
public function getName() {
|
public static function getTranslatedName($role) {
|
||||||
switch ($this) {
|
switch ($role) {
|
||||||
case self::ENCADRANT:
|
case self::ENCADRANT:
|
||||||
return "Encadrant";
|
return "Encadrant";
|
||||||
case self::ORGANIZER:
|
case self::ORGANIZER:
|
||||||
@ -23,6 +20,19 @@ class Role extends SplEnum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getName($role) {
|
||||||
|
switch ($role) {
|
||||||
|
case self::ENCADRANT:
|
||||||
|
return "ENCADRANT";
|
||||||
|
case self::ORGANIZER:
|
||||||
|
return "ORGANIZER";
|
||||||
|
case self::ADMIN:
|
||||||
|
return "ADMIN";
|
||||||
|
default:
|
||||||
|
return "PARTICIPANT";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function fromName($name) {
|
public static function fromName($name) {
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
case "ENCADRANT":
|
case "ENCADRANT":
|
||||||
|
@ -26,7 +26,7 @@ class Team
|
|||||||
$data = $req->fetch();
|
$data = $req->fetch();
|
||||||
|
|
||||||
if ($data === false)
|
if ($data === false)
|
||||||
throw new InvalidArgumentException("L'équipe spécifiée n'existe pas.");
|
return null;
|
||||||
|
|
||||||
$team = new Team();
|
$team = new Team();
|
||||||
$team->fill($data);
|
$team->fill($data);
|
||||||
@ -41,7 +41,22 @@ class Team
|
|||||||
$data = $req->fetch();
|
$data = $req->fetch();
|
||||||
|
|
||||||
if ($data === false)
|
if ($data === false)
|
||||||
throw new InvalidArgumentException("L'équipe spécifiée n'existe pas.");
|
return null;
|
||||||
|
|
||||||
|
$team = new Team();
|
||||||
|
$team->fill($data);
|
||||||
|
return $team;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromAccessCode($access_code)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `teams` WHERE `access_code` = ? AND `year` = $YEAR;");
|
||||||
|
$req->execute([htmlspecialchars($access_code)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
$team = new Team();
|
$team = new Team();
|
||||||
$team->fill($data);
|
$team->fill($data);
|
||||||
@ -145,7 +160,7 @@ class Team
|
|||||||
global $DB;
|
global $DB;
|
||||||
$this->validation_status = $status;
|
$this->validation_status = $status;
|
||||||
/** @noinspection PhpUndefinedMethodInspection */
|
/** @noinspection PhpUndefinedMethodInspection */
|
||||||
$DB->prepare("UPDATE `teams` SET `validation_status` = ? WHERE `id` = ?;")->execute([$status->getName(), $this->id]);
|
$DB->prepare("UPDATE `teams` SET `validation_status` = ? WHERE `id` = ?;")->execute([ValidationStatus::getName($status), $this->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSelectedForFinal()
|
public function isSelectedForFinal()
|
||||||
|
@ -27,7 +27,7 @@ class Tournament
|
|||||||
$data = $req->fetch();
|
$data = $req->fetch();
|
||||||
|
|
||||||
if ($data === false)
|
if ($data === false)
|
||||||
throw new InvalidArgumentException("Le tournoi spécifié n'existe pas.");
|
return null;
|
||||||
|
|
||||||
$tournament = new Tournament();
|
$tournament = new Tournament();
|
||||||
$tournament->fill($data);
|
$tournament->fill($data);
|
||||||
@ -42,7 +42,21 @@ class Tournament
|
|||||||
$data = $req->fetch();
|
$data = $req->fetch();
|
||||||
|
|
||||||
if ($data === false)
|
if ($data === false)
|
||||||
throw new InvalidArgumentException("Le tournoi spécifié n'existe pas.");
|
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 = new Tournament();
|
||||||
$tournament->fill($data);
|
$tournament->fill($data);
|
||||||
|
@ -27,6 +27,7 @@ class User
|
|||||||
private $year;
|
private $year;
|
||||||
private $confirm_email;
|
private $confirm_email;
|
||||||
private $forgotten_password;
|
private $forgotten_password;
|
||||||
|
private $inscription_date;
|
||||||
|
|
||||||
private function __construct() {}
|
private function __construct() {}
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ class User
|
|||||||
$data = $req->fetch();
|
$data = $req->fetch();
|
||||||
|
|
||||||
if ($data === false)
|
if ($data === false)
|
||||||
throw new InvalidArgumentException("L'utilisateur spécifié n'existe pas.");
|
return null;
|
||||||
|
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$user->fill($data);
|
$user->fill($data);
|
||||||
@ -53,7 +54,7 @@ class User
|
|||||||
$data = $req->fetch();
|
$data = $req->fetch();
|
||||||
|
|
||||||
if ($data === false)
|
if ($data === false)
|
||||||
throw new InvalidArgumentException("L'utilisateur spécifié n'existe pas.");
|
return null;
|
||||||
|
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$user->fill($data);
|
$user->fill($data);
|
||||||
@ -85,6 +86,7 @@ class User
|
|||||||
$this->year = $data["year"];
|
$this->year = $data["year"];
|
||||||
$this->confirm_email = $data["confirm_email"];
|
$this->confirm_email = $data["confirm_email"];
|
||||||
$this->forgotten_password = $data["forgotten_password"];
|
$this->forgotten_password = $data["forgotten_password"];
|
||||||
|
$this->inscription_date = $data["inscription_date"];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmail()
|
public function getEmail()
|
||||||
@ -166,7 +168,7 @@ class User
|
|||||||
{
|
{
|
||||||
global $DB;
|
global $DB;
|
||||||
$this->gender = $gender;
|
$this->gender = $gender;
|
||||||
$DB->prepare("UPDATE `users` SET `email` = ? WHERE `id` = ?;")->execute([$gender, $this->getId()]);
|
$DB->prepare("UPDATE `users` SET `gender` = ? WHERE `id` = ?;")->execute([$gender, $this->getId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAddress()
|
public function getAddress()
|
||||||
@ -311,7 +313,7 @@ class User
|
|||||||
global $DB;
|
global $DB;
|
||||||
$this->role = $role;
|
$this->role = $role;
|
||||||
/** @noinspection PhpUndefinedMethodInspection */
|
/** @noinspection PhpUndefinedMethodInspection */
|
||||||
$DB->prepare("UPDATE `users` SET `email` = ? WHERE `id` = ?;")->execute([$role->getName(), $this->getId()]);
|
$DB->prepare("UPDATE `users` SET `role` = ? WHERE `id` = ?;")->execute([Role::getName($role), $this->getId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTeamId()
|
public function getTeamId()
|
||||||
@ -354,4 +356,9 @@ class User
|
|||||||
$this->forgotten_password = $token;
|
$this->forgotten_password = $token;
|
||||||
$DB->prepare("UPDATE `users` SET `forgotten_password` = ? WHERE `id` = ?;")->execute([$token, $this->getId()]);
|
$DB->prepare("UPDATE `users` SET `forgotten_password` = ? WHERE `id` = ?;")->execute([$token, $this->getId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getInscriptionDate()
|
||||||
|
{
|
||||||
|
return $this->inscription_date;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,15 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ValidationStatus extends SplEnum
|
class ValidationStatus
|
||||||
{
|
{
|
||||||
const __default = self::NOT_READY;
|
|
||||||
|
|
||||||
const NOT_READY = 0;
|
const NOT_READY = 0;
|
||||||
const WAITING = 1;
|
const WAITING = 1;
|
||||||
const VALIDATED = 2;
|
const VALIDATED = 2;
|
||||||
|
|
||||||
public function getName() {
|
public static function getTranslatedName($status) {
|
||||||
switch ($this) {
|
switch ($status) {
|
||||||
case self::WAITING:
|
case self::WAITING:
|
||||||
return "En attente de validation";
|
return "En attente de validation";
|
||||||
case self::VALIDATED:
|
case self::VALIDATED:
|
||||||
@ -19,6 +17,17 @@ class ValidationStatus extends SplEnum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getName($status) {
|
||||||
|
switch ($status) {
|
||||||
|
case self::WAITING:
|
||||||
|
return "WAITING";
|
||||||
|
case self::VALIDATED:
|
||||||
|
return "VALIDATED";
|
||||||
|
default:
|
||||||
|
return "NOT_READY";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function fromName($name) {
|
public static function fromName($name) {
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
case "WAITING":
|
case "WAITING":
|
||||||
|
@ -28,5 +28,10 @@ session_start();
|
|||||||
setlocale(LC_ALL, "fr_FR.utf8");
|
setlocale(LC_ALL, "fr_FR.utf8");
|
||||||
|
|
||||||
require_once "model.php";
|
require_once "model.php";
|
||||||
|
require_once "classes/Role.php";
|
||||||
|
require_once "classes/Team.php";
|
||||||
|
require_once "classes/Tournament.php";
|
||||||
|
require_once "classes/User.php";
|
||||||
|
require_once "classes/ValidationStatus.php";
|
||||||
|
|
||||||
loadUserValues();
|
loadUserValues();
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
require_once "../config.php";
|
require_once "../config.php";
|
||||||
|
|
||||||
|
if (!isset($_SESSION["role"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT))
|
||||||
|
require_once "../403.php";
|
||||||
|
|
||||||
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `date_inscription` > CURRENT_DATE AND `year` = '$YEAR';");
|
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `date_inscription` > CURRENT_DATE AND `year` = '$YEAR';");
|
||||||
|
|
||||||
if (isset($_POST["submitted"])) {
|
if (isset($_POST["submitted"])) {
|
||||||
@ -11,7 +14,7 @@ if (isset($_POST["submitted"])) {
|
|||||||
function registerTeam() {
|
function registerTeam() {
|
||||||
global $DB, $YEAR, $MAIL_ADDRESS, $access_code;
|
global $DB, $YEAR, $MAIL_ADDRESS, $access_code;
|
||||||
|
|
||||||
if ($_SESSION["team_id"] != NULL)
|
if ($_SESSION["team"] != NULL)
|
||||||
return "Vous êtes déjà dans une équipe.";
|
return "Vous êtes déjà dans une équipe.";
|
||||||
|
|
||||||
$name = htmlspecialchars($_POST["name"]);
|
$name = htmlspecialchars($_POST["name"]);
|
||||||
@ -33,10 +36,8 @@ function registerTeam() {
|
|||||||
return "Une équipe a déjà choisi ce trigramme.";
|
return "Une équipe a déjà choisi ce trigramme.";
|
||||||
|
|
||||||
$tournament_id = intval(htmlspecialchars($_POST["tournament"]));
|
$tournament_id = intval(htmlspecialchars($_POST["tournament"]));
|
||||||
|
$tournament = Tournament::fromId($tournament_id);
|
||||||
$result = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `id` = '" . $tournament_id . "' AND `year` = '$YEAR';");
|
if ($tournament === null)
|
||||||
$data = $result->fetch();
|
|
||||||
if ($data === FALSE)
|
|
||||||
return "Le tournoi spécifié n'existe pas.";
|
return "Le tournoi spécifié n'existe pas.";
|
||||||
|
|
||||||
$alphabet = "0123456789abcdefghijkmnopqrstuvwxyz0123456789";
|
$alphabet = "0123456789abcdefghijkmnopqrstuvwxyz0123456789";
|
||||||
@ -46,18 +47,17 @@ function registerTeam() {
|
|||||||
|
|
||||||
$req = $DB->prepare("INSERT INTO `teams` (`name`, `trigram`, `tournament`, `encadrant_1`, `participant_1`, `validation_status`, `access_code`, `year`)
|
$req = $DB->prepare("INSERT INTO `teams` (`name`, `trigram`, `tournament`, `encadrant_1`, `participant_1`, `validation_status`, `access_code`, `year`)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
$req->execute([$name, $trigram, $tournament_id, $_SESSION["role"] == "ENCADRANT" ? $_SESSION["user_id"] : NULL,
|
$req->execute([$name, $trigram, $tournament_id, $_SESSION["role"] == Role::ENCADRANT ? $_SESSION["user_id"] : NULL,
|
||||||
$_SESSION["role"] == "PARTICIPANT" ? $_SESSION["user_id"] : NULL, "NOT_READY", $access_code, $YEAR]);
|
$_SESSION["role"] == Role::PARTICIPANT ? $_SESSION["user_id"] : NULL, ValidationStatus::NOT_READY, $access_code, $YEAR]);
|
||||||
|
|
||||||
$result = $DB->query("SELECT `id` FROM `teams` WHERE `name` = '" . $name . "' AND `year` = '$YEAR';");
|
$_SESSION["team"] = Team::fromTrigram($trigram);
|
||||||
$data_team = $result->fetch();
|
$_SESSION["user"]->setTeamId($_SESSION["team"]->getId());
|
||||||
$DB->prepare("UPDATE `users` SET `team_id` = ? WHERE `id` = " . $_SESSION["user_id"] . ";")->execute([$data_team["id"]]);
|
|
||||||
|
|
||||||
$msg = "Bonjour " . $_SESSION["first_name"] . " " . $_SESSION["surname"] . ",\r\n\r\n";
|
$msg = "Bonjour " . $_SESSION["user"]->getFirstName() . " " . $_SESSION["user"]->getSurname() . ",\r\n\r\n";
|
||||||
$msg .= "Vous venez de créer l'équipe « $name » ($trigram) pour le TFJM² de " . $data["name"] . " et nous vous en remercions. ";
|
$msg .= "Vous venez de créer l'équipe « $name » ($trigram) pour le TFJM² de " . $tournament->getName() . " et nous vous en remercions. ";
|
||||||
$msg .= "Afin de permettre aux autres membres de votre équipe de vous rejoindre, veuillez leur transmettre le code d'accès : " . $access_code . "\r\n\r\n";
|
$msg .= "Afin de permettre aux autres membres de votre équipe de vous rejoindre, veuillez leur transmettre le code d'accès : " . $access_code . "\r\n\r\n";
|
||||||
$msg .= "Cordialement,\r\n\r\nL'organisation du TFJM² $YEAR";
|
$msg .= "Cordialement,\r\n\r\nL'organisation du TFJM² $YEAR";
|
||||||
mail($_SESSION["email"], "Nouvelle équipe TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n");
|
mail($_SESSION["user"]->getEmail(), "Nouvelle équipe TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
require_once "../config.php";
|
require_once "../config.php";
|
||||||
|
|
||||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ADMIN")
|
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
|
||||||
require_once "../403.php";
|
require_once "../403.php";
|
||||||
|
|
||||||
if (isset($_POST["submitted"])) {
|
if (isset($_POST["submitted"])) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
require_once "../config.php";
|
require_once "../config.php";
|
||||||
|
|
||||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ADMIN")
|
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
|
||||||
require_once "../403.php";
|
require_once "../403.php";
|
||||||
|
|
||||||
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
|
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
|
||||||
@ -31,7 +31,7 @@ function registerTournament() {
|
|||||||
$data = $result->fetch();
|
$data = $result->fetch();
|
||||||
if ($data === FALSE)
|
if ($data === FALSE)
|
||||||
return "L'organisateur spécifié n'existe pas.";
|
return "L'organisateur spécifié n'existe pas.";
|
||||||
if ($data["role"] != "ORGANIZER" && $data["role"] != "ADMIN")
|
if ($data["role"] != Role::ORGANIZER && $data["role"] != Role::ADMIN)
|
||||||
return "L'organisateur indiqué ne peut pas organiser de tournoi.";
|
return "L'organisateur indiqué ne peut pas organiser de tournoi.";
|
||||||
$orga_mails[] = $data["email"];
|
$orga_mails[] = $data["email"];
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ if (isset($_GET["confirmation-mail"]) && !isset($_SESSION["user_id"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function login() {
|
function login() {
|
||||||
global $DB, $URL_BASE;
|
global $URL_BASE;
|
||||||
|
|
||||||
$email = htmlspecialchars($_POST["email"]);
|
$email = htmlspecialchars($_POST["email"]);
|
||||||
|
|
||||||
@ -35,39 +35,39 @@ function login() {
|
|||||||
|
|
||||||
$password = htmlspecialchars($_POST["password"]);
|
$password = htmlspecialchars($_POST["password"]);
|
||||||
|
|
||||||
$result = $DB->query("SELECT `id`, `pwd_hash`, `email`, `surname`, `first_name`, `role`, `team_id`, `confirm_email` FROM `users` WHERE `email` = '" . $email . "';");
|
$user = User::fromEmail($email);
|
||||||
if (($data = $result->fetch()) === FALSE)
|
if ($user === FALSE)
|
||||||
return "Le compte n'existe pas.";
|
return "Le compte n'existe pas.";
|
||||||
|
|
||||||
if ($data["confirm_email"] !== NULL) {
|
if ($user->getConfirmEmailToken() !== NULL) {
|
||||||
$_SESSION["confirm_email"] = $email;
|
$_SESSION["confirm_email"] = $email;
|
||||||
return "L'adresse mail n'a pas été validée. Veuillez vérifier votre boîte mail (surtout vos spams). <a href=\"$URL_BASE/connexion/confirmation-mail\">Cliquez ici pour renvoyer le mail de confirmation</a>.";
|
return "L'adresse mail n'a pas été validée. Veuillez vérifier votre boîte mail (surtout vos spams). <a href=\"$URL_BASE/connexion/confirmation-mail\">Cliquez ici pour renvoyer le mail de confirmation</a>.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!password_verify($password, $data["pwd_hash"]))
|
if (!$user->checkPassword($password))
|
||||||
return "Le mot de passe est incorrect.";
|
return "Le mot de passe est incorrect.";
|
||||||
|
|
||||||
$_SESSION["user_id"] = $data["id"];
|
$_SESSION["user_id"] = $user->getId();
|
||||||
loadUserValues();
|
loadUserValues();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function recuperateAccount() {
|
function recuperateAccount() {
|
||||||
global $DB, $MAIL_ADDRESS, $URL_BASE, $YEAR;
|
global $MAIL_ADDRESS, $URL_BASE;
|
||||||
|
|
||||||
$email = htmlspecialchars($_POST["email"]);
|
$email = htmlspecialchars($_POST["email"]);
|
||||||
|
|
||||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||||
return "L'email entrée est invalide.";
|
return "L'email entrée est invalide.";
|
||||||
|
|
||||||
$req = $DB->query("SELECT `id` FROM `users` WHERE `email` = '$email' AND `year` = $YEAR;");
|
$user = User::fromEmail($email);
|
||||||
if (!$req->fetch())
|
if ($user == null)
|
||||||
return "Le compte n'existe pas.";
|
return "Le compte n'existe pas.";
|
||||||
|
|
||||||
$token = uniqid();
|
$token = uniqid();
|
||||||
|
|
||||||
$DB->exec("UPDATE `users` SET `forgotten_password` = '$token' WHERE `email` = '$email' AND `year` = $YEAR;");
|
$user->setForgottenPasswordToken($token);
|
||||||
|
|
||||||
$msg = "Bonjour,\r\n\r\n"
|
$msg = "Bonjour,\r\n\r\n"
|
||||||
. "Vous avez indiqué avoir oublié votre mot de passe. Veuillez cliquer ici pour le réinitialiser : $URL_BASE/connexion/reinitialiser_mdp/$token\r\n\r\n"
|
. "Vous avez indiqué avoir oublié votre mot de passe. Veuillez cliquer ici pour le réinitialiser : $URL_BASE/connexion/reinitialiser_mdp/$token\r\n\r\n"
|
||||||
@ -106,7 +106,7 @@ function resetPassword() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendConfirmEmail() {
|
function sendConfirmEmail() {
|
||||||
global $DB, $URL_BASE, $MAIL_ADDRESS, $YEAR;
|
global $URL_BASE, $MAIL_ADDRESS, $YEAR;
|
||||||
|
|
||||||
$email = htmlspecialchars($_SESSION["confirm_email"]);
|
$email = htmlspecialchars($_SESSION["confirm_email"]);
|
||||||
|
|
||||||
@ -115,15 +115,15 @@ function sendConfirmEmail() {
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $DB->query("SELECT `confirm_email` FROM `users` WHERE `email` = '$email' AND `year` = $YEAR;")->fetch();
|
$user = User::fromEmail($email);
|
||||||
|
|
||||||
if ($data === FALSE) {
|
if ($user === null) {
|
||||||
unset($_SESSION["confirm_email"]);
|
unset($_SESSION["confirm_email"]);
|
||||||
header("Location: $URL_BASE/connexion");
|
header("Location: $URL_BASE/connexion");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$confirm_email_uid = $data["confirm_email"];
|
$confirm_email_uid = $user->getConfirmEmailToken();
|
||||||
|
|
||||||
$msg = "Bonjour,\r\n\r\nPour confirmer votre adresse mail, cliquez ici : $URL_BASE/confirmer_mail/$confirm_email_uid\r\n\r\n"
|
$msg = "Bonjour,\r\n\r\nPour confirmer votre adresse mail, cliquez ici : $URL_BASE/confirmer_mail/$confirm_email_uid\r\n\r\n"
|
||||||
. "Cordialement,\r\n\r\nLe comité national d'organisation du TFJM²";
|
. "Cordialement,\r\n\r\nLe comité national d'organisation du TFJM²";
|
||||||
|
@ -2,23 +2,27 @@
|
|||||||
|
|
||||||
require_once "../config.php";
|
require_once "../config.php";
|
||||||
|
|
||||||
|
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN)
|
||||||
|
require_once "../403.php";
|
||||||
|
|
||||||
$trigram = htmlspecialchars($_GET["trigram"]);
|
$trigram = htmlspecialchars($_GET["trigram"]);
|
||||||
|
|
||||||
|
$team = Team::fromTrigram($trigram);
|
||||||
|
|
||||||
|
if ($team === null)
|
||||||
|
require_once "../404.php";
|
||||||
|
|
||||||
if (isset($_POST["validate"])) {
|
if (isset($_POST["validate"])) {
|
||||||
$DB->exec("UPDATE `teams` SET `validation_status` = 'VALIDATED' WHERE `trigram` = '$trigram' AND `year` = $YEAR;");
|
$team->setValidationStatus(ValidationStatus::VALIDATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
$team_data = $DB->query("SELECT * FROM `teams` WHERE `trigram` = '$trigram' AND `year` = $YEAR;")->fetch();
|
|
||||||
|
|
||||||
if (isset($_POST["select"])) {
|
if (isset($_POST["select"])) {
|
||||||
$DB->exec("UPDATE `teams` SET `final_selection` = true, `validation_status` = 'NOT_READY' WHERE `trigram` = '$trigram' AND `year` = $YEAR;");
|
$team->selectForFinal(true);
|
||||||
$team_data["validation_status"] = "NOT_READY";
|
$team->setValidationStatus(ValidationStatus::NOT_READY);
|
||||||
$team_data["final_selection"] = true;
|
$_SESSION["final"] = Tournament::getFinalTournament();
|
||||||
$final_id = $_SESSION["final_id"];
|
|
||||||
$team_id = $team_data["id"];
|
|
||||||
|
|
||||||
$sols_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem`, `uploaded_at` ORDER BY `problem`, `uploaded_at` DESC;");
|
$sols_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem`, `uploaded_at` ORDER BY `problem`, `uploaded_at` DESC;");
|
||||||
$sols_req->execute([$team_data["id"], $team_data["tournament"]]);
|
$sols_req->execute([$team->getId(), $team->getTournamentId()]);
|
||||||
while (($sol_data = $sols_req->fetch()) !== false) {
|
while (($sol_data = $sols_req->fetch()) !== false) {
|
||||||
$old_id = $sol_data["file_id"];
|
$old_id = $sol_data["file_id"];
|
||||||
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
@ -35,11 +39,11 @@ if (isset($_POST["select"])) {
|
|||||||
|
|
||||||
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`)
|
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`)
|
||||||
VALUES (?, ?, ?, ?);");
|
VALUES (?, ?, ?, ?);");
|
||||||
$req->execute([$id, $team_id, $_SESSION["final_id"], $sol_data["problem"]]);
|
$req->execute([$id, $team->getId(), $_SESSION["final_id"], $sol_data["problem"]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest`, `uploaded_at` ORDER BY `dest`, `uploaded_at` DESC;");
|
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest`, `uploaded_at` ORDER BY `dest`, `uploaded_at` DESC;");
|
||||||
$syntheses_req->execute([$team_data["id"], $team_data["tournament"]]);
|
$syntheses_req->execute([$team->getId(), $team->getTournamentId()]);
|
||||||
while (($synthese_data = $syntheses_req->fetch()) !== false) {
|
while (($synthese_data = $syntheses_req->fetch()) !== false) {
|
||||||
$old_id = $synthese_data["file_id"];
|
$old_id = $synthese_data["file_id"];
|
||||||
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
@ -55,23 +59,20 @@ if (isset($_POST["select"])) {
|
|||||||
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
|
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
|
||||||
|
|
||||||
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
|
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
|
||||||
$req->execute([$id, $team_id, $_SESSION["final_id"], $synthese_data["dest"]]);
|
$req->execute([$id, $team->getId(), $_SESSION["final"]->getId(), $synthese_data["dest"]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($team_data === false)
|
|
||||||
require_once "../404.php";
|
|
||||||
|
|
||||||
$tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch();
|
|
||||||
|
|
||||||
$documents_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` = ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
|
$documents_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` = ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
|
||||||
$documents_req->execute([$team_data["id"], $team_data["tournament"]]);
|
$documents_req->execute([$team->getId(), $team->getId()]);
|
||||||
|
|
||||||
if ($team_data["final_selection"]) {
|
if ($team->isSelectedForFinal()) {
|
||||||
$documents_final_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` != ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
|
$documents_final_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` != ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
|
||||||
$documents_final_req->execute([$team_data["id"], $_SESSION["final_id"]]);
|
$documents_final_req->execute([$team->getId(), $_SESSION["final"]->getId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tournament = Tournament::fromId($team->getTournamentId());
|
||||||
|
|
||||||
require_once "../views/header.php";
|
require_once "../views/header.php";
|
||||||
require_once "../views/equipe.php";
|
require_once "../views/equipe.php";
|
||||||
require_once "../views/footer.php";
|
require_once "../views/footer.php";
|
||||||
|
@ -2,20 +2,22 @@
|
|||||||
|
|
||||||
require_once "../config.php";
|
require_once "../config.php";
|
||||||
|
|
||||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ORGANIZER" && $_SESSION["role"] != "ADMIN") {
|
if (!isset($_SESSION["role"]))
|
||||||
|
require_once "../403.php";
|
||||||
|
|
||||||
|
$id = $_GET["id"];
|
||||||
|
$user = User::fromId($id);
|
||||||
|
|
||||||
|
if ($_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN) {
|
||||||
|
if ($user->getId() != $_SESSION["user_id"] && ($user->getTeamId() == null || $user->getTeamId() != $_SESSION["user"]->getTeamId()))
|
||||||
require_once "../403.php";
|
require_once "../403.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $_GET["id"];
|
if ($user === null) {
|
||||||
$user_data = $DB->query("SELECT * FROM `users` WHERE `id` = $id;")->fetch();
|
|
||||||
|
|
||||||
if ($user_data === false) {
|
|
||||||
require_once "../404.php";
|
require_once "../404.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
$team_data = false;
|
$team = Team::fromId($user->getTeamId());
|
||||||
if ($user_data["team_id"] !== NULL)
|
|
||||||
$team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = " . $user_data["team_id"] . ";")->fetch();
|
|
||||||
|
|
||||||
$documents_req = $DB->query("SELECT * FROM `documents` WHERE `user` = $id;");
|
$documents_req = $DB->query("SELECT * FROM `documents` WHERE `user` = $id;");
|
||||||
$tournaments_req = $DB->query("SELECT `tournament`, `name` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $id ORDER BY `date_start`, `name`;");
|
$tournaments_req = $DB->query("SELECT `tournament`, `name` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $id ORDER BY `date_start`, `name`;");
|
||||||
|
@ -8,102 +8,96 @@ if (isset($_POST["submitted"])) {
|
|||||||
$error_message = updatePassword();
|
$error_message = updatePassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SESSION["user_id"])) {
|
if (!isset($_SESSION["user_id"]))
|
||||||
$result = $DB->query("SELECT * FROM `users` WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
|
||||||
$user_data = $result->fetch();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
require_once "../403.php";
|
require_once "../403.php";
|
||||||
|
|
||||||
|
/** @var User $user */
|
||||||
|
$user = $_SESSION["user"];
|
||||||
|
|
||||||
function updateAccount()
|
function updateAccount()
|
||||||
{
|
{
|
||||||
global $DB, $URL_BASE, $MAIL_ADDRESS;
|
global $URL_BASE, $MAIL_ADDRESS, $user;
|
||||||
|
|
||||||
if (!isset($_SESSION["user_id"]))
|
|
||||||
return "Vous n'êtes pas connecté.";
|
|
||||||
|
|
||||||
$ID = $_SESSION["user_id"];
|
|
||||||
|
|
||||||
$surname = htmlspecialchars($_POST["surname"]);
|
$surname = htmlspecialchars($_POST["surname"]);
|
||||||
if (isset($surname) && $surname != "")
|
if (isset($surname) && $surname != "")
|
||||||
$DB->prepare("UPDATE `users` SET `surname` = ? WHERE `id` = ?;")->execute([$surname, $ID]);
|
$user->setSurname($surname);
|
||||||
|
|
||||||
$first_name = htmlspecialchars($_POST["firstname"]);
|
$first_name = htmlspecialchars($_POST["firstname"]);
|
||||||
if (isset($first_name) && $first_name != "")
|
if (isset($first_name) && $first_name != "")
|
||||||
$DB->prepare("UPDATE `users` SET `first_name` = ? WHERE `id` = ?;")->execute([$first_name, $ID]);
|
$user->setFirstName($first_name);
|
||||||
|
|
||||||
$birth_date = htmlspecialchars($_POST["birth_date"]);
|
$birth_date = htmlspecialchars($_POST["birth_date"]);
|
||||||
if (isset($birth_date) && $birth_date != "")
|
if (isset($birth_date) && $birth_date != "")
|
||||||
$DB->prepare("UPDATE `users` SET `birth_date` = ? WHERE `id` = ?;")->execute([$birth_date, $ID]);
|
$user->setBirthDate($birth_date);
|
||||||
|
|
||||||
if (isset($_POST["gender"])) {
|
if (isset($_POST["gender"])) {
|
||||||
$gender = htmlspecialchars($_POST["gender"]);
|
$gender = htmlspecialchars($_POST["gender"]);
|
||||||
if (isset($gender) && ($gender == "M" || $gender == "F"))
|
if (isset($gender) && ($gender == "M" || $gender == "F"))
|
||||||
$DB->prepare("UPDATE `users` SET `gender` = ? WHERE `id` = ?;")->execute([$gender, $ID]);
|
$user->setGender($gender);
|
||||||
}
|
}
|
||||||
|
|
||||||
$address = htmlspecialchars($_POST["address"]);
|
$address = htmlspecialchars($_POST["address"]);
|
||||||
if (isset($address) && $address != "")
|
if (isset($address) && $address != "")
|
||||||
$DB->prepare("UPDATE `users` SET `address` = ? WHERE `id` = ?;")->execute([$address, $ID]);
|
$user->setAddress($address);
|
||||||
|
|
||||||
$postal_code = htmlspecialchars($_POST["postal_code"]);
|
$postal_code = htmlspecialchars($_POST["postal_code"]);
|
||||||
if (isset($postal_code) && $postal_code != "")
|
if (isset($postal_code) && $postal_code != "")
|
||||||
$DB->prepare("UPDATE `users` SET `postal_code` = ? WHERE `id` = ?;")->execute([$postal_code, $ID]);
|
$user->setPostalCode($postal_code);
|
||||||
|
|
||||||
$city = htmlspecialchars($_POST["city"]);
|
$city = htmlspecialchars($_POST["city"]);
|
||||||
if (isset($city) && $city != "")
|
if (isset($city) && $city != "")
|
||||||
$DB->prepare("UPDATE `users` SET `city` = ? WHERE `id` = ?;")->execute([$city, $ID]);
|
$user->setCity($city);
|
||||||
|
|
||||||
$country = htmlspecialchars($_POST["country"]);
|
$country = htmlspecialchars($_POST["country"]);
|
||||||
if (isset($country) && $country != "")
|
if (isset($country) && $country != "")
|
||||||
$DB->prepare("UPDATE `users` SET `country` = ? WHERE `id` = ?;")->execute([$country, $ID]);
|
$user->setCountry($country);
|
||||||
|
|
||||||
$phone_number = htmlspecialchars($_POST["phone_number"]);
|
$phone_number = htmlspecialchars($_POST["phone_number"]);
|
||||||
if (isset($phone_number) && $phone_number != "")
|
if (isset($phone_number) && $phone_number != "")
|
||||||
$DB->prepare("UPDATE `users` SET `phone_number` = ? WHERE `id` = ?;")->execute([$phone_number, $ID]);
|
$user->setPhoneNumber($phone_number);
|
||||||
|
|
||||||
if (isset($_POST["school"])) {
|
if (isset($_POST["school"])) {
|
||||||
$school = htmlspecialchars($_POST["school"]);
|
$school = htmlspecialchars($_POST["school"]);
|
||||||
if (isset($school) && $school != "")
|
if (isset($school) && $school != "")
|
||||||
$DB->prepare("UPDATE `users` SET `school` = ? WHERE `id` = ?;")->execute([$school, $ID]);
|
$user->setSchool($school);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST["class"])) {
|
if (isset($_POST["class"])) {
|
||||||
$class = htmlspecialchars($_POST["class"]);
|
$class = htmlspecialchars($_POST["class"]);
|
||||||
if (isset($class) && ($class == "terminale" || $class == "premiere" || $class == "seconde"))
|
if (isset($class) && ($class == "terminale" || $class == "premiere" || $class == "seconde"))
|
||||||
$DB->prepare("UPDATE `users` SET `class` = ? WHERE `id` = ?;")->execute([strtoupper($class), $ID]);
|
$user->setClass($class);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST["responsible_name"])) {
|
if (isset($_POST["responsible_name"])) {
|
||||||
$responsible_name = htmlspecialchars($_POST["responsible_name"]);
|
$responsible_name = htmlspecialchars($_POST["responsible_name"]);
|
||||||
if (isset($responsible_name) && $responsible_name != "")
|
if (isset($responsible_name) && $responsible_name != "")
|
||||||
$DB->prepare("UPDATE `users` SET `responsible_name` = ? WHERE `id` = ?;")->execute([$responsible_name, $ID]);
|
$user->setResponsibleName($responsible_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST["responsible_phone"])) {
|
if (isset($_POST["responsible_phone"])) {
|
||||||
$responsible_phone = htmlspecialchars($_POST["responsible_phone"]);
|
$responsible_phone = htmlspecialchars($_POST["responsible_phone"]);
|
||||||
if (isset($responsible_phone) && $responsible_phone != "")
|
if (isset($responsible_phone) && $responsible_phone != "")
|
||||||
$DB->prepare("UPDATE `users` SET `responsible_phone` = ? WHERE `id` = ?;")->execute([$responsible_phone, $ID]);
|
$user->setResponsiblePhone($responsible_phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST["responsible_email"])) {
|
if (isset($_POST["responsible_email"])) {
|
||||||
$responsible_email = htmlspecialchars($_POST["responsible_email"]);
|
$responsible_email = htmlspecialchars($_POST["responsible_email"]);
|
||||||
if (isset($responsible_email) && $responsible_email != "")
|
if (isset($responsible_email) && $responsible_email != "")
|
||||||
$DB->prepare("UPDATE `users` SET `responsible_email` = ? WHERE `id` = ?;")->execute([$responsible_email, $ID]);
|
$user->setResponsibleEmail($responsible_email);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST["description"])) {
|
if (isset($_POST["description"])) {
|
||||||
$description = htmlspecialchars($_POST["description"]);
|
$description = htmlspecialchars($_POST["description"]);
|
||||||
if (isset($description) && $description != "")
|
if (isset($description) && $description != "")
|
||||||
$DB->prepare("UPDATE `users` SET `description` = ? WHERE `id` = ?;")->execute([$description, $ID]);
|
$user->setDescription($description);
|
||||||
}
|
}
|
||||||
|
|
||||||
$email = htmlspecialchars($_POST["email"]);
|
$email = htmlspecialchars($_POST["email"]);
|
||||||
if (isset($email) && $email != "" && filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
if (isset($email) && $email != "" && filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
$confirm_email_uid = uniqid();
|
$confirm_email_token = uniqid();
|
||||||
$DB->prepare("UPDATE `users` SET `email` = ?, `confirm_email` = ? WHERE `id` = ?;")->execute([$email, $confirm_email_uid, $ID]);
|
$user->setConfirmEmailToken($confirm_email_token);
|
||||||
|
|
||||||
$msg = "Vous venez de changer votre adresse mail. Veuillez désormais confirmer votre adresse mail en cliquant ici : $URL_BASE/confirmer_mail/$confirm_email_uid";
|
$msg = "Vous venez de changer votre adresse mail. Veuillez désormais confirmer votre adresse mail en cliquant ici : $URL_BASE/confirmer_mail/$confirm_email_token";
|
||||||
mail($email, "Changement d'adresse mail - TFJM²", $msg, "From: $MAIL_ADDRESS\r\n");
|
mail($email, "Changement d'adresse mail - TFJM²", $msg, "From: $MAIL_ADDRESS\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,17 +106,13 @@ function updateAccount()
|
|||||||
|
|
||||||
function updatePassword()
|
function updatePassword()
|
||||||
{
|
{
|
||||||
global $DB, $YEAR;
|
global $user;
|
||||||
|
|
||||||
$old = htmlspecialchars($_POST["old_password"]);
|
$old = htmlspecialchars($_POST["old_password"]);
|
||||||
$new = htmlspecialchars($_POST["new_password"]);
|
$new = htmlspecialchars($_POST["new_password"]);
|
||||||
$confirm = htmlspecialchars($_POST["confirm_password"]);
|
$confirm = htmlspecialchars($_POST["confirm_password"]);
|
||||||
|
|
||||||
$result = $DB->query("SELECT `pwd_hash` FROM `users` WHERE `id` = '" . $_SESSION["user_id"] . "' AND `year` = '$YEAR';");
|
if (!$user->checkPassword($old))
|
||||||
if (($data = $result->fetch()) === FALSE)
|
|
||||||
return "Le compte n'existe pas.";
|
|
||||||
|
|
||||||
if (!password_verify($old, $data["pwd_hash"]))
|
|
||||||
return "L'ancien mot de passe est incorrect.";
|
return "L'ancien mot de passe est incorrect.";
|
||||||
|
|
||||||
if (strlen($new) < 8)
|
if (strlen($new) < 8)
|
||||||
@ -131,9 +121,7 @@ function updatePassword()
|
|||||||
if ($new != $confirm)
|
if ($new != $confirm)
|
||||||
return "Les deux mots de passe sont différents.";
|
return "Les deux mots de passe sont différents.";
|
||||||
|
|
||||||
$hash = password_hash($new, PASSWORD_BCRYPT);
|
$user->setPassword($new);
|
||||||
|
|
||||||
$DB->prepare("UPDATE `users` SET `pwd_hash` = ? WHERE `id` = ?;")->execute([$hash, $_SESSION["user_id"]]);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ require_once "../config.php";
|
|||||||
|
|
||||||
if (isset($_POST["leave_team"])) {
|
if (isset($_POST["leave_team"])) {
|
||||||
quitTeam();
|
quitTeam();
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `year` = '$YEAR';");
|
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `year` = '$YEAR';");
|
||||||
@ -15,20 +16,18 @@ if (isset($_POST["send_document"])) {
|
|||||||
if (isset($_POST["request_validation"])) {
|
if (isset($_POST["request_validation"])) {
|
||||||
if (!checkCanValidate())
|
if (!checkCanValidate())
|
||||||
$error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
|
$error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
|
||||||
else {
|
else
|
||||||
$DB->exec("UPDATE `teams` SET `validation_status` = 'WAITING' WHERE `id` = " . $_SESSION["team_id"] . ";");
|
$_SESSION["team"]->setValidationStatus(ValidationStatus::WAITING);
|
||||||
$_SESSION["team_validation_status"] = "WAITING";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SESSION["user_id"]) && isset($_SESSION["team_id"])) {
|
if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"] !== null) {
|
||||||
$result = $DB->query("SELECT * FROM `teams` WHERE `id` = '" . $_SESSION["team_id"] . "' AND `year` = '$YEAR';");
|
/** @var Team $team */
|
||||||
$team_data = $result->fetch();
|
$team = $_SESSION["team"];
|
||||||
|
|
||||||
$tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch();
|
$tournament = Tournament::fromId($team->getTournamentId());
|
||||||
|
|
||||||
$documents_req = $DB->prepare("SELECT `file_id`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? GROUP BY `type`, `uploaded_at` ORDER BY `type`, `uploaded_at` DESC;");
|
$documents_req = $DB->prepare("SELECT `file_id`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? GROUP BY `type`, `uploaded_at` ORDER BY `type`, `uploaded_at` DESC;");
|
||||||
$documents_req->execute([$_SESSION["user_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
|
$documents_req->execute([$_SESSION["user_id"], $_SESSION[$team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $tournament->getId()]]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
require_once "../403.php";
|
require_once "../403.php";
|
||||||
@ -77,39 +76,35 @@ function sendDocument()
|
|||||||
|
|
||||||
function updateTeam()
|
function updateTeam()
|
||||||
{
|
{
|
||||||
global $DB, $YEAR, $URL_BASE, $team_data;
|
global $DB, $YEAR, $URL_BASE, $team;
|
||||||
|
|
||||||
if ($_SESSION["team_id"] == NULL)
|
|
||||||
return "Vous n'êtes pas dans une équipe.";
|
|
||||||
|
|
||||||
$name = htmlspecialchars($_POST["name"]);
|
$name = htmlspecialchars($_POST["name"]);
|
||||||
|
|
||||||
if (!isset($name) || $name == "")
|
if (!isset($name) || $name == "")
|
||||||
return "Vous devez spécifier un nom d'équipe.";
|
return "Vous devez spécifier un nom d'équipe.";
|
||||||
|
|
||||||
echo $team_data["id"];
|
$result = $DB->query("SELECT `id` FROM `teams` WHERE `name` = '" . $name . "' AND `id` != " . $team->getId() . " AND `year` = '$YEAR';");
|
||||||
$result = $DB->query("SELECT `id` FROM `teams` WHERE `name` = '" . $name . "' AND `id` != " . $team_data["id"] . " AND `year` = '$YEAR';");
|
|
||||||
if ($result->fetch())
|
if ($result->fetch())
|
||||||
return "Une équipe existe déjà avec ce nom." . $team_data["id"];
|
return "Une équipe existe déjà avec ce nom.";
|
||||||
|
|
||||||
$trigram = strtoupper(htmlspecialchars($_POST["trigram"]));
|
$trigram = strtoupper(htmlspecialchars($_POST["trigram"]));
|
||||||
|
|
||||||
if (!preg_match("#^[A-Z][A-Z][A-Z]$#", $trigram))
|
if (!preg_match("#^[A-Z][A-Z][A-Z]$#", $trigram))
|
||||||
return "Le trigramme entré n'est pas valide.";
|
return "Le trigramme entré n'est pas valide.";
|
||||||
|
|
||||||
$result = $DB->query("SELECT `id` FROM `teams` WHERE `trigram` = '" . $trigram . "' AND `id` != '" . $team_data["id"] . "' AND `year` = '$YEAR';");
|
$result = $DB->query("SELECT `id` FROM `teams` WHERE `trigram` = '" . $trigram . "' AND `id` != '" . $team->getId() . "' AND `year` = '$YEAR';");
|
||||||
if ($result->fetch())
|
if ($result->fetch())
|
||||||
return "Une équipe a déjà choisi ce trigramme.";
|
return "Une équipe a déjà choisi ce trigramme.";
|
||||||
|
|
||||||
$tournament_id = intval(htmlspecialchars($_POST["tournament"]));
|
$tournament_id = intval(htmlspecialchars($_POST["tournament"]));
|
||||||
|
$tournament = Tournament::fromId($tournament_id);
|
||||||
$result = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `id` = '" . $tournament_id . "' AND `year` = '$YEAR';");
|
if ($tournament === null)
|
||||||
$data = $result->fetch();
|
|
||||||
if ($data === FALSE)
|
|
||||||
return "Le tournoi spécifié n'existe pas.";
|
return "Le tournoi spécifié n'existe pas.";
|
||||||
|
|
||||||
$req = $DB->prepare("UPDATE `teams` SET `name` = ?, `trigram` = ?, `tournament` = ? WHERE `id` = ?;");
|
$team->setName($name);
|
||||||
$req->execute([$name, $trigram, $tournament_id, $team_data["id"]]);
|
$team->setTrigram($trigram);
|
||||||
|
$team->setTournamentId($tournament_id);
|
||||||
|
$_SESSION["tournament"] = $tournament;
|
||||||
|
|
||||||
header("Location: $URL_BASE/mon_equipe");
|
header("Location: $URL_BASE/mon_equipe");
|
||||||
|
|
||||||
@ -118,42 +113,43 @@ function updateTeam()
|
|||||||
|
|
||||||
function checkCanValidate()
|
function checkCanValidate()
|
||||||
{
|
{
|
||||||
global $DB, $team_data, $tournament_data, $YEAR;
|
global $DB, $team, $tournament, $YEAR;
|
||||||
$can_validate = $team_data["validation_status"] == "NOT_READY";
|
|
||||||
$can_validate &= $team_data["encadrant_1"] != NULL;
|
$can_validate = $team->getValidationStatus() == ValidationStatus::NOT_READY;
|
||||||
$can_validate &= $team_data["participant_4"] != NULL;
|
$can_validate &= $team->getEncadrants()[0] != NULL;
|
||||||
|
$can_validate &= $team->getParticipants()[3] != NULL;
|
||||||
for ($i = 1; $i <= 2; ++$i) {
|
for ($i = 1; $i <= 2; ++$i) {
|
||||||
if ($team_data["encadrant_$i"] === NULL)
|
if ($team->getEncadrants()[$i - 1] === NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||||
$req->execute([$team_data["encadrant_$i"], "PHOTO_CONSENT"]);
|
$req->execute([$team->getEncadrants()[$i - 1], "PHOTO_CONSENT"]);
|
||||||
$d = $req->fetch();
|
$d = $req->fetch();
|
||||||
$can_validate &= $d["version"] > 0;
|
$can_validate &= $d["version"] > 0;
|
||||||
|
|
||||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||||
$req->execute([$team_data["encadrant_$i"], "SANITARY_PLUG"]);
|
$req->execute([$team->getEncadrants()[$i - 1], "SANITARY_PLUG"]);
|
||||||
$d = $req->fetch();
|
$d = $req->fetch();
|
||||||
$can_validate &= $d["version"] > 0;
|
$can_validate &= $d["version"] > 0;
|
||||||
}
|
}
|
||||||
for ($i = 1; $i <= 6; ++$i) {
|
for ($i = 1; $i <= 6; ++$i) {
|
||||||
if ($team_data["participant_$i"] === NULL)
|
if ($team->getParticipants()[$i] === NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||||
$req->execute([$team_data["participant_$i"], "PHOTO_CONSENT"]);
|
$req->execute([$team->getParticipants()[$i], "PHOTO_CONSENT"]);
|
||||||
$d = $req->fetch();
|
$d = $req->fetch();
|
||||||
$can_validate &= $d["version"] > 0;
|
$can_validate &= $d["version"] > 0;
|
||||||
|
|
||||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||||
$req->execute([$team_data["participant_$i"], "SANITARY_PLUG"]);
|
$req->execute([$team->getParticipants()[$i], "SANITARY_PLUG"]);
|
||||||
$d = $req->fetch();
|
$d = $req->fetch();
|
||||||
$can_validate &= $d["version"] > 0;
|
$can_validate &= $d["version"] > 0;
|
||||||
|
|
||||||
$birth_date = $DB->query("SELECT `birth_date` FROM `users` WHERE `id` = " . $team_data["participant_$i"] . ";")->fetch()["birth_date"];
|
$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_data["date_start"], 4)) {
|
if ($birth_date > strval($YEAR - 18) . substr($tournament->getStartDate(), 4)) {
|
||||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||||
$req->execute([$team_data["participant_$i"], "PARENTAL_CONSENT"]);
|
$req->execute([$team->getParticipants()[$i], "PARENTAL_CONSENT"]);
|
||||||
$d = $req->fetch();
|
$d = $req->fetch();
|
||||||
$can_validate &= $d["version"] > 0;
|
$can_validate &= $d["version"] > 0;
|
||||||
}
|
}
|
||||||
|
@ -2,48 +2,50 @@
|
|||||||
|
|
||||||
require_once "../config.php";
|
require_once "../config.php";
|
||||||
|
|
||||||
|
if (isset($_SESSION["team"]) || !isset($_SESSION["user"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT))
|
||||||
|
require_once "../403.php";
|
||||||
|
|
||||||
if (isset($_POST["submitted"])) {
|
if (isset($_POST["submitted"])) {
|
||||||
$error_message = joinTeam();
|
$error_message = joinTeam();
|
||||||
}
|
}
|
||||||
|
|
||||||
function joinTeam() {
|
function joinTeam() {
|
||||||
global $DB, $YEAR, $MAIL_ADDRESS, $access_code, $data;
|
global $YEAR, $MAIL_ADDRESS, $access_code;
|
||||||
|
|
||||||
if ($_SESSION["team_id"] != NULL)
|
|
||||||
return "Vous êtes déjà dans une équipe.";
|
|
||||||
|
|
||||||
$access_code = htmlspecialchars($_POST["access_code"]);
|
$access_code = htmlspecialchars($_POST["access_code"]);
|
||||||
|
|
||||||
if (!isset($access_code) || strlen($access_code) != 6)
|
if (!isset($access_code) || strlen($access_code) != 6)
|
||||||
return "Le code d'accès doit comporter 6 caractères.";
|
return "Le code d'accès doit comporter 6 caractères.";
|
||||||
|
|
||||||
$result = $DB->query("SELECT * FROM `teams` WHERE `access_code` = '" . $access_code . "' AND `year` = '$YEAR';");
|
/** @var User $user */
|
||||||
if (($data = $result->fetch()) === FALSE)
|
$user = $_SESSION["user"];
|
||||||
|
$team = Team::fromAccessCode($access_code);
|
||||||
|
if ($team === null)
|
||||||
return "Ce code d'accès est invalide.";
|
return "Ce code d'accès est invalide.";
|
||||||
|
|
||||||
if ($_SESSION["role"] != "PARTICIPANT" && $_SESSION["role"] != "ENCADRANT")
|
if ($team->getValidationStatus() != ValidationStatus::NOT_READY)
|
||||||
return "Seuls les participants et les encadrants peuvent rejoindre une équipe.";
|
|
||||||
|
|
||||||
if ($data["validation_status"] != "NOT_READY")
|
|
||||||
return "Cette équipe est déjà en cours de validation ou validée, vous ne pouvez pas la rejoindre.";
|
return "Cette équipe est déjà en cours de validation ou validée, vous ne pouvez pas la rejoindre.";
|
||||||
|
|
||||||
for ($i = 1; $i <= $_SESSION["role"] == "PARTICIPANT" ? 6 : 2; ++$i) {
|
for ($i = 1; $i <= $_SESSION["role"] == Role::PARTICIPANT ? 6 : 2; ++$i) {
|
||||||
if ($data[strtolower($_SESSION["role"]) . "_" . strval($i)] == NULL)
|
if (($_SESSION["role"] == Role::PARTICIPANT ? $team->getParticipants()[$i - 1] : $team->getEncadrants()[$i - 1]) == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SESSION["role"] == "PARTICIPANT" && $i == 7 || $_SESSION["role"] == "ENCADRANT" && $i == 3)
|
if ($_SESSION["role"] == Role::PARTICIPANT && $i == 7 || $_SESSION["role"] == Role::ENCADRANT && $i == 3)
|
||||||
return "Il n'y a plus de place pour vous dans l'équipe.";
|
return "Il n'y a plus de place pour vous dans l'équipe.";
|
||||||
|
|
||||||
$DB->prepare("UPDATE `users` SET `team_id` = ? WHERE `id` = " . $_SESSION["user_id"] . ";")->execute([$data["id"]]);
|
$user->setTeamId($team->getId());
|
||||||
/** @noinspection SqlResolve */
|
|
||||||
$DB->prepare("UPDATE `teams` SET `" . strtolower($_SESSION["role"]) . "_" . strval($i) . "` = ? WHERE `id` = " . $data["id"] . ";")->execute([$_SESSION["user_id"]]);
|
|
||||||
|
|
||||||
$_SESSION["team_id"] = $data["id"];
|
if ($_SESSION["role"] == Role::ENCADRANT)
|
||||||
$_SESSION["team_validation_status"] = $data["validation_status"];
|
$team->setEncadrant($i, $user->getId());
|
||||||
|
else
|
||||||
|
$team->setParticipant($i, $user->getId());
|
||||||
|
|
||||||
$msg = "Bonjour " . $_SESSION["first_name"] . " " . $_SESSION["surname"] . ",\r\n\r\n";
|
$_SESSION["team"] = $team;
|
||||||
$msg .= "Vous venez de rejoindre l'équipe « " . $data["name"] . " » (" . $data["trigram"] . ") pour le TFJM² de " . $data["name"] . " et nous vous en remercions.\r\n\r\n";
|
$tournament = $_SESSION["tournament"] = Tournament::fromId($team->getTournamentId());
|
||||||
|
|
||||||
|
$msg = "Bonjour " . $user->getFirstName() . " " . $user->getSurname() . ",\r\n\r\n";
|
||||||
|
$msg .= "Vous venez de rejoindre l'équipe « " . $team->getName() . " » (" . $team->getTrigram() . ") pour le TFJM² de " . $tournament->getId() . " et nous vous en remercions.\r\n\r\n";
|
||||||
$msg .= "Cordialement,\r\n\r\nL'organisation du TFJM² $YEAR";
|
$msg .= "Cordialement,\r\n\r\nL'organisation du TFJM² $YEAR";
|
||||||
mail($_SESSION["email"], "Équipe rejointe TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n");
|
mail($_SESSION["email"], "Équipe rejointe TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n");
|
||||||
|
|
||||||
|
@ -2,16 +2,18 @@
|
|||||||
|
|
||||||
require_once "../config.php";
|
require_once "../config.php";
|
||||||
|
|
||||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ADMIN" && $_SESSION["role"] != "ORGANIZER")
|
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
|
||||||
require_once "../403.php";
|
require_once "../403.php";
|
||||||
|
|
||||||
|
/** @noinspection SqlAggregates */
|
||||||
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
|
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
|
||||||
. ($_SESSION["role"] == "ADMIN" ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
|
. ($_SESSION["role"] == Role::ADMIN ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
|
||||||
. "`year` = $YEAR GROUP BY `tournament` ORDER BY `name`;");
|
. "`year` = $YEAR GROUP BY `tournament` ORDER BY `name`;");
|
||||||
|
|
||||||
if (isset($_POST["download_zip"])) {
|
if (isset($_POST["download_zip"])) {
|
||||||
$id = $_POST["tournament"];
|
$id = $_POST["tournament"];
|
||||||
$tournament_name = $_POST["tournament_name"];
|
$tournament_name = $_POST["tournament_name"];
|
||||||
|
/** @noinspection SqlAggregates */
|
||||||
$files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team`, `problem` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
|
$files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team`, `problem` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
|
||||||
|
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
@ -27,9 +29,9 @@ if (isset($_POST["download_zip"])) {
|
|||||||
$problem = $data_file["problem"];
|
$problem = $data_file["problem"];
|
||||||
$version = $data_file["version"];
|
$version = $data_file["version"];
|
||||||
$team_id = $data_file["team"];
|
$team_id = $data_file["team"];
|
||||||
$team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch();
|
$team = Team::fromId($team_id);
|
||||||
$team_name = $team_data["name"];
|
$team_name = $team->getName();
|
||||||
$team_trigram = $team_data["trigram"];
|
$team_trigram = $team->getTrigram();
|
||||||
|
|
||||||
$zip->addFile("$LOCAL_PATH/files/$file_id", "Problème $problem $team_trigram.pdf");
|
$zip->addFile("$LOCAL_PATH/files/$file_id", "Problème $problem $team_trigram.pdf");
|
||||||
}
|
}
|
||||||
@ -50,15 +52,16 @@ require_once "../views/header.php";
|
|||||||
while (($data_tournament = $req->fetch()) !== false) {
|
while (($data_tournament = $req->fetch()) !== false) {
|
||||||
echo "<h1>Tournoi de " . $data_tournament["name"] . "</h1>\n";
|
echo "<h1>Tournoi de " . $data_tournament["name"] . "</h1>\n";
|
||||||
$id = $data_tournament["id"];
|
$id = $data_tournament["id"];
|
||||||
|
/** @noinspection SqlAggregates */
|
||||||
$files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
|
$files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
|
||||||
while (($data_file = $files_req->fetch()) !== false) {
|
while (($data_file = $files_req->fetch()) !== false) {
|
||||||
$file_id = $data_file["file_id"];
|
$file_id = $data_file["file_id"];
|
||||||
$problem = $data_file["problem"];
|
$problem = $data_file["problem"];
|
||||||
$version = $data_file["version"];
|
$version = $data_file["version"];
|
||||||
$team_id = $data_file["team"];
|
$team_id = $data_file["team"];
|
||||||
$team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch();
|
$team = Team::fromId($team_id);
|
||||||
$team_name = $team_data["name"];
|
$team_name = $team->getName();
|
||||||
$team_trigram = $team_data["trigram"];
|
$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 "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 />";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
<?php require_once "../config.php"; ?>
|
<?php require_once "../config.php";
|
||||||
|
|
||||||
<?php
|
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
|
||||||
|
|
||||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ADMIN" && $_SESSION["role"] != "ORGANIZER")
|
|
||||||
require_once "../403.php";
|
require_once "../403.php";
|
||||||
|
|
||||||
if (isset($_POST["download_zip"])) {
|
if (isset($_POST["download_zip"])) {
|
||||||
$id = $_POST["tournament"];
|
$id = $_POST["tournament"];
|
||||||
$tournament_name = $_POST["tournament_name"];
|
$tournament_name = $_POST["tournament_name"];
|
||||||
$files_req = $DB->query("SELECT *, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `tournament` = '$id' GROUP BY `team`, `dest`, `uploaded_at` ORDER BY `team`, `dest`, `uploaded_at` DESC;");
|
/** @noinspection SqlAggregates */
|
||||||
|
$files_req = $DB->query("SELECT *, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `tournament` = '$id' GROUP BY `team`, `dest` ORDER BY `team`, `dest`, `uploaded_at` DESC;");
|
||||||
|
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
|
|
||||||
@ -23,9 +22,9 @@ if (isset($_POST["download_zip"])) {
|
|||||||
$dest = $data_file["dest"];
|
$dest = $data_file["dest"];
|
||||||
$version = $data_file["version"];
|
$version = $data_file["version"];
|
||||||
$team_id = $data_file["team"];
|
$team_id = $data_file["team"];
|
||||||
$team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch();
|
$team = Team::fromId($team_id);
|
||||||
$team_name = $team_data["name"];
|
$team_name = $team->getName();
|
||||||
$team_trigram = $team_data["trigram"];
|
$team_trigram = $team->getTrigram();
|
||||||
|
|
||||||
$zip->addFile("$LOCAL_PATH/files/$file_id", "Note de synthèse $team_trigram pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur") . ".pdf");
|
$zip->addFile("$LOCAL_PATH/files/$file_id", "Note de synthèse $team_trigram pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur") . ".pdf");
|
||||||
}
|
}
|
||||||
@ -44,7 +43,7 @@ if (isset($_POST["download_zip"])) {
|
|||||||
require_once "../views/header.php";
|
require_once "../views/header.php";
|
||||||
|
|
||||||
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
|
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
|
||||||
. ($_SESSION["role"] == "ADMIN" ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
|
. ($_SESSION["role"] == Role::ADMIN ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
|
||||||
. "`year` = $YEAR GROUP BY `tournament`, `name` ORDER BY `name`;");
|
. "`year` = $YEAR GROUP BY `tournament`, `name` ORDER BY `name`;");
|
||||||
|
|
||||||
while (($data_tournament = $req->fetch()) !== false) {
|
while (($data_tournament = $req->fetch()) !== false) {
|
||||||
@ -56,9 +55,9 @@ while (($data_tournament = $req->fetch()) !== false) {
|
|||||||
$dest = $data_file["dest"];
|
$dest = $data_file["dest"];
|
||||||
$version = $data_file["version"];
|
$version = $data_file["version"];
|
||||||
$team_id = $data_file["team"];
|
$team_id = $data_file["team"];
|
||||||
$team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch();
|
$team = Team::fromId($team_id);
|
||||||
$team_name = $team_data["name"];
|
$team_name = $team->getName();
|
||||||
$team_trigram = $team_data["trigram"];
|
$team_trigram = $team->getTrigram();
|
||||||
echo "Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur")
|
echo "Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur")
|
||||||
. ", version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
. ", version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
}
|
}
|
||||||
|
@ -4,61 +4,56 @@ require_once "../config.php";
|
|||||||
|
|
||||||
$tournament_name = htmlspecialchars($_GET["nom"]);
|
$tournament_name = htmlspecialchars($_GET["nom"]);
|
||||||
|
|
||||||
$response = $DB->prepare("SELECT * FROM `tournaments` WHERE `name` = ? AND `year` = $YEAR;");
|
$tournament = Tournament::fromName($tournament_name);
|
||||||
$response->execute([$tournament_name]);
|
|
||||||
$data = $response->fetch();
|
|
||||||
|
|
||||||
if ($data === false)
|
if ($tournament === null)
|
||||||
require_once "../404.php";
|
require_once "../404.php";
|
||||||
|
|
||||||
$orgas_req = $DB->query("SELECT `users`.`id` AS `id`, `surname`, `first_name` FROM `users` JOIN `organizers` ON `users`.`id` = `organizer` WHERE `tournament` = " . $data["id"] . ";");
|
$orgas_req = $DB->query("SELECT `users`.`id` AS `id` FROM `users` JOIN `organizers` ON `users`.`id` = `organizer` WHERE `tournament` = " . $tournament->getId() . ";");
|
||||||
$orgas = [];
|
$orgas = [];
|
||||||
$orgas_id = [];
|
$orgas_id = [];
|
||||||
while (($orga_data = $orgas_req->fetch()) !== false) {
|
while (($orga_data = $orgas_req->fetch()) !== false) {
|
||||||
$orgas[] = $orga_data["first_name"] . " " . $orga_data["surname"];
|
$orgas[] = User::fromId($orga_data["id"]);
|
||||||
$orgas_id[] = $orga_data["id"];
|
$orgas_id[] = $orga_data["id"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET["modifier"]) && $_SESSION["role"] != "ADMIN" && !in_array($_SESSION["user_id"], $orgas_id))
|
if (isset($_GET["modifier"]) && $_SESSION["role"] != Role::ADMIN && !in_array($_SESSION["user_id"], $orgas_id))
|
||||||
require_once "../403.php";
|
require_once "../403.php";
|
||||||
|
|
||||||
if (isset($_POST["edit_tournament"])) {
|
if (isset($_POST["edit_tournament"])) {
|
||||||
$error_message = updateTournament();
|
$error_message = updateTournament();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data["final"])
|
if ($tournament->isFinal())
|
||||||
$teams_response = $DB->query("SELECT `id`, `name`, `trigram`, `inscription_date`, `validation_status` FROM `teams` WHERE `final_selection` AND `year` = $YEAR;");
|
$teams_response = $DB->query("SELECT `id`, `name`, `trigram`, `inscription_date`, `validation_status` FROM `teams` WHERE `final_selection` AND `year` = $YEAR;");
|
||||||
else
|
else
|
||||||
$teams_response = $DB->query("SELECT `id`, `name`, `trigram`, `inscription_date`, `validation_status` FROM `teams` WHERE `tournament` = " . $data["id"] . " AND `year` = $YEAR;");
|
$teams_response = $DB->query("SELECT `id`, `name`, `trigram`, `inscription_date`, `validation_status` FROM `teams` WHERE `tournament` = " . $tournament->getId() . " AND `year` = $YEAR;");
|
||||||
|
|
||||||
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
|
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
|
||||||
|
|
||||||
function updateTournament() {
|
function updateTournament() {
|
||||||
global $DB, $URL_BASE, $YEAR, $data;
|
global $DB, $URL_BASE, $YEAR, $tournament;
|
||||||
|
|
||||||
$tournament_id = $data["id"];
|
|
||||||
|
|
||||||
$name = htmlspecialchars($_POST["name"]);
|
$name = htmlspecialchars($_POST["name"]);
|
||||||
|
|
||||||
$result = $DB->query("SELECT `id` FROM `tournaments` WHERE `name` = '" . $name . "' AND `id` != $tournament_id AND `year` = '$YEAR';");
|
$result = $DB->query("SELECT `id` FROM `tournaments` WHERE `name` = '" . $name . "' AND `id` != " . $tournament->getId() . " AND `year` = '$YEAR';");
|
||||||
if ($result->fetch())
|
if ($result->fetch())
|
||||||
return "Un tournoi existe déjà avec ce nom.";
|
return "Un tournoi existe déjà avec ce nom.";
|
||||||
|
|
||||||
if (!isset($_POST["organizer"]) || sizeof($_POST["organizer"]) == 0)
|
if (!isset($_POST["organizer"]) || sizeof($_POST["organizer"]) == 0)
|
||||||
return "Aucun organisateur n'a été choisi.";
|
return "Aucun organisateur n'a été choisi.";
|
||||||
|
|
||||||
if ($_SESSION["role"] == "ADMIN") {
|
if ($_SESSION["role"] == Role::ADMIN) {
|
||||||
$organizers = $_POST["organizer"];
|
$organizers = $_POST["organizer"];
|
||||||
$orga_mails = [];
|
$orga_mails = [];
|
||||||
|
|
||||||
foreach ($organizers as $orga) {
|
foreach ($organizers as $orga_id) {
|
||||||
$result = $DB->query("SELECT `role`, `email` FROM `users` WHERE `id` = '" . $orga . "' AND `year` = '$YEAR';");
|
$orga = User::fromId($orga_id);
|
||||||
$data = $result->fetch();
|
if ($orga === null)
|
||||||
if ($data === FALSE)
|
|
||||||
return "L'organisateur spécifié n'existe pas.";
|
return "L'organisateur spécifié n'existe pas.";
|
||||||
if ($data["role"] != "ORGANIZER" && $data["role"] != "ADMIN")
|
if ($orga->getRole() != Role::ORGANIZER && $orga->getRole() != Role::ADMIN)
|
||||||
return "L'organisateur indiqué ne peut pas organiser de tournoi.";
|
return "L'organisateur indiqué ne peut pas organiser de tournoi.";
|
||||||
$orga_mails[] = $data["email"];
|
$orga_mails[] = $orga->getEmail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,15 +107,15 @@ function updateTournament() {
|
|||||||
|
|
||||||
$req = $DB->prepare("UPDATE `tournaments` SET `name` = ?, `size` = ?, `place` = ?, `price` = ?, `description` = ?,
|
$req = $DB->prepare("UPDATE `tournaments` SET `name` = ?, `size` = ?, `place` = ?, `price` = ?, `description` = ?,
|
||||||
`date_start` = ?, `date_end` = ?, `date_inscription` = ?, `date_solutions` = ?, `date_syntheses` = ?
|
`date_start` = ?, `date_end` = ?, `date_inscription` = ?, `date_solutions` = ?, `date_syntheses` = ?
|
||||||
WHERE `id` = $tournament_id;");
|
WHERE `id` = " . $tournament->getId() . ";");
|
||||||
$req->execute([$name, $size, $place, $price, $description, $date_start, $date_end,
|
$req->execute([$name, $size, $place, $price, $description, $date_start, $date_end,
|
||||||
"$date_inscription $time_inscription", "$date_solutions $time_solutions", "$date_syntheses $time_syntheses"]);
|
"$date_inscription $time_inscription", "$date_solutions $time_solutions", "$date_syntheses $time_syntheses"]);
|
||||||
|
|
||||||
if ($_SESSION["role"] == "ADMIN") {
|
if ($_SESSION["role"] == Role::ADMIN) {
|
||||||
$DB->exec("DELETE FROM `organizers` WHERE `tournament` = $tournament_id;");
|
$DB->exec("DELETE FROM `organizers` WHERE `tournament` = " . $tournament->getId() . ";");
|
||||||
foreach ($organizers as $orga) {
|
foreach ($organizers as $orga) {
|
||||||
$req = $DB->prepare("INSERT INTO `organizers`(`organizer`, `tournament`) VALUES(?, ?);");
|
$req = $DB->prepare("INSERT INTO `organizers`(`organizer`, `tournament`) VALUES(?, ?);");
|
||||||
$req->execute([$orga, $tournament_id]);
|
$req->execute([$orga->getId(), $tournament->getId()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ if (($data = $req->fetch()) === false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($data !== false) {
|
if ($data !== false) {
|
||||||
$team_data = $DB->query("SELECT `trigram` FROM `teams` WHERE `id` = " . $data["team"] . ";")->fetch();
|
$team = Team::fromId($data["team"]);
|
||||||
$tournament_data = $DB->query("SELECT `name` FROM `tournaments` WHERE `id` = " . $data["tournament"] . ";")->fetch();
|
$tournament = Tournament::fromId($data["tournament"]);
|
||||||
$trigram = $team_data["trigram"];
|
$trigram = $team->getTrigram();
|
||||||
if ($type == "SOLUTION") {
|
if ($type == "SOLUTION") {
|
||||||
$problem = $data["problem"];
|
$problem = $data["problem"];
|
||||||
$name = "Problème $problem $trigram.pdf";
|
$name = "Problème $problem $trigram.pdf";
|
||||||
|
@ -1,65 +1,48 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function loadUserValues() {
|
function loadUserValues() {
|
||||||
global $DB, $URL_BASE, $YEAR;
|
$_SESSION["final"] = Tournament::getFinalTournament();
|
||||||
|
|
||||||
|
$_SESSION["user"] = $_SESSION["team"] = $_SESSION["tournament"] = null;
|
||||||
|
unset($_SESSION["user"]);
|
||||||
|
unset($_SESSION["role"]);
|
||||||
|
unset($_SESSION["team"]);
|
||||||
|
unset($_SESSION["tournament"]);
|
||||||
|
|
||||||
if (isset($_SESSION["user_id"])) {
|
if (isset($_SESSION["user_id"])) {
|
||||||
$response = $DB->query("SELECT * FROM `users` WHERE `id` ='" . $_SESSION["user_id"] . "' AND `year` = '$YEAR';");
|
$user = $_SESSION["user"] = User::fromId($_SESSION["user_id"]);
|
||||||
$data = $response->fetch();
|
$_SESSION["role"] = $user->getRole();
|
||||||
if ($data === FALSE)
|
|
||||||
unset($_SESSION["user_id"]);
|
if ($user->getTeamId() !== null) {
|
||||||
else {
|
$team = $_SESSION["team"] = Team::fromId($user->getTeamId());
|
||||||
$_SESSION["email"] = $data["email"];
|
$_SESSION["tournament"] = Tournament::fromId($team->getTournamentId());
|
||||||
$_SESSION["surname"] = $data["surname"];
|
|
||||||
$_SESSION["first_name"] = $data["first_name"];
|
|
||||||
$_SESSION["birth_date"] = $data["birth_date"];
|
|
||||||
$_SESSION["role"] = $data["role"];
|
|
||||||
$_SESSION["team_id"] = $data["team_id"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SESSION["user_id"]) && isset($_SESSION["team_id"]) && $_SESSION["team_id"] != NULL) {
|
if (isset($_GET["be-admin"])) {
|
||||||
$response = $DB->query("SELECT `tournament`, `validation_status`, `final_selection` FROM `teams` WHERE `id` ='" . $_SESSION["team_id"] . "' AND `year` = '$YEAR';");
|
|
||||||
$data = $response->fetch();
|
|
||||||
$_SESSION["tournament_id"] = $data["tournament"];
|
|
||||||
$_SESSION["team_validation_status"] = $data["validation_status"];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((isset($data["final_selection"]) && $data["final_selection"]) || $_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER") {
|
|
||||||
$response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `final` AND `year` = $YEAR;");
|
|
||||||
$data = $response->fetch();
|
|
||||||
$_SESSION["final_id"] = $data["id"];
|
|
||||||
$_SESSION["final_name"] = $data["name"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-admin"])) {
|
|
||||||
$DB->exec("UPDATE `users` SET `role` = 'ADMIN' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
|
||||||
quitTeam();
|
quitTeam();
|
||||||
header("Location: $URL_BASE");
|
$user->setRole(Role::ADMIN);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-organizer"])) {
|
if (isset($_GET["be-organizer"])) {
|
||||||
$DB->exec("UPDATE `users` SET `role` = 'ORGANIZER' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
|
||||||
quitTeam();
|
quitTeam();
|
||||||
header("Location: $URL_BASE");
|
$user->setRole(Role::ORGANIZER);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-participant"])) {
|
if (isset($_GET["be-participant"])) {
|
||||||
$DB->exec("UPDATE `users` SET `role` = 'PARTICIPANT' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
|
||||||
quitTeam();
|
quitTeam();
|
||||||
header("Location: $URL_BASE");
|
$user->setRole(Role::PARTICIPANT);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-encadrant"])) {
|
if (isset($_GET["be-encadrant"])) {
|
||||||
$DB->exec("UPDATE `users` SET `role` = 'ENCADRANT' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
|
||||||
quitTeam();
|
quitTeam();
|
||||||
header("Location: $URL_BASE");
|
$user->setRole(Role::ENCADRANT);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function echoDate($date = NULL, $with_time = false) {
|
function echoDate($date = NULL, $with_time = false) {
|
||||||
if ($date == NULL)
|
if ($date == NULL)
|
||||||
@ -71,35 +54,44 @@ function echoDate($date = NULL, $with_time = false) {
|
|||||||
function quitTeam() {
|
function quitTeam() {
|
||||||
global $DB, $URL_BASE;
|
global $DB, $URL_BASE;
|
||||||
|
|
||||||
if ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER")
|
header("Location: $URL_BASE");
|
||||||
|
|
||||||
|
/** @var User $user */
|
||||||
|
$user = $_SESSION["user"];
|
||||||
|
$user_id = $user->getId();
|
||||||
|
$role = $user->getRole();
|
||||||
|
|
||||||
|
if ($role == Role::ADMIN || $role == Role::ORGANIZER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for ($i = 1; $i <= ($_SESSION["role"] == "PARTICIPANT" ? 6 : 2); ++$i)
|
for ($i = 1; $i <= ($role == Role::ENCADRANT ? 6 : 2); ++$i)
|
||||||
/** @noinspection SqlResolve */
|
/** @noinspection SqlResolve */
|
||||||
$DB->exec("UPDATE `teams` SET `" . strtolower($_SESSION["role"]) . "_$i` = NULL WHERE `" . strtolower($_SESSION["role"]) . "_$i` = " . $_SESSION["user_id"] . ";");
|
$DB->exec("UPDATE `teams` SET `" . strtolower(Role::getName($role)) . "_$i` = NULL WHERE `" . strtolower(Role::getName($role)) . "_$i` = $user_id;");
|
||||||
$DB->exec("UPDATE `users` SET `team_id` = NULL WHERE `id` = " . $_SESSION["user_id"] . ";");
|
$user->setTeamId(null);
|
||||||
$DB->exec("UPDATE `teams` SET `encadrant_1` = `encadrant_2`, `encadrant_2` = NULL WHERE `encadrant_1` IS NULL;");
|
$DB->exec("UPDATE `teams` SET `encadrant_1` = `encadrant_2`, `encadrant_2` = NULL WHERE `encadrant_1` IS NULL;");
|
||||||
for ($i = 1; $i <= 5; ++$i) {
|
for ($i = 1; $i <= 5; ++$i) {
|
||||||
/** @noinspection SqlResolve */
|
/** @noinspection SqlResolve */
|
||||||
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
|
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
|
||||||
}
|
}
|
||||||
|
|
||||||
$req = $DB->query("SELECT `file_id` FROM `documents` WHERE `user` = '" . $_SESSION["user_id"] . "';");
|
$req = $DB->query("SELECT `file_id` FROM `documents` WHERE `user` = $user_id;");
|
||||||
while (($data = $req->fetch()) !== false)
|
while (($data = $req->fetch()) !== false)
|
||||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||||
$DB->exec("DELETE FROM `documents` WHERE `user` = '" . $_SESSION["user_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) {
|
if ($DB->exec("DELETE FROM `teams` WHERE `encadrant_1` IS NULL AND `participant_1` IS NULL;") > 0) {
|
||||||
$req = $DB->query("SELECT `file_id` FROM `solutions` WHERE `team` = '" . $_SESSION["team_id"] . "';");
|
$team_id = $user->getTeamId();
|
||||||
|
$req = $DB->query("SELECT `file_id` FROM `solutions` WHERE `team` = $team_id;");
|
||||||
while (($data = $req->fetch()) !== false)
|
while (($data = $req->fetch()) !== false)
|
||||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||||
$DB->exec("DELETE FROM `solutions` WHERE `team` = " . $_SESSION["team_id"] . ";");
|
$DB->exec("DELETE FROM `solutions` WHERE `team` = $team_id;");
|
||||||
|
|
||||||
$req = $DB->query("SELECT `file_id` FROM `syntheses` WHERE `team` = '" . $_SESSION["team_id"] . "';");
|
$req = $DB->query("SELECT `file_id` FROM `syntheses` WHERE `team` = $team_id;");
|
||||||
while (($data = $req->fetch()) !== false)
|
while (($data = $req->fetch()) !== false)
|
||||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||||
$DB->exec("DELETE FROM `syntheses` WHERE `team` = " . $_SESSION["team_id"] . ";");
|
$DB->exec("DELETE FROM `syntheses` WHERE `team` = $team_id;");
|
||||||
}
|
}
|
||||||
unset($_SESSION["team_id"]);
|
|
||||||
unset($_SESSION["team_validation_status"]);
|
$_SESSION["team"] = null;
|
||||||
|
unset($_SESSION["team"]);
|
||||||
}
|
}
|
@ -1,10 +1,7 @@
|
|||||||
<?php if (!isset($_SESSION["role"]) or ($_SESSION["role"] != "PARTICIPANT" && $_SESSION["role"] != "ENCADRANT")) {
|
<?php if ($_SESSION["team"] != NULL) { ?>
|
||||||
?>
|
|
||||||
<h2>Vous devez être participant ou encadrant pour pouvoir ajouter une équipe.</h2>
|
|
||||||
<?php } else if ($_SESSION["team_id"] != NULL) { ?>
|
|
||||||
<h2>Vous êtes déjà dans une équipe.</h2>
|
<h2>Vous êtes déjà dans une équipe.</h2>
|
||||||
<?php } else if (isset($access_code)) { ?>
|
<?php } else if (isset($access_code)) { ?>
|
||||||
Votre équipe a bien été créée ! Voici le code d'accès à transmettre aux autres membres de votre équipe : <strong><?php echo $access_code ?></strong>
|
Votre équipe a bien été créée ! Voici le code d'accès à transmettre aux autres membres de votre équipe : <strong><?= $access_code ?></strong>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
<h2>Informations sur l'équipe</h2>
|
<h2>Informations sur l'équipe</h2>
|
||||||
|
|
||||||
Nom de l'équipe : <?= $team_data["name"] ?><br />
|
Nom de l'équipe : <?= $team->getName() ?><br />
|
||||||
Trigramme : <?= $team_data["trigram"] ?><br />
|
Trigramme : <?= $team->getTrigram() ?><br />
|
||||||
Tournoi : <a href="<?= $URL_BASE . "/tournoi/" . $tournament_data["name"] ?>"><?= $tournament_data["name"] ?></a><br />
|
Tournoi : <a href="<?= $URL_BASE . "/tournoi/" . $tournament->getName() ?>"><?= $tournament->getName() ?></a><br />
|
||||||
<?php
|
<?php
|
||||||
for ($i = 1; $i <= 2; ++$i) {
|
for ($i = 1; $i <= 2; ++$i) {
|
||||||
if ($team_data["encadrant_" . $i] == NULL)
|
if ($team->getEncadrants()[$i] == NULL)
|
||||||
continue;
|
continue;
|
||||||
$user_data = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["encadrant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
$encadrant = User::fromId($team->getEncadrants()[$i - 1]);
|
||||||
$id = $user_data["id"];
|
$id = $encadrant->getId();
|
||||||
echo "Encadrant $i : <a href=\"$URL_BASE/informations/$id/" . $user_data["first_name"] . " " . $user_data["surname"] . "\">" . $user_data["first_name"] . " " . $user_data["surname"] . "</a><br />";
|
echo "Encadrant $i : <a href=\"$URL_BASE/informations/$id/" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "\">" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "</a><br />";
|
||||||
}
|
}
|
||||||
for ($i = 1; $i <= 6; ++$i) {
|
for ($i = 1; $i <= 6; ++$i) {
|
||||||
if ($team_data["participant_" . $i] == NULL)
|
if ($team->getParticipants()[$i - 1] == NULL)
|
||||||
continue;
|
continue;
|
||||||
$user_data = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["participant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
$participant = User::fromId($team->getParticipants()[$i - 1]);
|
||||||
$id = $user_data["id"];
|
$id = $participant->getId();
|
||||||
echo "Participant $i : <a href=\"$URL_BASE/informations/$id/" . $user_data["first_name"] . " " . $user_data["surname"] . "\">" . $user_data["first_name"] . " " . $user_data["surname"] . "</a><br />";
|
echo "Participant $i : <a href=\"$URL_BASE/informations/$id/" . $participant->getFirstName() . " " . $participant->getSurname() . "\">" . $participant->getFirstName() . " " . $participant->getSurname() . "</a><br />";
|
||||||
}
|
}
|
||||||
if ($team_data["final_selection"]) {
|
if ($team->isSelectedForFinal()) {
|
||||||
$final_name = $_SESSION["final_name"];
|
$final_name = $_SESSION["final"]->getName();
|
||||||
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong>";
|
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -52,7 +52,7 @@ while (($data = $documents_req->fetch()) !== false) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if ($team_data["final_selection"]) { ?>
|
<?php if ($team->isSelectedForFinal()) { ?>
|
||||||
<hr />
|
<hr />
|
||||||
<h2>Autorisations pour la finale</h2>
|
<h2>Autorisations pour la finale</h2>
|
||||||
<?php
|
<?php
|
||||||
@ -79,14 +79,14 @@ while (($data = $documents_req->fetch()) !== false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($team_data["validation_status"] == "WAITING" && $_SESSION["role"] == "ADMIN") { ?>
|
if ($team->getValidationStatus() == ValidationStatus::WAITING && $_SESSION["role"] == Role::ADMIN) { ?>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<input style="width: 100%;" type="submit" name="validate" value="Valider l'équipe" />
|
<input style="width: 100%;" type="submit" name="validate" value="Valider l'équipe" />
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$team_data["final_selection"]) { ?>
|
if (!$team->isSelectedForFinal() && isset($_SESSION["user_id"]) && $_SESSION["role"] == Role::ADMIN) { ?>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale" />
|
<input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale" />
|
||||||
</form>
|
</form>
|
||||||
|
@ -30,40 +30,40 @@
|
|||||||
<li><a href="<?= $URL_BASE ?>/inscription">Inscription</a></li>
|
<li><a href="<?= $URL_BASE ?>/inscription">Inscription</a></li>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<li><a href="<?= $URL_BASE ?>/mon_compte">Mon compte</a></li>
|
<li><a href="<?= $URL_BASE ?>/mon_compte">Mon compte</a></li>
|
||||||
<?php if ($_SESSION["role"] == "ENCADRANT" || $_SESSION["role"] == "PARTICIPANT") { ?>
|
<?php if ($_SESSION["role"] == Role::ENCADRANT || $_SESSION["role"] == Role::PARTICIPANT) { ?>
|
||||||
<?php if ($_SESSION["team_id"] == NULL) { ?>
|
<?php if ($_SESSION["team"] == NULL) { ?>
|
||||||
<li><a href="<?= $URL_BASE ?>/ajouter_equipe">Ajouter une équipe</a></li>
|
<li><a href="<?= $URL_BASE ?>/ajouter_equipe">Ajouter une équipe</a></li>
|
||||||
<li><a href="<?= $URL_BASE ?>/rejoindre_equipe">Rejoindre une équipe</a></li>
|
<li><a href="<?= $URL_BASE ?>/rejoindre_equipe">Rejoindre une équipe</a></li>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<li><a href="<?= $URL_BASE ?>/mon_equipe">Mon équipe</a></li>
|
<li><a href="<?= $URL_BASE ?>/mon_equipe">Mon équipe</a></li>
|
||||||
<?php if ($_SESSION["team_validation_status"] == "VALIDATED" || true) { ?>
|
<?php if ($_SESSION["team"]->getValidationStatus() == ValidationStatus::VALIDATED || true) { ?>
|
||||||
<li><a href="https://paypal.me/galaxyoyo42">Paiement</a></li>
|
<li><a href="https://paypal.me/galaxyoyo42">Paiement</a></li>
|
||||||
<li><a href="<?= $URL_BASE ?>/solutions">Solutions</a></li>
|
<li><a href="<?= $URL_BASE ?>/solutions">Solutions</a></li>
|
||||||
<li><a href="<?= $URL_BASE ?>/syntheses">Notes de synthèse</a></li>
|
<li><a href="<?= $URL_BASE ?>/syntheses">Notes de synthèse</a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($_SESSION["role"] == "ADMIN") { ?>
|
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
|
||||||
<li><a href="<?= $URL_BASE ?>/ajouter_tournoi">Ajouter un tournoi</a></li>
|
<li><a href="<?= $URL_BASE ?>/ajouter_tournoi">Ajouter un tournoi</a></li>
|
||||||
<li><a href="<?= $URL_BASE ?>/ajouter_organisateur">Ajouter un organisateur</a></li>
|
<li><a href="<?= $URL_BASE ?>/ajouter_organisateur">Ajouter un organisateur</a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER") { ?>
|
<?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 ?>/solutions_orga">Solutions</a></li>
|
||||||
<li><a href="<?= $URL_BASE ?>/syntheses_orga">Notes de synthèse</a></li>
|
<li><a href="<?= $URL_BASE ?>/syntheses_orga">Notes de synthèse</a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<li><a href="<?= $URL_BASE ?>/deconnexion">Déconnexion</a></li>
|
<li><a href="<?= $URL_BASE ?>/deconnexion">Déconnexion</a></li>
|
||||||
<hr />
|
<hr />
|
||||||
<?php
|
<?php
|
||||||
if ($_SESSION["role"] != "ADMIN") {
|
if ($_SESSION["role"] != Role::ADMIN) {
|
||||||
echo "<li><a href=\"?be-admin=1\">Devenir administrateur</a></li>";
|
echo "<li><a href=\"?be-admin=1\">Devenir administrateur</a></li>";
|
||||||
}
|
}
|
||||||
if ($_SESSION["role"] != "ORGANIZER") {
|
if ($_SESSION["role"] != Role::ORGANIZER) {
|
||||||
echo "<li><a href=\"?be-organizer=1\">Devenir organisateur</a></li>";
|
echo "<li><a href=\"?be-organizer=1\">Devenir organisateur</a></li>";
|
||||||
}
|
}
|
||||||
if ($_SESSION["role"] != "PARTICIPANT") {
|
if ($_SESSION["role"] != Role::PARTICIPANT) {
|
||||||
echo "<li><a href=\"?be-participant=1\">Devenir participant</a></li>";
|
echo "<li><a href=\"?be-participant=1\">Devenir participant</a></li>";
|
||||||
}
|
}
|
||||||
if ($_SESSION["role"] != "ENCADRANT") {
|
if ($_SESSION["role"] != Role::ENCADRANT) {
|
||||||
echo "<li><a href=\"?be-encadrant=1\">Devenir encadrant</a></li>";
|
echo "<li><a href=\"?be-encadrant=1\">Devenir encadrant</a></li>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<h1><?= $user_data["first_name"] . " " . $user_data["surname"] ?></h1>
|
<h1><?= $user->getFirstName() . " " . $user->getSurname() ?></h1>
|
||||||
|
|
||||||
<?php if ($user_data["role"] == "PARTICIPANT" || $user_data["role"] == "ENCADRANT") { ?>
|
<?php if ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?>
|
||||||
Équipe : <?= $team_data === false ? "Pas d'équipe" : "<a href=\"$URL_BASE/equipe/" . $team_data["trigram"] . "\">" . $team_data["name"] . " (" . $team_data["trigram"] . ")</a>" ?><br />
|
Équipe : <?= $team === null ? "Pas d'équipe" : "<a href=\"$URL_BASE/equipe/" . $team->getTrigram() . "\">" . $team->getName() . " (" . $team->getTrigram() . ")</a>" ?><br />
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
Date de naissance : <?= echoDate($user_data["birth_date"]) ?><br />
|
Date de naissance : <?= echoDate($user->getBirthDate()) ?><br />
|
||||||
Sexe : <?= $user_data["gender"] == "M" ? "Masculin" : "Féminin" ?><br />
|
Sexe : <?= $user->getGender() == "M" ? "Masculin" : "Féminin" ?><br />
|
||||||
Adresse : <?= $user_data["address"] . ", " . $user_data["postal_code"] . " " . $user_data["city"] . ($user_data["country"] == "France" ? "" : ", " . $user_data["country"]) ?><br />
|
Adresse : <?= $user->getAddress() . ", " . $user->getPostalCode() . " " . $user->getCity() . ($user->getCountry() == "France" ? "" : ", " . $user->getCountry()) ?><br />
|
||||||
Adresse e-mail : <a href="mailto:<?= $user_data["email"] ?>"><?= $user_data["email"] ?></a><br />
|
Adresse e-mail : <a href="mailto:<?= $user->getEmail() ?>"><?= $user->getEmail() ?></a><br />
|
||||||
Numéro de téléphone : <?= $user_data["phone_number"] ?><br />
|
Numéro de téléphone : <?= $user->getPhoneNumber() ?><br />
|
||||||
|
|
||||||
<?php if ($user_data["role"] == "PARTICIPANT") { ?>
|
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
|
||||||
Lycée : <?= $user_data["school"] ?><br />
|
Lycée : <?= $user->getSchool() ?><br />
|
||||||
Classe : <?php switch ($user_data["class"]) {
|
Classe : <?php switch ($user->getClass()) {
|
||||||
case "TERMINALE":
|
case "TERMINALE":
|
||||||
echo "Terminale";
|
echo "Terminale";
|
||||||
break;
|
break;
|
||||||
@ -26,22 +26,21 @@ Numéro de téléphone : <?= $user_data["phone_number"] ?><br />
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?><br />
|
?><br />
|
||||||
Nom du responsable légal : <?= $user_data["responsible_name"] ?><br />
|
Nom du responsable légal : <?= $user->getResponsibleName() ?><br />
|
||||||
Numéro de téléphone du responsable légal : <?= $user_data["responsible_phone"] ?><br />
|
Numéro de téléphone du responsable légal : <?= $user->getResponsiblePhone() ?><br />
|
||||||
Adresse e-mail du responsable légal : <a href="mailto:<?= $user_data["responsible_email"] ?>"><?= $user_data["responsible_email"] ?></a>
|
Adresse e-mail du responsable légal : <a href="mailto:<?= $user->getResponsibleEmail() ?>"><?= $user->getResponsibleEmail() ?></a>
|
||||||
<?php } elseif ($user_data["description"] != "") { ?>
|
<?php } elseif ($user->getDescription() != "") { ?>
|
||||||
Description : <?= $user_data["description"] ?><br />
|
Description : <?= $user->getDescription() ?><br />
|
||||||
<?php }
|
<?php }
|
||||||
|
|
||||||
echo "<hr />";
|
echo "<hr />";
|
||||||
|
|
||||||
if ($user_data["role"] == "ADMIN" || $user_data["role"] == "ORGANIZER") {
|
if ($user->getRole() == Role::ADMIN || $user->getRole() == Role::ORGANIZER) {
|
||||||
while (($tournament_data = $tournaments_req->fetch()) !== false) {
|
while (($tournament_data = $tournaments_req->fetch()) !== false) {
|
||||||
echo "Organise le tournoi <a href=\"$URL_BASE/tournoi/" . $tournament_data["name"] . "\">" . $tournament_data["name"] . "</a><br />";
|
echo "Organise le tournoi <a href=\"$URL_BASE/tournoi/" . $tournament_data["name"] . "\">" . $tournament_data["name"] . "</a><br />";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($user_data["role"] == "PARTICIPANT" || $user_data["role"] == "ENCADRANT") { ?>
|
elseif ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?>
|
||||||
<hr />
|
|
||||||
<h2>Autorisations</h2>
|
<h2>Autorisations</h2>
|
||||||
<?php
|
<?php
|
||||||
while (($data = $documents_req->fetch()) !== false) {
|
while (($data = $documents_req->fetch()) !== false) {
|
||||||
|
@ -5,9 +5,7 @@ if (isset($error_message) && $error_message === FALSE) {
|
|||||||
?>
|
?>
|
||||||
Votre inscription est validée ! Merci désormais de confirmer votre boîte mail pour valider votre adresse.
|
Votre inscription est validée ! Merci désormais de confirmer votre boîte mail pour valider votre adresse.
|
||||||
<?php } else if (isset($_SESSION["user_id"])) { ?>
|
<?php } else if (isset($_SESSION["user_id"])) { ?>
|
||||||
|
|
||||||
<h2>Vous êtes déjà connecté !</h2>
|
<h2>Vous êtes déjà connecté !</h2>
|
||||||
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
@ -56,7 +54,7 @@ if (isset($error_message) && $error_message === FALSE) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="country">Pays :</label></td>
|
<td><label for="country">Pays :</label></td>
|
||||||
<td><input style="width: 100%;" type="text" id="country" name="country" value="<?php echo isset($_POST["country"]) ? $_POST["country"] : "France" ?>" required /></td>
|
<td><input style="width: 100%;" type="text" id="country" name="country" value="<?= isset($_POST["country"]) ? $_POST["country"] : "France" ?>" required /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
||||||
|
@ -16,76 +16,76 @@ if (isset($error_message) && $error_message === FALSE) {
|
|||||||
<table style="width: 100%">
|
<table style="width: 100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 30%"><label for="email">E-mail :</label></td>
|
<td style="width: 30%"><label for="email">E-mail :</label></td>
|
||||||
<td style="width: 70%"><?php echo $user_data["email"] ?></td>
|
<td style="width: 70%"><?= $user->getEmail() ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input style="width: 100%" type="email" id="email" name="email"/></td>
|
<td colspan="2"><input style="width: 100%" type="email" id="email" name="email"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="surname">Nom :</label></td>
|
<td><label for="surname">Nom :</label></td>
|
||||||
<td><?php echo $user_data["surname"] ?></td>
|
<td><?= $user->getSurname() ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input style="width: 100%" type="text" id="surname" name="surname"/></td>
|
<td colspan="2"><input style="width: 100%" type="text" id="surname" name="surname"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="firstname">Prénom :</label></td>
|
<td><label for="firstname">Prénom :</label></td>
|
||||||
<td><?php echo $user_data["first_name"] ?></td>
|
<td><?= $user->getFirstName() ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input style="width: 100%" type="text" id="firstname" name="firstname"/></td>
|
<td colspan="2"><input style="width: 100%" type="text" id="firstname" name="firstname"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="birth_date">Date de naissance :</label></td>
|
<td><label for="birth_date">Date de naissance :</label></td>
|
||||||
<td><?php echo echoDate($user_data["birth_date"]) ?></td>
|
<td><?= echoDate($user->getBirthDate()) ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input style="width: 100%" type="date" id="birth_date" name="birth_date"/></td>
|
<td colspan="2"><input style="width: 100%" type="date" id="birth_date" name="birth_date"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="gender">Sexe :</label></td>
|
<td><label for="gender">Sexe :</label></td>
|
||||||
<td><input type="radio" id="male" name="gender" value="M" <?php if ($user_data["gender"] == "M") echo "checked" ?> /><label for="male">Homme</label>
|
<td><input type="radio" id="male" name="gender" value="M" <?php if ($user->getGender() == "M") echo "checked" ?> /><label for="male">Homme</label>
|
||||||
<input type="radio" id="female" name="gender" value="F" <?php if ($user_data["gender"] == "F") echo "checked" ?> /><label for="female">Femme</label></td>
|
<input type="radio" id="female" name="gender" value="F" <?php if ($user->getGender() == "F") echo "checked" ?> /><label for="female">Femme</label></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="address">Adresse :</label></td>
|
<td><label for="address">Adresse :</label></td>
|
||||||
<td><?php echo $user_data["address"] ?></td>
|
<td><?= $user->getAddress() ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input style="width: 100%" type="text" id="address" name="address"/></td>
|
<td colspan="2"><input style="width: 100%" type="text" id="address" name="address"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="postal_code">Code postal :</label></td>
|
<td><label for="postal_code">Code postal :</label></td>
|
||||||
<td><?php echo $user_data["postal_code"] ?></td>
|
<td><?= $user->getPostalCode() ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input style="width: 100%" type="number" id="postal_code" name="postal_code" min="1000" max="95999"/></td>
|
<td colspan="2"><input style="width: 100%" type="number" id="postal_code" name="postal_code" min="1000" max="95999"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="city">Ville :</label></td>
|
<td><label for="city">Ville :</label></td>
|
||||||
<td><?php echo $user_data["city"] ?></td>
|
<td><?= $user->getCity() ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input style="width: 100%" type="text" id="city" name="city"/></td>
|
<td colspan="2"><input style="width: 100%" type="text" id="city" name="city"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="country">Pays :</label></td>
|
<td><label for="country">Pays :</label></td>
|
||||||
<td><?php echo $user_data["country"] ?></td>
|
<td><?= $user->getCountry() ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input style="width: 100%" type="text" id="country" name="country"/></td>
|
<td colspan="2"><input style="width: 100%" type="text" id="country" name="country"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
||||||
<td><?php echo $user_data["phone_number"] ?></td>
|
<td><?= $user->getPhoneNumber() ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input style="width: 100%" type="text" id="phone_number" name="phone_number"/></td>
|
<td colspan="2"><input style="width: 100%" type="text" id="phone_number" name="phone_number"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ($user_data["role"] == "PARTICIPANT") { ?>
|
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="school">Établissement dans lequel l'élève étudie :</label></td>
|
<td><label for="school">Établissement dans lequel l'élève étudie :</label></td>
|
||||||
<td><?php echo $user_data["school"] ?></td>
|
<td><?= $user->getSchool() ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input style="width: 100%" type="text" id="school" name="school"/></td>
|
<td colspan="2"><input style="width: 100%" type="text" id="school" name="school"/></td>
|
||||||
@ -93,9 +93,9 @@ if (isset($error_message) && $error_message === FALSE) {
|
|||||||
<tr>
|
<tr>
|
||||||
<td><label for="class">Classe :</label></td>
|
<td><label for="class">Classe :</label></td>
|
||||||
<td><select style="width: 100%" id="class" name="class">
|
<td><select style="width: 100%" id="class" name="class">
|
||||||
<option value="terminale" <?php if ($user_data["class"] == "terminale") echo "selected" ?>>Terminale</option>
|
<option value="terminale" <?php if ($user->getClass() == "TERMINALE") echo "selected" ?>>Terminale</option>
|
||||||
<option value="premiere" <?php if ($user_data["class"] == "premiere") echo "selected" ?>>Première</option>
|
<option value="premiere" <?php if ($user->getClass() == "PREMIERE") echo "selected" ?>>Première</option>
|
||||||
<option value="seconde" <?php if ($user_data["class"] == "seconde") echo "selected" ?>>Seconde ou inférieur</option>
|
<option value="seconde" <?php if ($user->getClass() == "SECONDE") echo "selected" ?>>Seconde ou inférieur</option>
|
||||||
</select></td>
|
</select></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -103,7 +103,7 @@ if (isset($error_message) && $error_message === FALSE) {
|
|||||||
<label for="responsible_name">Nom du responsable légal :</label>
|
<label for="responsible_name">Nom du responsable légal :</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php echo $user_data["responsible_name"] ?>
|
<?= $user->getResponsibleName() ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -116,7 +116,7 @@ if (isset($error_message) && $error_message === FALSE) {
|
|||||||
<label for="responsible_phone">Téléphone du responsable légal :</label>
|
<label for="responsible_phone">Téléphone du responsable légal :</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php echo $user_data["responsible_phone"] ?>
|
<?= $user->getResponsiblePhone() ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -129,7 +129,7 @@ if (isset($error_message) && $error_message === FALSE) {
|
|||||||
<label for="responsible_email">Email du responsable légal :</label>
|
<label for="responsible_email">Email du responsable légal :</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php echo $user_data["responsible_email"] ?>
|
<?= $user->getResponsibleEmail() ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -140,7 +140,7 @@ if (isset($error_message) && $error_message === FALSE) {
|
|||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="description">Description :</label></td>
|
<td><label for="description">Description :</label></td>
|
||||||
<td><textarea style="width: 100%" id="description" name="description"><?php echo $user_data["description"] ?></textarea></td>
|
<td><textarea style="width: 100%" id="description" name="description"><?= $user->getDescription() ?></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -8,26 +8,28 @@
|
|||||||
|
|
||||||
<h2>Informations sur l'équipe</h2>
|
<h2>Informations sur l'équipe</h2>
|
||||||
|
|
||||||
Nom de l'équipe : <?= $team_data["name"] ?><br/>
|
Nom de l'équipe : <?= $team->getName() ?><br/>
|
||||||
Trigramme : <?= $team_data["trigram"] ?><br/>
|
Trigramme : <?= $team->getTrigram() ?><br/>
|
||||||
Tournoi : <a href="<?= $tournament_data["name"] ?>"><?= $tournament_data["name"] ?></a><br/>
|
Tournoi : <a href="<?= $tournament->getName() ?>"><?= $tournament->getName() ?></a><br/>
|
||||||
<?php
|
<?php
|
||||||
for ($i = 1; $i <= 2; ++$i) {
|
for ($i = 1; $i <= 2; ++$i) {
|
||||||
if ($team_data["encadrant_" . $i] == NULL)
|
if ($team->getEncadrants()[$i] == NULL)
|
||||||
continue;
|
continue;
|
||||||
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["encadrant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
$encadrant = User::fromId($team->getEncadrants()[$i - 1]);
|
||||||
echo "Encadrant $i : " . $user_data["first_name"] . " " . $user_data["surname"] . "<br />";
|
$id = $encadrant->getId();
|
||||||
|
echo "Encadrant $i : <a href=\"$URL_BASE/informations/$id/" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "\">" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "</a><br />";
|
||||||
}
|
}
|
||||||
for ($i = 1; $i <= 6; ++$i) {
|
for ($i = 1; $i <= 6; ++$i) {
|
||||||
if ($team_data["participant_" . $i] == NULL)
|
if ($team->getParticipants()[$i - 1] == NULL)
|
||||||
continue;
|
continue;
|
||||||
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["participant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
$participant = User::fromId($team->getParticipants()[$i - 1]);
|
||||||
echo "Participant $i : " . $user_data["first_name"] . " " . $user_data["surname"] . "<br />";
|
$id = $participant->getId();
|
||||||
|
echo "Participant $i : <a href=\"$URL_BASE/informations/$id/" . $participant->getFirstName() . " " . $participant->getSurname() . "\">" . $participant->getFirstName() . " " . $participant->getSurname() . "</a><br />";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
Code d'accès : <strong><?php echo $team_data["access_code"] ?></strong><br/>
|
Code d'accès : <strong><?= $team->getAccessCode() ?></strong><br/>
|
||||||
<?php if (isset($_SESSION["final_id"])) {
|
<?php if ($team->isSelectedForFinal()) {
|
||||||
$final_name = $_SESSION["final_name"];
|
$final_name = $_SESSION["final"]->getName();
|
||||||
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong><br />";
|
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong><br />";
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ Code d'accès : <strong><?php echo $team_data["access_code"] ?></strong><br/>
|
|||||||
<label for="name">Nom :</label>
|
<label for="name">Nom :</label>
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 70%;">
|
<td style="width: 70%;">
|
||||||
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $team_data["name"] ?>"/>
|
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $team->getName() ?>"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -51,7 +53,7 @@ Code d'accès : <strong><?php echo $team_data["access_code"] ?></strong><br/>
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input style="width: 100%;" type="text" id="trigram" name="trigram"
|
<input style="width: 100%;" type="text" id="trigram" name="trigram"
|
||||||
value="<?= $team_data["trigram"] ?>"/>
|
value="<?= $team->getTrigram() ?>"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -79,7 +81,7 @@ Code d'accès : <strong><?php echo $team_data["access_code"] ?></strong><br/>
|
|||||||
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<?php if ($_SESSION["team_validation_status"] == "NOT_READY") { ?>
|
<?php if ($_SESSION["team_validation_status"] == ValidationStatus::NOT_READY) { ?>
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<a href="<?= $URL_BASE ?>/mon_equipe/modifier">Modifier mon équipe</a>
|
<a href="<?= $URL_BASE ?>/mon_equipe/modifier">Modifier mon équipe</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -103,7 +105,7 @@ Code d'accès : <strong><?php echo $team_data["access_code"] ?></strong><br/>
|
|||||||
}
|
}
|
||||||
echo "$name : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
echo "$name : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
}
|
}
|
||||||
if ($team_data["validation_status"] == "NOT_READY") { ?>
|
if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
|
||||||
<form method="post" enctype="multipart/form-data">
|
<form method="post" enctype="multipart/form-data">
|
||||||
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
|
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
|
||||||
<table style="width: 100%;">
|
<table style="width: 100%;">
|
||||||
@ -114,7 +116,7 @@ Code d'accès : <strong><?php echo $team_data["access_code"] ?></strong><br/>
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select style="width: 100%;" id="type" name="type">
|
<select style="width: 100%;" id="type" name="type">
|
||||||
<?php if ($_SESSION["birth_date"] > strval($YEAR - 18) . substr($tournament_data["date_start"], 4)) { ?>
|
<?php if ($_SESSION["user"]->getBirthDate() > strval($YEAR - 18) . substr($tournament_data["date_start"], 4)) { ?>
|
||||||
<option value="parental_consent">Autorisation parentale</option>
|
<option value="parental_consent">Autorisation parentale</option>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<option value="photo_consent">Autorisation de droit à l'image</option>
|
<option value="photo_consent">Autorisation de droit à l'image</option>
|
||||||
@ -140,7 +142,7 @@ Code d'accès : <strong><?php echo $team_data["access_code"] ?></strong><br/>
|
|||||||
</form>
|
</form>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<hr/>
|
<hr/>
|
||||||
<?php if ($team_data["validation_status"] == "NOT_READY") { ?>
|
<?php if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
|
||||||
<table style="width: 100%;">
|
<table style="width: 100%;">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 50%;">
|
<td style="width: 50%;">
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
<?php
|
<?php if (isset($error_message) && $error_message === false) { ?>
|
||||||
if (!isset($_SESSION["role"]) or ($_SESSION["role"] != "PARTICIPANT" && $_SESSION["role"] != "ENCADRANT")) {
|
Vous avez bien rejoint l'équipe <?= $_SESSION["team"]->getName() ?> !
|
||||||
?>
|
|
||||||
<h2>Vous devez être participant ou encadrant pour pouvoir rejoindre une équipe.</h2>
|
|
||||||
<?php } else if (isset($access_code)) { ?>
|
|
||||||
Vous avez bien rejoint l'équipe <?php echo $data["name"] ?> !
|
|
||||||
<?php } else if ($_SESSION["team_id"] != NULL) { ?>
|
|
||||||
<h2>Vous êtes déjà dans une équipe.</h2>
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||||
|
@ -1,33 +1,36 @@
|
|||||||
<h2>Tournoi de <?php echo $data["name"] ?></h2>
|
<h2>Tournoi de <?= $tournament->getName() ?></h2>
|
||||||
|
|
||||||
<strong>Organisateur<?= sizeof($orgas) >= 2 ? 's' : '' ?> :</strong>
|
<strong>Organisateur<?= sizeof($orgas) >= 2 ? 's' : '' ?> :</strong>
|
||||||
<?php
|
<?php
|
||||||
$s = "";
|
$s = "";
|
||||||
for ($i = 0; $i < sizeof($orgas); ++$i) {
|
/** @var User $orga */
|
||||||
if ($_SESSION["role"] == "ORGANIZER" || $_SESSION["role"] == "ADMIN")
|
foreach ($orgas as $orga) {
|
||||||
$s .= "<a href=\"$URL_BASE/informations/$orgas_id[$i]/$orgas[$i]\">$orgas[$i]</a>";
|
$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
|
else
|
||||||
$s .= $orgas[$i];
|
$s .= $orga_name;
|
||||||
$s .= ", ";
|
$s .= ", ";
|
||||||
}
|
}
|
||||||
echo substr($s, 0, -2);
|
echo substr($s, 0, -2);
|
||||||
?>
|
?>
|
||||||
<br />
|
<br />
|
||||||
<strong>Nombre d'équipes maximal :</strong> <?php echo $data["size"] ?><br />
|
<strong>Nombre d'équipes maximal :</strong> <?= $tournament->getSize() ?><br />
|
||||||
<strong>Lieu :</strong> <?php echo $data["place"] ?><br />
|
<strong>Lieu :</strong> <?= $tournament->getPlace() ?><br />
|
||||||
<strong>Prix par partipant :</strong> <?php echo $data["price"] == 0 ? "Gratuit" : $data["price"] . " €" ?><br />
|
<strong>Prix par partipant :</strong> <?= $tournament->getPrice() == 0 ? "Gratuit" : $tournament->getPrice() . " €" ?><br />
|
||||||
<strong>Dates :</strong> Du <?php echo echoDate($data["date_start"]) ?> au <?php echo echoDate($data["date_end"]) ?><br />
|
<strong>Dates :</strong> Du <?= echoDate($tournament->getStartDate()) ?> au <?= echoDate($tournament->getEndDate()) ?><br />
|
||||||
<strong>Clôture des inscriptions :</strong> <?php echo echoDate($data["date_inscription"], true) ?><br />
|
<strong>Clôture des inscriptions :</strong> <?= echoDate($tournament->getInscriptionDate(), true) ?><br />
|
||||||
<strong>Date limite d'envoi des solutions :</strong> <?php echo echoDate($data["date_solutions"], true) ?><br />
|
<strong>Date limite d'envoi des solutions :</strong> <?= echoDate($tournament->getSolutionsDate(), true) ?><br />
|
||||||
<strong>Date limite d'envoi des notes de synthèse :</strong> <?php echo echoDate($data["date_syntheses"], true) ?><br />
|
<strong>Date limite d'envoi des notes de synthèse :</strong> <?= echoDate($tournament->getSynthesesDate(), true) ?><br />
|
||||||
<strong>Description :</strong> <?php echo $data["description"] ?><br />
|
<strong>Description :</strong> <?= $tournament->getDescription() ?><br />
|
||||||
<?php
|
<?php
|
||||||
if ($data["final"])
|
if ($tournament->isFinal())
|
||||||
echo "<strong>Ce tournoi est la finale nationale du TFJM² 2020.</strong><br />";
|
echo "<strong>Ce tournoi est la finale nationale du TFJM² 2020.</strong><br />";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER" && in_array($_SESSION["user_id"], $orgas_id))) { ?>
|
<?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER && in_array($_SESSION["user_id"], $orgas_id))) { ?>
|
||||||
<a href="<?= $URL_BASE ?>/tournoi/<?= $data["name"] ?>/modifier">Éditer le tournoi</a>
|
<a href="<?= $URL_BASE ?>/tournoi/<?= $tournament->getName() ?>/modifier">Éditer le tournoi</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
@ -55,29 +58,30 @@ if ($data["final"])
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
|
/** @noinspection PhpUndefinedVariableInspection */
|
||||||
while (($team_data = $teams_response->fetch()) != false) {
|
while (($team_data = $teams_response->fetch()) != false) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="border: 1px solid black; text-align: center">
|
<td style="border: 1px solid black; text-align: center">
|
||||||
<?php
|
<?php
|
||||||
if (isset($_SESSION["role"]) && ($_SESSION["role"] == "ADMIN" || ($_SESSION["role"] == "ORGANIZER" && in_array($_SESSION["user_id"], $orgas_id))))
|
if (isset($_SESSION["role"]) && ($_SESSION["role"] == Role::ADMIN || ($_SESSION["role"] == Role::ORGANIZER && in_array($_SESSION["user_id"], $orgas_id))))
|
||||||
echo "<a href=\"$URL_BASE/equipe/" . $team_data["trigram"] . "\">" . $team_data["name"] . "</a>";
|
echo "<a href=\"$URL_BASE/equipe/" . $team_data["trigram"] . "\">" . $team_data["name"] . "</a>";
|
||||||
else
|
else
|
||||||
echo $team_data["name"];
|
echo $team_data["name"];
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
<td style="border: 1px solid black; text-align: center"><?php echo $team_data["trigram"] ?></td>
|
<td style="border: 1px solid black; text-align: center"><?= $team_data["trigram"] ?></td>
|
||||||
<td style="border: 1px solid black; text-align: center"><?php echo echoDate($team_data["inscription_date"]) ?></td>
|
<td style="border: 1px solid black; text-align: center"><?= echoDate($team_data["inscription_date"]) ?></td>
|
||||||
<td style="border: 1px solid black; text-align: center">
|
<td style="border: 1px solid black; text-align: center">
|
||||||
<?php
|
<?php
|
||||||
switch ($team_data["validation_status"]) {
|
switch (ValidationStatus::fromName($team_data["validation_status"])) {
|
||||||
case "NOT_READY":
|
case ValidationStatus::NOT_READY:
|
||||||
echo "Inscription non terminée";
|
echo "Inscription non terminée";
|
||||||
break;
|
break;
|
||||||
case "WAITING":
|
case ValidationStatus::WAITING:
|
||||||
echo "En attente de validation";
|
echo "En attente de validation";
|
||||||
break;
|
break;
|
||||||
case "VALIDATED":
|
case ValidationStatus::VALIDATED:
|
||||||
echo "Inscription validée";
|
echo "Inscription validée";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -122,10 +126,10 @@ else {
|
|||||||
<label for="name">Nom :</label>
|
<label for="name">Nom :</label>
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 70%;">
|
<td style="width: 70%;">
|
||||||
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $data["name"] ?>" required />
|
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $tournament->getName() ?>" required />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ($_SESSION["role"] == "ADMIN") { ?>
|
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="organizer">Organisateur :</label>
|
<label for="organizer">Organisateur :</label>
|
||||||
@ -134,7 +138,7 @@ else {
|
|||||||
<select style="width: 100%;" id="organizer" name="organizer[]" multiple size="4" required>
|
<select style="width: 100%;" id="organizer" name="organizer[]" multiple size="4" required>
|
||||||
<?php
|
<?php
|
||||||
while (($orga_data = $orgas_response->fetch()) !== FALSE) {
|
while (($orga_data = $orgas_response->fetch()) !== FALSE) {
|
||||||
echo "<option value=\"" . $orga_data["id"] . "\" " . (in_array($orga_data["first_name"] . " " . $orga_data["surname"], $orgas) ? "selected" : "")
|
echo "<option value=\"" . $orga_data["id"] . "\" " . (in_array($orga_data["id"], $orgas_id) ? "selected" : "")
|
||||||
. ">" . $orga_data["first_name"] . " " . $orga_data["surname"] . "</option>\n";
|
. ">" . $orga_data["first_name"] . " " . $orga_data["surname"] . "</option>\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -147,7 +151,7 @@ else {
|
|||||||
<label for="size">Nombre d'équipes :</label>
|
<label for="size">Nombre d'équipes :</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="<?= $data["size"] ?>" required />
|
<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="<?= $tournament->getSize() ?>" required />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -155,7 +159,7 @@ else {
|
|||||||
<label for="place">Lieu :</label>
|
<label for="place">Lieu :</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input style="width: 100%;" type="text" id="place" name="place" value="<?= $data["place"] ?>" required />
|
<input style="width: 100%;" type="text" id="place" name="place" value="<?= $tournament->getPlace() ?>" required />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -163,7 +167,7 @@ else {
|
|||||||
<label for="price">Prix par participant</label>
|
<label for="price">Prix par participant</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input style="width: 100%;" type="number" id="price" name="price" min="0" max="21" value="<?= $data["price"] ?>" required />
|
<input style="width: 100%;" type="number" id="price" name="price" min="0" max="21" value="<?= $tournament->getPrice() ?>" required />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -171,8 +175,8 @@ else {
|
|||||||
<label for="date_start">Dates :</label>
|
<label for="date_start">Dates :</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Du <input style="width: 45%;" type="date" id="date_start" name="date_start" value="<?= $data["date_start"] ?>" required />
|
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="<?= $data["date_end"] ?>" required />
|
au <input style="width: 45%;" type="date" id="date_end" name="date_end" value="<?= $tournament->getEndDate() ?>" required />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -180,8 +184,8 @@ else {
|
|||||||
<label for="date_inscription">Date limite d'inscription :</label>
|
<label for="date_inscription">Date limite d'inscription :</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" value="<?= substr($data["date_inscription"], 0, 10) ?>" required />
|
<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($data["date_inscription"], 11) ?>" required />
|
<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" value="<?= substr($tournament->getInscriptionDate(), 11) ?>" required />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -189,8 +193,8 @@ else {
|
|||||||
<label for="date_solutions">Date limite pour rendre les solutions :</label>
|
<label for="date_solutions">Date limite pour rendre les solutions :</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input style="width: 49%;" type="date" id="date_solutions" name="date_solutions" value="<?= substr($data["date_solutions"], 0, 10) ?>" required />
|
<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($data["date_solutions"],11) ?>" required />
|
<input style="width: 49%;" type="time" id="time_solutions" name="time_solutions" value="<?= substr($tournament->getSolutionsDate(),11) ?>" required />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -198,8 +202,8 @@ else {
|
|||||||
<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
|
<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input style="width: 100%;" type="date" id="date_syntheses" name="date_syntheses" value="<?= substr($data["date_syntheses"], 0, 10) ?>" required />
|
<input style="width: 100%;" type="date" id="date_syntheses" name="date_syntheses" value="<?= substr($tournament->getSynthesesDate(), 0, 10) ?>" required />
|
||||||
<input style="width: 100%;" type="time" id="time_syntheses" name="time_syntheses" value="<?= substr($data["date_syntheses"], 11) ?>" required />
|
<input style="width: 100%;" type="time" id="time_syntheses" name="time_syntheses" value="<?= substr($tournament->getSynthesesDate(), 11) ?>" required />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -207,7 +211,7 @@ else {
|
|||||||
<label for="description">Description :</label>
|
<label for="description">Description :</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea style="width: 100%;" name="description" id="description" required><?= $data["description"] ?></textarea>
|
<textarea style="width: 100%;" name="description" id="description" required><?= $tournament->getDescription() ?></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user