Modifications mineures

This commit is contained in:
Yohann D'ANELLO 2020-01-21 12:43:13 +01:00
parent cd70de049a
commit 6fe398d965
10 changed files with 43 additions and 36 deletions

View File

@ -90,7 +90,7 @@ class User
{ {
global $DB, $YEAR; global $DB, $YEAR;
$admins = []; $admins = [];
$req = $DB->query("SELECT * FROM `users` WHERE `role` = 'ORGANIZER' OR `role` = 'ADMIN' AND `year` = $YEAR;"); $req = $DB->query("SELECT * FROM `users` WHERE `role` = 'ORGANIZER' OR `role` = 'ADMIN' AND `year` = $YEAR ORDER BY `role`, `surname`, `first_name`;");
while (($data = $req->fetch()) !== false) { while (($data = $req->fetch()) !== false) {
$admin = new User(); $admin = new User();

View File

@ -3,8 +3,6 @@
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN) if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php"; require_once "server_files/403.php";
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
$has_error = false; $has_error = false;
$error_message = null; $error_message = null;

View File

@ -5,17 +5,20 @@ if (!isset($_SESSION["role"]))
$id = $_GET["id"]; $id = $_GET["id"];
$user = User::fromId($id); $user = User::fromId($id);
$team = Team::fromId($user->getTeamId());
if ($_SESSION["role"] != Role::ADMIN) { if ($_SESSION["role"] != Role::ADMIN) {
if ($user->getId() != $_SESSION["user_id"]) if ($_SESSION["role"] == Role::ORGANIZER) {
if (($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::PARTICIPANT) && ($team == null || $team->getTournamentId() == null || !Tournament::fromId($team->getTournamentId())->organize($_SESSION["user_id"])))
require_once "server_files/403.php";
}
elseif ($user->getId() != $_SESSION["user_id"])
require_once "server_files/403.php"; require_once "server_files/403.php";
} }
if ($user === null) if ($user === null)
require_once "server_files/404.php"; require_once "server_files/404.php";
$team = Team::fromId($user->getTeamId());
if ($team != null) { if ($team != null) {
$documents = $user->getAllDocuments($team->getTournamentId()); $documents = $user->getAllDocuments($team->getTournamentId());
$payment = $user->getPayment(); $payment = $user->getPayment();

View File

@ -1,6 +1,6 @@
<?php <?php
if ($_SESSION["role"] != Role::ADMIN) if ($_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
require_once "server_files/403.php"; require_once "server_files/403.php";
$organizers = User::getOrganizers(); $organizers = User::getOrganizers();

View File

@ -25,7 +25,6 @@ if (isset($_POST["edit_tournament"])) {
$orgas = $tournament->getOrganizers(); $orgas = $tournament->getOrganizers();
$teams = $tournament->getAllTeams(); $teams = $tournament->getAllTeams();
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
class UpdateTournament class UpdateTournament
{ {
@ -106,6 +105,7 @@ class UpdateTournament
$tournament->setInscriptionDate("$this->date_inscription $this->time_inscription"); $tournament->setInscriptionDate("$this->date_inscription $this->time_inscription");
$tournament->setSolutionsDate("$this->date_solutions $this->time_solutions"); $tournament->setSolutionsDate("$this->date_solutions $this->time_solutions");
$tournament->setSynthesesDate("$this->date_syntheses $this->time_syntheses"); $tournament->setSynthesesDate("$this->date_syntheses $this->time_syntheses");
$tournament->setDescription($this->description);
foreach ($this->organizers as $organizer) { foreach ($this->organizers as $organizer) {
if (!$tournament->organize($organizer->getId())) if (!$tournament->organize($organizer->getId()))

View File

@ -18,7 +18,7 @@ if (isset($tournament) && !$has_error) { ?>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="name">Nom du tournoi :</label> <label for="name">Nom du tournoi :</label>
<input class="form-control" type="text" id="name" name="name" pattern="[A-Za-zÀ-ÿ ]+" <input class="form-control" type="text" id="name" name="name" pattern="[A-Za-zÀ-ÿ\- ]+"
value="<?php if (isset($tournament)) echo $tournament->name ?>" required/> value="<?php if (isset($tournament)) echo $tournament->name ?>" required/>
</div> </div>
@ -34,8 +34,8 @@ if (isset($tournament) && !$has_error) { ?>
<label for="organizers">Organisateurs :</label> <label for="organizers">Organisateurs :</label>
<select style="width: 100%;" id="organizers" name="organizers[]" multiple size="4" class="custom-select" required> <select style="width: 100%;" id="organizers" name="organizers[]" multiple size="4" class="custom-select" required>
<?php <?php
while (($data = $orgas_response->fetch()) !== FALSE) { foreach (User::getOrganizers() as $organizer) {
echo "<option value=\"" . $data["id"] . "\">" . $data["first_name"] . " " . $data["surname"] . "</option>\n"; echo "<option value=\"" . $organizer->getId(). "\">" . $organizer->getFirstName() . " " . $organizer->getSurname() . "</option>\n";
} }
?> ?>
</select> </select>
@ -60,12 +60,12 @@ if (isset($tournament) && !$has_error) { ?>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="date_start">Début du tournoi :</label> <label for="date_start">Début du tournoi :</label>
<input class="form-control" type="date" id="date_start" name="date_start" <input class="form-control" type="date" id="date_start" name="date_start"
value="<?= isset($tournament) ? substr($tournament->getStartDate(), 0, 10) : date('Y-m-d') ?>"/> value="<?= isset($tournament) ? $tournament->date_start : date('Y-m-d') ?>"/>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="date_end">Fin du tournoi :</label> <label for="date_end">Fin du tournoi :</label>
<input class="form-control" type="date" id="date_end" name="date_end" <input class="form-control" type="date" id="date_end" name="date_end"
value="<?= isset($tournament) ? substr($tournament->getEndDate(), 0, 10) : date('Y-m-d') ?>"/> value="<?= isset($tournament) ? $tournament->date_end : date('Y-m-d') ?>"/>
</div> </div>
</div> </div>
@ -73,30 +73,30 @@ if (isset($tournament) && !$has_error) { ?>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="date_inscription">Date limite d'inscription :</label> <label for="date_inscription">Date limite d'inscription :</label>
<input class="form-control" type="date" id="date_inscription" name="date_inscription" <input class="form-control" type="date" id="date_inscription" name="date_inscription"
value="<?= isset($tournament) ? substr($tournament->getInscriptionDate(), 0, 10) : date('Y-m-d') ?>"/> value="<?= isset($tournament) ? $tournament->date_inscription : date('Y-m-d') ?>"/>
<input class="form-control" type="time" id="time_inscription" name="time_inscription" <input class="form-control" type="time" id="time_inscription" name="time_inscription"
value="<?= isset($tournament) ? substr($tournament->getInscriptionDate(), 11, 5) : date('H:i') ?>"/> value="<?= isset($tournament) ? $tournament->time_inscription : date('H:i') ?>"/>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="date_solutions">Date limite de remise des solutions :</label> <label for="date_solutions">Date limite de remise des solutions :</label>
<input class="form-control" type="date" id="date_solutions" name="date_solutions" <input class="form-control" type="date" id="date_solutions" name="date_solutions"
value="<?= isset($tournament) ? substr($tournament->getSolutionsDate(), 0, 10) : date('Y-m-d') ?>"/> value="<?= isset($tournament) ? $tournament->date_solutions : date('Y-m-d') ?>"/>
<input class="form-control" type="time" id="time_solutions" name="time_solutions" <input class="form-control" type="time" id="time_solutions" name="time_solutions"
value="<?= isset($tournament) ? substr($tournament->getSolutionsDate(), 11, 5) : date('H:i') ?>"/> value="<?= isset($tournament) ? $tournament->time_solutions: date('H:i') ?>"/>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="date_syntheses">Date limite de remise des notes de synthèse :</label> <label for="date_syntheses">Date limite de remise des notes de synthèse :</label>
<input class="form-control" type="date" id="date_syntheses" name="date_syntheses" <input class="form-control" type="date" id="date_syntheses" name="date_syntheses"
value="<?= isset($tournament) ? substr($tournament->getSynthesesDate(), 0, 10) : date('Y-m-d') ?>"/> value="<?= isset($tournament) ? $tournament->date_syntheses : date('Y-m-d') ?>"/>
<input class="form-control" type="time" id="time_syntheses" name="time_syntheses" <input class="form-control" type="time" id="time_syntheses" name="time_syntheses"
value="<?= isset($tournament) ? substr($tournament->getSynthesesDate(), 11, 5) : date('H:i') ?>"/> value="<?= isset($tournament) ? $tournament->time_syntheses : date('H:i') ?>"/>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="description">Description :</label> <label for="description">Description :</label>
<textarea class="form-control" id="description" name="description"><?= isset($tournament) ? $tournament->getDescription() : "" ?></textarea> <textarea class="form-control" id="description" name="description"><?= isset($tournament) ? $tournament->description : "" ?></textarea>
</div> </div>
</div> </div>

View File

@ -30,8 +30,10 @@
<a class="nav-link" href="/tournois">Liste des tournois</a> <a class="nav-link" href="/tournois">Liste des tournois</a>
<?php if ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER) { ?> <?php if ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER) { ?>
<ul class="deroule"> <ul class="deroule">
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
<li class="nav-item active"><a class="nav-link" href="/profils-orphelins">Profils orphelins</a></li> <li class="nav-item active"><a class="nav-link" href="/profils-orphelins">Profils orphelins</a></li>
<li class="nav-item active"><a class="nav-link" href="/profils">Tous les profils</a></li> <li class="nav-item active"><a class="nav-link" href="/profils">Tous les profils</a></li>
<?php } ?>
<li class="nav-item active"><a class="nav-link" href="/organisateurs">Organisateurs</a></li> <li class="nav-item active"><a class="nav-link" href="/organisateurs">Organisateurs</a></li>
</ul> </ul>
<?php } ?> <?php } ?>

View File

@ -66,6 +66,9 @@ if (!$has_error) {
</div> </div>
<?php } ?> <?php } ?>
<?php
if ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) {
?>
<div class="alert alert-info"> <div class="alert alert-info">
<strong>Date de naissance :</strong> <?= formatDate($user->getBirthDate()) ?><br /> <strong>Date de naissance :</strong> <?= formatDate($user->getBirthDate()) ?><br />
</div> </div>
@ -77,6 +80,7 @@ if (!$has_error) {
<div class="alert alert-info"> <div class="alert alert-info">
<strong>Adresse :</strong> <?= $user->getAddress() . ", " . $user->getPostalCode() . " " . $user->getCity() . ($user->getCountry() == "France" ? "" : ", " . $user->getCountry()) ?><br /> <strong>Adresse :</strong> <?= $user->getAddress() . ", " . $user->getPostalCode() . " " . $user->getCity() . ($user->getCountry() == "France" ? "" : ", " . $user->getCountry()) ?><br />
</div> </div>
<?php } ?>
<div class="alert alert-info"> <div class="alert alert-info">
<strong>Adresse e-mail :</strong> <a href="mailto:<?= $user->getEmail() ?>"><?= $user->getEmail() ?></a><br /> <strong>Adresse e-mail :</strong> <a href="mailto:<?= $user->getEmail() ?>"><?= $user->getEmail() ?></a><br />
@ -156,7 +160,7 @@ if (!$has_error) {
<?php } <?php }
if ($user->getRole() == Role::ADMIN || $user->getRole() == Role::ORGANIZER) { if ($user->getRole() == Role::ADMIN || $user->getRole() == Role::ORGANIZER) {
foreach ($tournaments as $tournament) { foreach ($user->getOrganizedTournaments() as $tournament) {
echo "<div class=\"alert alert-info\">Organise le tournoi <a href=\"/tournoi/" . $tournament->getName(). "\">" . $tournament->getName() . "</a></div>"; echo "<div class=\"alert alert-info\">Organise le tournoi <a href=\"/tournoi/" . $tournament->getName(). "\">" . $tournament->getName() . "</a></div>";
} }
} }

View File

@ -135,9 +135,9 @@ else {
<label for="organizers">Organisateur·s :</label> <label for="organizers">Organisateur·s :</label>
<select class="custom-select" id="organizers" name="organizers[]" multiple size="4" required> <select class="custom-select" id="organizers" name="organizers[]" multiple size="4" required>
<?php <?php
while (($orga_data = $orgas_response->fetch()) !== FALSE) { foreach (User::getOrganizers() as $orga) {
echo "<option value=\"" . $orga_data["id"] . "\" " . ($tournament->organize($orga_data["id"]) ? "selected" : "") echo "<option value=\"" . $orga->getId() . "\" " . ($tournament->organize($orga->getId()) ? "selected" : "")
. ">" . $orga_data["first_name"] . " " . $orga_data["surname"] . "</option>\n"; . ">" . $orga->getFirstName() . " " . $orga->getSurname() . "</option>\n";
} }
?> ?>
</select> </select>

View File

@ -23,8 +23,8 @@
<a href="/tournoi/<?= $tournament->getName() ?>"><?= $tournament->getName() ?></a> <a href="/tournoi/<?= $tournament->getName() ?>"><?= $tournament->getName() ?></a>
</th> </th>
<td>Du <?= formatDate($tournament->getStartDate()) ?> au <?= formatDate($tournament->getEndDate()) ?></td> <td>Du <?= formatDate($tournament->getStartDate()) ?> au <?= formatDate($tournament->getEndDate()) ?></td>
<td><?= formatDate($tournament->getInscriptionDate()) ?></td>
<td><?= formatDate($tournament->getSolutionsDate()) ?></td> <td><?= formatDate($tournament->getSolutionsDate()) ?></td>
<td><?= formatDate($tournament->getSynthesesDate()) ?></td>
<td><?= $tournament->getSize() ?></td> <td><?= $tournament->getSize() ?></td>
</tr> </tr>
<?php <?php