mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-26 05:42:22 +00:00
143 lines
6.7 KiB
PHP
143 lines
6.7 KiB
PHP
|
<?php
|
||
|
|
||
|
if (isset($_SESSION["user_id"]) && isset($_GET["be-admin"])) {
|
||
|
$DB->exec("UPDATE `users` SET `role` = 'ADMIN' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||
|
quitTeam();
|
||
|
header("Location: $URL_BASE");
|
||
|
exit();
|
||
|
}
|
||
|
|
||
|
if (isset($_SESSION["user_id"]) && isset($_GET["be-organizer"])) {
|
||
|
$DB->exec("UPDATE `users` SET `role` = 'ORGANIZER' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||
|
quitTeam();
|
||
|
header("Location: $URL_BASE");
|
||
|
exit();
|
||
|
}
|
||
|
|
||
|
if (isset($_SESSION["user_id"]) && isset($_GET["be-participant"])) {
|
||
|
$DB->exec("UPDATE `users` SET `role` = 'PARTICIPANT' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||
|
quitTeam();
|
||
|
header("Location: $URL_BASE");
|
||
|
exit();
|
||
|
}
|
||
|
|
||
|
if (isset($_SESSION["user_id"]) && isset($_GET["be-encadrant"])) {
|
||
|
$DB->exec("UPDATE `users` SET `role` = 'ENCADRANT' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||
|
quitTeam();
|
||
|
header("Location: $URL_BASE");
|
||
|
exit();
|
||
|
}
|
||
|
|
||
|
function quitTeam() {
|
||
|
global $DB, $URL_BASE;
|
||
|
|
||
|
if ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER")
|
||
|
return;
|
||
|
|
||
|
for ($i = 1; $i <= ($_SESSION["role"] == "PARTICIPANT" ? 6 : 2); ++$i)
|
||
|
/** @noinspection SqlResolve */
|
||
|
$DB->exec("UPDATE `teams` SET `" . strtolower($_SESSION["role"]) . "_$i` = NULL WHERE `" . strtolower($_SESSION["role"]) . "_$i` = " . $_SESSION["user_id"] . ";");
|
||
|
$DB->exec("UPDATE `users` SET `team_id` = NULL WHERE `id` = " . $_SESSION["user_id"] . ";");
|
||
|
$DB->exec("UPDATE `teams` SET `encadrant_1` = `encadrant_2`, `encadrant_2` = NULL WHERE `encadrant_1` IS NULL;");
|
||
|
for ($i = 1; $i <= 5; ++$i) {
|
||
|
/** @noinspection SqlResolve */
|
||
|
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
|
||
|
}
|
||
|
|
||
|
$req = $DB->query("SELECT `file_id` FROM `documents` WHERE `user` = '" . $_SESSION["user_id"] . "';");
|
||
|
while (($data = $req->fetch()) !== false)
|
||
|
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||
|
$DB->exec("DELETE FROM `documents` WHERE `user` = '" . $_SESSION["user_id"] . "';");
|
||
|
|
||
|
if ($DB->exec("DELETE FROM `teams` WHERE `encadrant_1` IS NULL AND `participant_1` IS NULL;") > 0) {
|
||
|
$req = $DB->query("SELECT `file_id` FROM `solutions` WHERE `team` = '" . $_SESSION["team_id"] . "';");
|
||
|
while (($data = $req->fetch()) !== false)
|
||
|
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||
|
$DB->exec("DELETE FROM `solutions` WHERE `team` = " . $_SESSION["team_id"] . ";");
|
||
|
|
||
|
$req = $DB->query("SELECT `file_id` FROM `syntheses` WHERE `team` = '" . $_SESSION["team_id"] . "';");
|
||
|
while (($data = $req->fetch()) !== false)
|
||
|
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||
|
$DB->exec("DELETE FROM `syntheses` WHERE `team` = " . $_SESSION["team_id"] . ";");
|
||
|
}
|
||
|
unset($_SESSION["team_id"]);
|
||
|
unset($_SESSION["team_validation_status"]);
|
||
|
}
|
||
|
|
||
|
?>
|
||
|
|
||
|
<!DOCTYPE html>
|
||
|
<html lang="fr">
|
||
|
<head>
|
||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||
|
<meta name="viewport" content= "width=device-width, initial-scale=1.0" />
|
||
|
<title>Site d'inscription pour le TFJM² <?= $YEAR ?></title>
|
||
|
<link rel="stylesheet" type="text/css" href="<?= $URL_BASE ?>/style.css" />
|
||
|
|
||
|
<!-- Bootstrap core CSS -->
|
||
|
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/bootstrap/css/bootstrap.min.css">
|
||
|
|
||
|
<!-- Custom fonts for this template -->
|
||
|
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/font-awesome/css/font-awesome.min.css">
|
||
|
|
||
|
<!-- Plugin CSS -->
|
||
|
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/datatables/dataTables.bootstrap4.css">
|
||
|
|
||
|
<!-- Custom styles for this template -->
|
||
|
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/css2/sb-admin.css">
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<ul id="menu">
|
||
|
<li id="menu-logo"><img src="<?= $URL_BASE ?>/logo.svg" alt="logo tfjm"></li>
|
||
|
<li><a href="<?= $URL_BASE ?>/">Accueil</a></li>
|
||
|
<li><a href="<?= $URL_BASE ?>/tournois">Liste des tournois</a></li>
|
||
|
<?php if (!isset($_SESSION["user_id"])) { ?>
|
||
|
<li><a href="<?= $URL_BASE ?>/connexion">Connexion</a></li>
|
||
|
<li><a href="<?= $URL_BASE ?>/inscription">Inscription</a></li>
|
||
|
<?php } else { ?>
|
||
|
<li><a href="<?= $URL_BASE ?>/mon_compte">Mon compte</a></li>
|
||
|
<?php if ($_SESSION["role"] == "ENCADRANT" || $_SESSION["role"] == "PARTICIPANT") { ?>
|
||
|
<?php if ($_SESSION["team_id"] == NULL) { ?>
|
||
|
<li><a href="<?= $URL_BASE ?>/ajouter_equipe">Ajouter une équipe</a></li>
|
||
|
<li><a href="<?= $URL_BASE ?>/rejoindre_equipe">Rejoindre une équipe</a></li>
|
||
|
<?php } else { ?>
|
||
|
<li><a href="<?= $URL_BASE ?>/mon_equipe">Mon équipe</a></li>
|
||
|
<?php if ($_SESSION["team_validation_status"] == "VALIDATED" || true) { ?>
|
||
|
<li><a href="https://paypal.me/galaxyoyo42">Paiement</a></li>
|
||
|
<li><a href="<?= $URL_BASE ?>/solutions">Solutions</a></li>
|
||
|
<li><a href="<?= $URL_BASE ?>/syntheses">Notes de synthèse</a></li>
|
||
|
<?php } ?>
|
||
|
<?php } ?>
|
||
|
<?php } ?>
|
||
|
<?php if ($_SESSION["role"] == "ADMIN") { ?>
|
||
|
<li><a href="<?= $URL_BASE ?>/ajouter_tournoi">Ajouter un tournoi</a></li>
|
||
|
<li><a href="<?= $URL_BASE ?>/ajouter_organisateur">Ajouter un organisateur</a></li>
|
||
|
<?php } ?>
|
||
|
<?php if ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER") { ?>
|
||
|
<li><a href="<?= $URL_BASE ?>/solutions_orga">Solutions</a></li>
|
||
|
<li><a href="<?= $URL_BASE ?>/syntheses_orga">Notes de synthèse</a></li>
|
||
|
<?php } ?>
|
||
|
<li><a href="<?= $URL_BASE ?>/deconnexion">Déconnexion</a></li>
|
||
|
<hr />
|
||
|
<?php
|
||
|
if ($_SESSION["role"] != "ADMIN") {
|
||
|
echo "<li><a href=\"?be-admin=1\">Devenir administrateur</a></li>";
|
||
|
}
|
||
|
if ($_SESSION["role"] != "ORGANIZER") {
|
||
|
echo "<li><a href=\"?be-organizer=1\">Devenir organisateur</a></li>";
|
||
|
}
|
||
|
if ($_SESSION["role"] != "PARTICIPANT") {
|
||
|
echo "<li><a href=\"?be-participant=1\">Devenir participant</a></li>";
|
||
|
}
|
||
|
if ($_SESSION["role"] != "ENCADRANT") {
|
||
|
echo "<li><a href=\"?be-encadrant=1\">Devenir encadrant</a></li>";
|
||
|
}
|
||
|
?>
|
||
|
<?php } ?>
|
||
|
</ul>
|
||
|
|
||
|
<div id="main-container">
|
||
|
<div id="main-content">
|
||
|
<!-- <h1 style="text-align: center">Site d'inscription pour le TFJM² <?= $YEAR ?></h1> -->
|
||
|
<div class="container-fluid">
|