ADD: front controleur fonctionnel

master
Lucie Bedouret 2 years ago
parent f67442e4b2
commit bbeee05bb2

BIN
.DS_Store vendored

Binary file not shown.

@ -4,7 +4,8 @@ class UserController{
public function __construct() {
global $rep,$vues;
//On démarre la session
session_sart();
$arrayErrorViews= array();
$action = $_REQUEST['action']??null;
@ -69,7 +70,7 @@ class UserController{
try{
UserModel::changerPassword($newPassword);
require($rep.$vues['profil']);
require($rep.$vues['profil'])
}catch(PDOException $e){
$dataView[]="Erreur inatendue";
require($rep.$vues['erreur']);

@ -4,6 +4,8 @@ class VisitorController {
public function __construct() {
global $rep,$vues;
//On démarre la session
session_sart();
$arrayErrorViews= array();
try{
@ -17,7 +19,6 @@ class VisitorController {
break;
case "inscription":
$this->inscription($arrayErrorViews);
break;
case "creerListe":
$this->creerListe($arrayErrorViews);
break;
@ -30,9 +31,6 @@ class VisitorController {
case "cocherTache":
$this->cocherTache($arrayErrorViews);
break;
case "decocherTache":
$this->decocherTache($arrayErrorViews);
break;
case "supprTache":
$this->supprTache($arrayErrorViews);
default :
@ -41,14 +39,14 @@ class VisitorController {
}
} catch(PDOException $e){
$dataView[]="Erreur inatendue";
require('erreur.php');
require(__DIR__.'/../vues/erreur.php');
}
exit(0);
}
public function reinit(){
global $rep,$vues;
require($rep.$vues['acceuil.php']);
require($rep.$vues['acceuil']);
}
public function connection(array $vues_erreur){
@ -59,7 +57,7 @@ class VisitorController {
Validation::clear_string($pwd);
Validation::val_connexion($usrname,$pwd,$vues_erreur);
$model = new VisiteurModel();
$model = new UserModel();
$worked=$model->connexion();
/*
$dVue = array (
@ -75,13 +73,12 @@ class VisitorController {
public function inscription(array $vues_erreur){
global $rep,$vues;
require($rep.$vues['inscription']);
$usrname=$_POST['login'];
$pwd=$_POST['mdp'];
Validation::val_connexion($usrname,$pwd,$vues_erreur);
$model = new VisiteurModel();
$model = new UserModel();
$model->inscription();
}
@ -91,7 +88,7 @@ class VisitorController {
$nom=$_POST['nom'];
$model = new VisiteurModel();
$model = new ListeModel();
$model->creerListe($nom);
}
@ -99,7 +96,7 @@ class VisitorController {
global $rep, $vues;
require($rep.$vues['suppressionListe']);
$model = new VisiteurModel();
$model = new ListeModel();
$model->supprListe();
}
@ -109,39 +106,9 @@ class VisitorController {
$intitule = $_POST['intitule'];
$model = new VisiteurModel();
$model = new ListeModel();
$model->creerTache();
}
public function cocherTache(array $vues_erreur){
global $rep, $vues;
require($rep.$vues['liste']);
$id = $_POST['idTache'];
$model = new VisiteurModel();
$model->cocherTache($id);
}
public function decocherTache(array $vues_erreur){
global $rep, $vues;
require($rep.$vues['liste']);
$id = $_POST['idTache'];
$model = new VisiteurModel();
$model->decocherTache($id);
}
public function supprTache(array $vues_erreur){
global $rep, $vues;
require($rep.$vues['liste']);
$id = $_POST['idTache'];
$model = new VisiteurModel();
$model->supprTache($id);
}
}
?>

@ -1,28 +1,27 @@
<?php
require('ControleurUtilisateur.php');
require('ControleurVisiteur.php');
require('modeles/Modele/UserModel.php');
require('modeles/Modele/VisiteurModel.php');
class FrontControleur{
public function __construct(){
//On démarre la session
session_start();
$liste_actions_utilisateur = array('deconnection','crerListePv','desinscription','changerPassword');
$liste_actions_visiteur = array('creerListe','suprrListe','connection','inscription','creerTache','cocherTache','supprTache');
global $rep,$vues;
try{
$action = isset($_REQUEST['action']) ? (string)$_REQUEST['action']: null;
$user = $_SESSION['login'];
$action = $_REQUEST['action'];
if (in_array($action,$liste_actions_utilisateur)){
if( !isset($_SESSION['login'])){
new VisitorController();
if($user == null){
new VisiteurController();
} else {
new UserController();
}
} else{
new VisitorController();
new VisiteurController();
}
} catch (Exception $e){require ($rep.$vues['erreur']);}
}

BIN
modeles/.DS_Store vendored

Binary file not shown.

@ -92,22 +92,6 @@ class ListeGateway {
}
}
public function decocherTache(int $id){
if(!empty($id)){
try{
$co = $this->co;
$query = "UPDATE Tache SET isCompleted=false WHERE id=:id";
$co->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR)));
}
catch(PDOException $Exception){
echo 'erreur';
echo $Exception->getMessage();
}
}
}
public function creerListe(string $nom, int $idCreator){
try{
$co = $this->co;

@ -43,18 +43,6 @@
public function creerTache(string $intitule){
$this->get_gtwListe()->creerTache($intitule);
}
public function cocherTache($id){
$this->get_gtwListe()->completeTache($id);
}
public function decocherTache($id){
$this->get_gtwListe()->decocherTache($id);
}
public function supprTache($id){
$this->get_gtwListe()->delTache($id);
}
}
?>

@ -1 +0,0 @@
Subproject commit 8d36530eb50f80bd0d2b77e03ff716c4776f5cfc
Loading…
Cancel
Save