diff --git a/server_files/config.php b/server_files/config.php index 991967f..00b9ff3 100644 --- a/server_files/config.php +++ b/server_files/config.php @@ -17,6 +17,7 @@ $DB_NAME = getenv("TFJM_DB_NAME"); $DB_USER = getenv("TFJM_DB_USER"); $DB_PASSWORD = getenv("TFJM_DB_PASSWORD"); + try { $DB = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME;charset=utf8", "$DB_USER", "$DB_PASSWORD", array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } diff --git a/server_files/controllers/tournoi.php b/server_files/controllers/tournoi.php index 5d7d2f8..3b5b451 100644 --- a/server_files/controllers/tournoi.php +++ b/server_files/controllers/tournoi.php @@ -122,4 +122,28 @@ class UpdateTournament } } +if ($_SESSION["role"] == Role::ENCADRANT || $_SESSION["role"] == Role::ADMIN) { + $emails = []; + foreach ($tournament->getOrganizers() as $organizer) + $emails[] = $organizer->getEmail(); + + foreach ($teams as $team) { + foreach ($team->getEncadrants() as $encadrant_id) { + $encadrant = User::fromId($encadrant_id); + if ($encadrant != null) + $emails[] = $encadrant->getEmail(); + } + + foreach ($team->getParticipants() as $participant_id) { + $participant = User::fromId($participant_id); + if ($participant != null) { + $emails[] = $participant->getEmail(); + if ($participant->getResponsibleEmail() != null) { + $emails[] = $participant->getResponsibleEmail(); + } + } + } + } +} + require_once "server_files/views/tournoi.php"; diff --git a/server_files/controllers/tournois.php b/server_files/controllers/tournois.php index db4c402..cf9ebce 100644 --- a/server_files/controllers/tournois.php +++ b/server_files/controllers/tournois.php @@ -2,4 +2,31 @@ $tournaments = Tournament::getAllTournaments(); +$emails = []; + +if ($_SESSION["role"] == Role::ENCADRANT || $_SESSION["role"] == Role::ADMIN) { + foreach ($tournaments as $tournament) { + foreach ($tournament->getOrganizers() as $organizer) + $emails[] = $organizer->getEmail(); + + foreach ($tournament->getAllTeams() as $team) { + foreach ($team->getEncadrants() as $encadrant_id) { + $encadrant = User::fromId($encadrant_id); + if ($encadrant != null) + $emails[] = $encadrant->getEmail(); + } + + foreach ($team->getParticipants() as $participant_id) { + $participant = User::fromId($participant_id); + if ($participant != null) { + $emails[] = $participant->getEmail(); + if ($participant->getResponsibleEmail() != null) { + $emails[] = $participant->getResponsibleEmail(); + } + } + } + } + } +} + require_once "server_files/views/tournois.php"; diff --git a/server_files/views/tournoi.php b/server_files/views/tournoi.php index 3995ee4..2d57350 100644 --- a/server_files/views/tournoi.php +++ b/server_files/views/tournoi.php @@ -59,6 +59,10 @@ if ($tournament->isFinal()) ?> organize($_SESSION["user_id"]))) { ?> +
+ diff --git a/server_files/views/tournois.php b/server_files/views/tournois.php index 2c0ae8d..a90ecb9 100644 --- a/server_files/views/tournois.php +++ b/server_files/views/tournois.php @@ -4,6 +4,12 @@