1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-26 07:57:38 +02:00

Améliorations du code

This commit is contained in:
Yohann
2019-09-08 01:35:05 +02:00
committed by galaxyoyo
parent 3cc66ef783
commit a25ec69ae9
23 changed files with 558 additions and 457 deletions

View File

@ -5,7 +5,7 @@ if (isset($_POST["leave_team"])) {
exit();
}
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `year` = '$YEAR';");
$tournaments = Tournament::getAllTournaments(false, true);
if (isset($_POST["send_document"])) {
$error_message = sendDocument();
@ -19,13 +19,17 @@ if (isset($_POST["request_validation"])) {
}
if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"] !== null) {
/** @var Team $team */
/**
* @var User $user
* @var Team $team
*/
$user = $_SESSION["user"];
$team = $_SESSION["team"];
$tournament = Tournament::fromId($team->getTournamentId());
$documents_req = $DB->prepare("SELECT `file_id`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? GROUP BY `type`, `uploaded_at` ORDER BY `type`, `uploaded_at` DESC;");
$documents_req->execute([$_SESSION["user_id"], $_SESSION[$team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId()]]);
$documents = $user->getAllDocuments($team->getTournamentId());
if ($team->isSelectedForFinal())
$documents_final = $user->getAllDocuments($FINAL->getId());
}
else
require_once "server_files/403.php";
@ -36,7 +40,7 @@ if (isset($_POST["team_edit"])) {
function sendDocument()
{
global $LOCAL_PATH, $DB;
global $LOCAL_PATH, $DB, $FINAL;
$type = strtoupper(htmlspecialchars($_POST["type"]));
if (!isset($type) || ($type != "PARENTAL_CONSENT" && $type != "PHOTO_CONSENT" && $type != "SANITARY_PLUG"))
@ -67,7 +71,7 @@ function sendDocument()
$req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `tournament`, `type`)
VALUES (?, ?, ?, ?, ?);");
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"], $type]);
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team"]->getId(), $_SESSION["team"]->isSelectedForFinal() ? $FINAL->getId() : $_SESSION["team"]->getTournamentId(), $type]);
return false;
}