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:
@ -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()]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user