diff --git a/server_files/classes/User.php b/server_files/classes/User.php index 2aa8382..b81bd99 100644 --- a/server_files/classes/User.php +++ b/server_files/classes/User.php @@ -323,7 +323,7 @@ class User public function getTeams() { global $DB; - $req = $DB->query("SELECT `id` FROM `teams` WHERE `encadrant` = $this->id;"); + $req = $DB->query("SELECT `id` FROM `teams` WHERE `encadrant` = $this->id OR `participant_1` = $this->id OR `participant_2` = $this->id OR `participant_3` = $this->id OR `participant_4` = $this->id OR `participant_5` = $this->id;"); $teams = []; diff --git a/server_files/controllers/commenter_echange.php b/server_files/controllers/commenter_echange.php index bfa4c6a..b1f3e92 100644 --- a/server_files/controllers/commenter_echange.php +++ b/server_files/controllers/commenter_echange.php @@ -13,7 +13,7 @@ $team = $user->getRole() == Role::PARTICIPANT ? $_SESSION["team"] : Team::fromTr if ($team == null) require_once "server_files/404.php"; -if ($team->getEncadrantId() != $user->getId() || $team->getValidationStatus() != ValidationStatus::VALIDATED) +if ($user->getRole() == Role::ENCADRANT && $team->getEncadrantId() != $user->getId() || $team->getValidationStatus() != ValidationStatus::VALIDATED) require_once "server_files/403.php"; if (isset($_POST["upload_answer"])) { diff --git a/server_files/controllers/envoyer_video.php b/server_files/controllers/envoyer_video.php index 1de3c6b..e20c006 100644 --- a/server_files/controllers/envoyer_video.php +++ b/server_files/controllers/envoyer_video.php @@ -13,7 +13,7 @@ $user = $_SESSION["user"]; if ($team == null) require_once "server_files/404.php"; -if ($team->getEncadrantId() != $user->getId() || $team->getValidationStatus() != ValidationStatus::VALIDATED) +if ($user->getRole() == Role::ENCADRANT && $team->getEncadrantId() != $user->getId() || $team->getValidationStatus() != ValidationStatus::VALIDATED) require_once "server_files/403.php"; $has_error = false; diff --git a/server_files/controllers/informations.php b/server_files/controllers/informations.php index 149cb59..370cfcf 100644 --- a/server_files/controllers/informations.php +++ b/server_files/controllers/informations.php @@ -15,6 +15,8 @@ if ($user === null) require_once "server_files/404.php"; $teams = $user->getTeams(); +if ($user->getRole() == Role::PARTICIPANT) + $team = sizeof($teams) == 0 ? null : $teams[0]; $has_error = false; $error_message = null; diff --git a/server_files/controllers/ma_participation.php b/server_files/controllers/ma_participation.php index a83ed0a..6452ed1 100644 --- a/server_files/controllers/ma_participation.php +++ b/server_files/controllers/ma_participation.php @@ -11,7 +11,7 @@ if (isset($_SESSION["user_id"]) && isset($_SESSION["teams"]) && sizeof($_SESSION if ($team == null) require_once "server_files/404.php"; - if ($team->getEncadrantId() != $user->getId()) + if ($user->getRole() == Role::ENCADRANT && $team->getEncadrantId() != $user->getId()) require_once "server_files/403.php"; $video = Video::getVideo(Reason::SOLUTION, $team); diff --git a/server_files/controllers/mon_equipe.php b/server_files/controllers/mon_equipe.php index 34182dd..21f1ad0 100644 --- a/server_files/controllers/mon_equipe.php +++ b/server_files/controllers/mon_equipe.php @@ -49,7 +49,7 @@ if (isset($_SESSION["user_id"]) && isset($_SESSION["teams"]) && sizeof($_SESSION if ($team == null) require_once "server_files/404.php"; - if ($team->getEncadrantId() != $user->getId()) + if ($user->getRole() == Role::ENCADRANT && $team->getEncadrantId() != $user->getId()) require_once "server_files/403.php"; $documents = $team->getAllDocuments(); diff --git a/server_files/controllers/poser_questions.php b/server_files/controllers/poser_questions.php index 913aefa..7aa3ee8 100644 --- a/server_files/controllers/poser_questions.php +++ b/server_files/controllers/poser_questions.php @@ -13,7 +13,7 @@ $team = $user->getRole() == Role::PARTICIPANT ? $_SESSION["team"] : Team::fromTr if ($team == null) require_once "server_files/404.php"; -if ($team->getEncadrantId() != $user->getId()) +if ($user->getRole() == Role::ENCADRANT && $team->getEncadrantId() != $user->getId() || $team->getValidationStatus() != ValidationStatus::VALIDATED) require_once "server_files/403.php"; $has_error = false; diff --git a/server_files/controllers/repondre_questions.php b/server_files/controllers/repondre_questions.php index dbfbc04..924171b 100644 --- a/server_files/controllers/repondre_questions.php +++ b/server_files/controllers/repondre_questions.php @@ -12,7 +12,7 @@ $team = $user->getRole() == Role::PARTICIPANT ? $_SESSION["team"] : Team::fromTr if ($team == null) require_once "server_files/404.php"; -if ($team->getEncadrantId() != $user->getId() || $team->getValidationStatus() != ValidationStatus::VALIDATED) +if ($user->getRole() == Role::ENCADRANT && $team->getEncadrantId() != $user->getId() || $team->getValidationStatus() != ValidationStatus::VALIDATED) require_once "server_files/403.php"; $has_error = false;