mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 03:02:14 +01:00 
			
		
		
		
	Améliorations du code
This commit is contained in:
		@@ -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;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user