1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-29 20:31:11 +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

@ -8,18 +8,19 @@ if (!isset($_SESSION["team"]))
* @var Tournament $tournament
*/
$team = $_SESSION["team"];
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId());
$tournament = Tournament::fromId($team->getTournamentId());
if (isset($_POST["send_synthese"])) {
$error_message = saveSynthese();
if (isset($_POST["send_synthesis"])) {
$error_message = saveSynthesis();
}
/** @noinspection SqlAggregates */
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest` ORDER BY `dest`, `uploaded_at` DESC;");
$syntheses_req->execute([$team->getId(), $tournament->getId()]);
$syntheses = $tournament->getAllSyntheses($team->getId());
$syntheses_final = null;
if ($team->isSelectedForFinal())
$syntheses_final = $FINAL->getAllSyntheses($team->getId());
function saveSynthese() {
global $LOCAL_PATH, $DB, $team, $tournament;
function saveSynthesis() {
global $LOCAL_PATH, $DB, $team, $tournament, $FINAL;
$dest = strtoupper(htmlspecialchars($_POST["dest"]));
@ -51,7 +52,7 @@ function saveSynthese() {
return "Une erreur est survenue lors de l'envoi du fichier.";
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $tournament->getId(), $dest]);
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $dest]);
return false;
}