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

@ -4,6 +4,8 @@ class VisitorController {
public function __construct() { public function __construct() {
global $rep,$vues; global $rep,$vues;
//On démarre la session
session_sart();
$arrayErrorViews= array(); $arrayErrorViews= array();
try{ try{
@ -17,7 +19,6 @@ class VisitorController {
break; break;
case "inscription": case "inscription":
$this->inscription($arrayErrorViews); $this->inscription($arrayErrorViews);
break;
case "creerListe": case "creerListe":
$this->creerListe($arrayErrorViews); $this->creerListe($arrayErrorViews);
break; break;
@ -30,9 +31,6 @@ class VisitorController {
case "cocherTache": case "cocherTache":
$this->cocherTache($arrayErrorViews); $this->cocherTache($arrayErrorViews);
break; break;
case "decocherTache":
$this->decocherTache($arrayErrorViews);
break;
case "supprTache": case "supprTache":
$this->supprTache($arrayErrorViews); $this->supprTache($arrayErrorViews);
default : default :
@ -41,14 +39,14 @@ class VisitorController {
} }
} catch(PDOException $e){ } catch(PDOException $e){
$dataView[]="Erreur inatendue"; $dataView[]="Erreur inatendue";
require('erreur.php'); require(__DIR__.'/../vues/erreur.php');
} }
exit(0); exit(0);
} }
public function reinit(){ public function reinit(){
global $rep,$vues; global $rep,$vues;
require($rep.$vues['acceuil.php']); require($rep.$vues['acceuil']);
} }
public function connection(array $vues_erreur){ public function connection(array $vues_erreur){
@ -59,7 +57,7 @@ class VisitorController {
Validation::clear_string($pwd); Validation::clear_string($pwd);
Validation::val_connexion($usrname,$pwd,$vues_erreur); Validation::val_connexion($usrname,$pwd,$vues_erreur);
$model = new VisiteurModel(); $model = new UserModel();
$worked=$model->connexion(); $worked=$model->connexion();
/* /*
$dVue = array ( $dVue = array (
@ -75,13 +73,12 @@ class VisitorController {
public function inscription(array $vues_erreur){ public function inscription(array $vues_erreur){
global $rep,$vues; global $rep,$vues;
require($rep.$vues['inscription']);
$usrname=$_POST['login']; $usrname=$_POST['login'];
$pwd=$_POST['mdp']; $pwd=$_POST['mdp'];
Validation::val_connexion($usrname,$pwd,$vues_erreur); Validation::val_connexion($usrname,$pwd,$vues_erreur);
$model = new VisiteurModel(); $model = new UserModel();
$model->inscription(); $model->inscription();
} }
@ -91,7 +88,7 @@ class VisitorController {
$nom=$_POST['nom']; $nom=$_POST['nom'];
$model = new VisiteurModel(); $model = new ListeModel();
$model->creerListe($nom); $model->creerListe($nom);
} }
@ -99,7 +96,7 @@ class VisitorController {
global $rep, $vues; global $rep, $vues;
require($rep.$vues['suppressionListe']); require($rep.$vues['suppressionListe']);
$model = new VisiteurModel(); $model = new ListeModel();
$model->supprListe(); $model->supprListe();
} }
@ -109,39 +106,9 @@ class VisitorController {
$intitule = $_POST['intitule']; $intitule = $_POST['intitule'];
$model = new VisiteurModel(); $model = new ListeModel();
$model->creerTache(); $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 <?php
require('ControleurUtilisateur.php'); require('modeles/Modele/UserModel.php');
require('ControleurVisiteur.php'); require('modeles/Modele/VisiteurModel.php');
class FrontControleur{ class FrontControleur{
public function __construct(){ public function __construct(){
//On démarre la session
session_start();
$liste_actions_utilisateur = array('deconnection','crerListePv','desinscription','changerPassword'); $liste_actions_utilisateur = array('deconnection','crerListePv','desinscription','changerPassword');
$liste_actions_visiteur = array('creerListe','suprrListe','connection','inscription','creerTache','cocherTache','supprTache'); $liste_actions_visiteur = array('creerListe','suprrListe','connection','inscription','creerTache','cocherTache','supprTache');
global $rep,$vues; global $rep,$vues;
try{ try{
$action = isset($_REQUEST['action']) ? (string)$_REQUEST['action']: null; $user = $_SESSION['login'];
$action = $_REQUEST['action'];
if (in_array($action,$liste_actions_utilisateur)){ if (in_array($action,$liste_actions_utilisateur)){
if( !isset($_SESSION['login'])){ if($user == null){
new VisitorController(); new VisiteurController();
} else { } else {
new UserController(); new UserController();
} }
} else{ } else{
new VisitorController(); new VisiteurController();
} }
} catch (Exception $e){require ($rep.$vues['erreur']);} } 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){ public function creerListe(string $nom, int $idCreator){
try{ try{
$co = $this->co; $co = $this->co;

@ -43,18 +43,6 @@
public function creerTache(string $intitule){ public function creerTache(string $intitule){
$this->get_gtwListe()->creerTache($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