Corrections mineures
This commit is contained in:
parent
66421eefb3
commit
9de0491755
|
@ -73,7 +73,7 @@ class Team
|
|||
public static function getAllTeams($problem)
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
$req = $DB->prepare("SELECT * FROM `teams` WHERE " . ($problem <= 0 ? "" : "`problem` = ? AND ") . "`year` = $YEAR;");
|
||||
$req = $DB->prepare("SELECT * FROM `teams` WHERE " . ($problem < 0 ? "" : "`problem` = ? AND ") . "`year` = $YEAR;");
|
||||
$req->execute([htmlspecialchars($problem)]);
|
||||
|
||||
$teams = [];
|
||||
|
|
|
@ -43,18 +43,22 @@ if (isset($_POST["attribute_team"])) {
|
|||
|
||||
class AttributeTeam
|
||||
{
|
||||
private $team_id;
|
||||
private $team;
|
||||
private $min_null_index;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->team = Team::fromId($data["team"]);
|
||||
$this->team_id = $data["team"];
|
||||
$this->team = Team::fromId($this->team_id);
|
||||
}
|
||||
|
||||
public function makeVerifications()
|
||||
{
|
||||
global $user;
|
||||
|
||||
ensure($user->getConfirmEmailToken() == null, "Ce participant n'a pas encore validé son adresse e-mail.");
|
||||
ensure($this->team_id != "no_team", "Vous n'avez pas choisi d'équipe.");
|
||||
ensure($this->team != null, "Cette équipe n'existe pas.");
|
||||
ensure($this->team->getValidationStatus() == ValidationStatus::NOT_READY, "Cette équipe est déjà validée ou en cours de validation.");
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ if (!isset($_SESSION["user_id"]))
|
|||
|
||||
/** @var User $user */
|
||||
$user = $_SESSION["user"];
|
||||
$documents = $user->getAllDocuments();
|
||||
|
||||
$has_error = false;
|
||||
$error_message = null;
|
||||
|
@ -172,4 +171,6 @@ class SendDocument
|
|||
}
|
||||
}
|
||||
|
||||
$documents = $user->getAllDocuments();
|
||||
|
||||
require_once "server_files/views/mon_compte.php";
|
||||
|
|
|
@ -38,14 +38,14 @@ class JoinTeam
|
|||
ensure($this->team != null, "Ce code d'accès est invalide.");
|
||||
ensure($this->team->getValidationStatus() == ValidationStatus::NOT_READY, "Cette équipe est déjà validée ou en cours de validation, vous ne pouvez pas la rejoindre.");
|
||||
|
||||
for ($i = 1; $i <= $_SESSION["role"] == Role::PARTICIPANT ? 5 : 1; ++$i) {
|
||||
for ($i = 1; $i <= ($_SESSION["role"] == Role::PARTICIPANT ? 5 : 1); ++$i) {
|
||||
if (($_SESSION["role"] == Role::PARTICIPANT ? $this->team->getParticipants()[$i - 1] : $this->team->getEncadrantId()) == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
$this->min_null_index = $i;
|
||||
|
||||
ensure($_SESSION["role"] == Role::PARTICIPANT && $this->min_null_index <= 5 || $_SESSION["role"] == Role::ENCADRANT && $this->min_null_index <= 2, "Il n'y a plus de place pour vous dans l'équipe.");
|
||||
ensure($_SESSION["role"] == Role::PARTICIPANT && $this->min_null_index <= 5 || $_SESSION["role"] == Role::ENCADRANT && $this->min_null_index <= 1, "Il n'y a plus de place pour vous dans l'équipe.");
|
||||
}
|
||||
|
||||
public function joinTeam()
|
||||
|
|
|
@ -33,13 +33,15 @@ if (!$has_error) {
|
|||
<div class="form-group col-md-12">
|
||||
<label for="team">Attribuer une équipe :</label>
|
||||
<select class="custom-select" id="team" name="team">
|
||||
<option value="no_team">Choisir une équipe ...</option>
|
||||
<?php
|
||||
/** @var Team $t */
|
||||
foreach (Team::getAllTeams(-1) as $t) {
|
||||
if ($t->getValidationStatus() != ValidationStatus::NOT_READY)
|
||||
continue;
|
||||
|
||||
$team_name = $t->getName() . " (" . $t->getTrigram() . "), problème " . $t->getProblem();
|
||||
$team_name = $t->getName() . " (" . $t->getTrigram() . "), "
|
||||
. ($t->getProblem() == 0 ? "pas de problème choisi" :"problème " . $t->getProblem());
|
||||
$team_id = $t->getId();
|
||||
echo "<option value=\"$team_id\">$team_name</option>\n";
|
||||
}
|
||||
|
@ -78,6 +80,7 @@ if (!$has_error) {
|
|||
|
||||
<div class="alert alert-info">
|
||||
<strong>Adresse e-mail :</strong> <a href="mailto:<?= $user->getEmail() ?>"><?= $user->getEmail() ?></a>
|
||||
<?= $user->getConfirmEmailToken() == null ? "" : "(<em>non validée</em>)" ?>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info">
|
||||
|
|
|
@ -6,6 +6,12 @@ require_once "header.php";
|
|||
<h1 class="display-4">Mon compte</h1>
|
||||
</div>
|
||||
|
||||
<?php if (!$has_error && isset($send_document)) { ?>
|
||||
<div class="alert alert-success">
|
||||
Le fichier a été correctement envoyé !
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if (!$has_error && (isset($my_account) || isset($new_password))) {
|
||||
?>
|
||||
|
|
|
@ -6,12 +6,6 @@ require_once "header.php";
|
|||
<h1 class="display-4">Mon équipe</h1>
|
||||
</div>
|
||||
|
||||
<?php if (!$has_error && isset($send_document)) { ?>
|
||||
<div class="alert alert-success">
|
||||
Le fichier a été correctement envoyé !
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="alert alert-info">
|
||||
<strong>Nom de l'équipe :</strong> <?= $team->getName() ?>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue