1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-25 20:57:25 +02:00

Amélioration des fichiers d'ajout de tournoi

This commit is contained in:
galaxyoyo
2019-09-07 18:08:40 +02:00
parent 0f0c082437
commit 8606ae7b95
8 changed files with 129 additions and 93 deletions

View File

@ -30,7 +30,7 @@ else
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
function updateTournament() {
global $DB, $URL_BASE, $YEAR, $tournament;
global $DB, $URL_BASE, $YEAR, $tournament, $orgas;
$name = htmlspecialchars($_POST["name"]);
@ -43,7 +43,7 @@ function updateTournament() {
if ($_SESSION["role"] == Role::ADMIN) {
$organizers = $_POST["organizer"];
$orga_mails = [];
$orgas = [];
foreach ($organizers as $orga_id) {
$orga = User::fromId($orga_id);
@ -51,7 +51,7 @@ function updateTournament() {
return "L'organisateur spécifié n'existe pas.";
if ($orga->getRole() != Role::ORGANIZER && $orga->getRole() != Role::ADMIN)
return "L'organisateur indiqué ne peut pas organiser de tournoi.";
$orga_mails[] = $orga->getEmail();
$orgas[] = $orga;
}
}
@ -111,7 +111,7 @@ function updateTournament() {
if ($_SESSION["role"] == Role::ADMIN) {
$DB->exec("DELETE FROM `organizers` WHERE `tournament` = " . $tournament->getId() . ";");
foreach ($organizers as $orga) {
foreach ($orgas as $orga) {
$req = $DB->prepare("INSERT INTO `organizers`(`organizer`, `tournament`) VALUES(?, ?);");
$req->execute([$orga->getId(), $tournament->getId()]);
}