You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.0 KiB
64 lines
2.0 KiB
<?php
|
|
|
|
namespace controleur;
|
|
|
|
|
|
|
|
use config\Validation;
|
|
|
|
|
|
class FrontControleur
|
|
{
|
|
public function __construct()
|
|
{
|
|
global $twig;
|
|
session_start();
|
|
$dVueErreur = [];
|
|
$actions = array(
|
|
"Admin" => [
|
|
"supprimerCompte", "consulterSignalement", "creerEvenement", "supprimerEvenement","supprimerOffre"
|
|
],
|
|
"Moderateur" => [
|
|
//TODO
|
|
],
|
|
"Membre" => [
|
|
"deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler"
|
|
],
|
|
"Utilisateur" => [
|
|
"connection", "inscription", "accueil","consulterProfilLimite"
|
|
]
|
|
);
|
|
|
|
include 'modeles/TestGateway.php';
|
|
|
|
|
|
$action = Validation::nettoyerString($_GET["action"] ?? "");
|
|
if(in_array($action,$actions['Admin'])) {
|
|
if (!isset($_SESSION["role"]) || $_SESSION["role"]!="admin") {
|
|
$dVueErreur[] = 'Veuillez vous connecter';
|
|
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
|
} else{
|
|
new AdminControleur();
|
|
}
|
|
}
|
|
else if(in_array($action,$actions['Moderateur'])) {
|
|
if (!isset($_SESSION["role"]) || ($_SESSION["role"]!="moderateur" && $_SESSION["role"]!="admin")) {
|
|
$dVueErreur[] = 'Veuillez vous connecter';
|
|
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
|
} else{
|
|
new ModerateurControleur();
|
|
}
|
|
}
|
|
else if(in_array($action,$actions['Membre'])) {
|
|
if (!isset($_SESSION["login"])) {
|
|
$dVueErreur[] = 'Veuillez vous connecter';
|
|
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
|
} else{
|
|
new MembreControleur();
|
|
}
|
|
}else{
|
|
new UtilisateurControleur();
|
|
}
|
|
}
|
|
}
|