mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 09:02:11 +01:00 
			
		
		
		
	Utilisation des nouvelles classes, amélioration du code
This commit is contained in:
		@@ -2,17 +2,19 @@
 | 
			
		||||
 | 
			
		||||
require_once "../config.php";
 | 
			
		||||
 | 
			
		||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ADMIN" && $_SESSION["role"] != "ORGANIZER")
 | 
			
		||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
 | 
			
		||||
    require_once "../403.php";
 | 
			
		||||
 | 
			
		||||
/** @noinspection SqlAggregates */
 | 
			
		||||
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
 | 
			
		||||
	. ($_SESSION["role"] == "ADMIN" ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
 | 
			
		||||
	. ($_SESSION["role"] == Role::ADMIN ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
 | 
			
		||||
	. "`year` = $YEAR GROUP BY `tournament` ORDER BY `name`;");
 | 
			
		||||
 | 
			
		||||
if (isset($_POST["download_zip"])) {
 | 
			
		||||
    $id = $_POST["tournament"];
 | 
			
		||||
    $tournament_name = $_POST["tournament_name"];
 | 
			
		||||
    $files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team`, `problem` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
 | 
			
		||||
	/** @noinspection SqlAggregates */
 | 
			
		||||
	$files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team`, `problem` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
 | 
			
		||||
 | 
			
		||||
    $zip = new ZipArchive();
 | 
			
		||||
 | 
			
		||||
@@ -27,9 +29,9 @@ if (isset($_POST["download_zip"])) {
 | 
			
		||||
        $problem = $data_file["problem"];
 | 
			
		||||
        $version = $data_file["version"];
 | 
			
		||||
        $team_id = $data_file["team"];
 | 
			
		||||
        $team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch();
 | 
			
		||||
        $team_name = $team_data["name"];
 | 
			
		||||
        $team_trigram = $team_data["trigram"];
 | 
			
		||||
        $team = Team::fromId($team_id);
 | 
			
		||||
        $team_name = $team->getName();
 | 
			
		||||
        $team_trigram = $team->getTrigram();
 | 
			
		||||
 | 
			
		||||
        $zip->addFile("$LOCAL_PATH/files/$file_id", "Problème $problem $team_trigram.pdf");
 | 
			
		||||
    }
 | 
			
		||||
@@ -50,15 +52,16 @@ require_once "../views/header.php";
 | 
			
		||||
while (($data_tournament = $req->fetch()) !== false) {
 | 
			
		||||
    echo "<h1>Tournoi de " . $data_tournament["name"] . "</h1>\n";
 | 
			
		||||
    $id = $data_tournament["id"];
 | 
			
		||||
    $files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
 | 
			
		||||
	/** @noinspection SqlAggregates */
 | 
			
		||||
	$files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
 | 
			
		||||
    while (($data_file = $files_req->fetch()) !== false) {
 | 
			
		||||
        $file_id = $data_file["file_id"];
 | 
			
		||||
        $problem = $data_file["problem"];
 | 
			
		||||
        $version = $data_file["version"];
 | 
			
		||||
        $team_id = $data_file["team"];
 | 
			
		||||
        $team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch();
 | 
			
		||||
        $team_name = $team_data["name"];
 | 
			
		||||
        $team_trigram = $team_data["trigram"];
 | 
			
		||||
        $team = Team::fromId($team_id);
 | 
			
		||||
        $team_name = $team->getName();
 | 
			
		||||
        $team_trigram = $team->getTrigram();
 | 
			
		||||
        echo "Problème n°$problem de l'équipe $team_name ($team_trigram), version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user