diff --git a/.DS_Store b/.DS_Store index 32b4894..0c71815 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/controleurs/ControleurUtilisateur.php b/controleurs/ControleurUtilisateur.php index 17b5a66..50dd5d7 100644 --- a/controleurs/ControleurUtilisateur.php +++ b/controleurs/ControleurUtilisateur.php @@ -1,6 +1,6 @@ Reinit(); - break; case "deconnection": $this->deconnection($arrayErrorViews); break; - case "creerListe": + case "creerListePv": $this->creerListe($arrayErrorViews); break; - case "supprListe": - $this->supprListe($arrayErrorViews); + case "desinscription": + $this->desinctription($arrayErrorViews); + break; + case "changerInfos": + $this->changerInfos($arrayErrorViews); break; default : $arrayErrorViews[]="Erreur innatendue !!!"; require($rep.$vues['error']); } - */ }catch(PDOException $e){ $dataView[]="Erreur inatendue"; - require(__DIR__.'/../vues/erreur.php'); + require($rep.$vues['erreur']); } - } + } + + public function deconnection($arrayErrorViews){ + // appeler la méthode deco du modèle + UserModel::deconnection(); + } + + public function creerListePv($arrayErrorViews){ + global $rep, $vues; + //recupérer les valeurs du formulaire + $nomListe=$_POST['ListName']; + $privee=$_POST['isPrivate']; + + // valider les champs + Validation::val_creation_Liste_PV($nomListe, $arrayErrorViews); + // vider les champs + //Validation::clear_string($_POST['ListName']); + // appelle à la methode du modèle + if($privee == true){ + UserModel::creerListePv($nomListe,$_SESSION['login']); + }else{ + VisitorModel::creerListe($nomListe); + } + } + + public function desinscription($arrayErrorViews){ + global $rep, $vues; + // recup valeurs des champs + $password=$_POST['password']; + // valider les champs + Validation::val_desinscription($password); + // vider les champs + //Validation::clear_string($_POST['password']); + // appel à la classe userModel + UserModel::desinscription($_SESSION['login']); + } } ?> \ No newline at end of file diff --git a/controleurs/ControleurVisiteur.php b/controleurs/ControleurVisiteur.php index a3bb829..461703d 100644 --- a/controleurs/ControleurVisiteur.php +++ b/controleurs/ControleurVisiteur.php @@ -40,11 +40,7 @@ class VisitorController { } catch(PDOException $e){ $dataView[]="Erreur inatendue"; require(__DIR__.'/../vues/erreur.php'); - } catch (Exception $e2) - { - $dVueEreur[] = "Erreur inattendue!!! "; - require ($rep.$vues['erreur']); - } + } exit(0); } diff --git a/controleurs/FrontControleur.php b/controleurs/FrontControleur.php index bf3caa7..2efdf89 100644 --- a/controleurs/FrontControleur.php +++ b/controleurs/FrontControleur.php @@ -3,8 +3,24 @@ class FrontControleur{ public function __construct(){ + $liste_actions_utilisateur = array('deconnection','crerListePv','desinscription','changerInfos'); + $liste_actions_visiteur = array('creerListe','suprrListe','connection','inscription','creerTache','cocherTache','supprTache'); global $rep,$vues; require($rep.$vues['acceuil']); + try{ + $utilisateur = UserModel::IsUtilisateur(); + $action = $_REQUEST['action']; + + if (in_array($action,$liste_actions_utilisateur)){ + if($utilisateur == null){ + new VisitorController(); + } else { + new UserController(); + } + } else{ + new VisitorController(); + } + } catch (Exception $e){require ($rep.$vues['erreur']);} } } diff --git a/modeles/Gateways/ListeGateway.php b/modeles/Gateways/ListeGateway.php index c69b8f0..5d48252 100644 --- a/modeles/Gateways/ListeGateway.php +++ b/modeles/Gateways/ListeGateway.php @@ -92,21 +92,22 @@ class ListeGateway { } } - public function creerListe(string $nom, string $idCreateur){ - if(!empty($id) && !empty($nom)){ + public function creerListe(string $nom, int $idCreator){ try{ $co = $this->co; - $query = "INSERT INTO Liste VALUES (NULL, :nom)"; + $insertQuery = "INSERT INTO Liste VALUES (NULL, :nom, :idCreator)"; - $co->executeQuery($query, array(':nom' => array($nom, PDO::PARAM_STR))); + + $co->executeQuery($insertQuery, array('nom' => array($nom, PDO::PARAM_STR), + 'idCreator' => array($idCreator, PDO::PARAM_INT))); } catch(PDOException $Exception){ echo 'erreur'; echo $Exception->getMessage(); } - } } + public function delListe(int $id){ if(!empty($id)){ @@ -123,7 +124,6 @@ class ListeGateway { } } } - } ?> \ No newline at end of file diff --git a/modeles/Modele/UserModel.php b/modeles/Modele/UserModel.php new file mode 100644 index 0000000..08841dc --- /dev/null +++ b/modeles/Modele/UserModel.php @@ -0,0 +1,28 @@ +usergw = new UserGateway($co); + $this->listgw = new ListeGateway($co); + } + + public function deconnection(){ + session_unset(); + session_destroy(); + $_SESSION = array(); + } + + public function creerListePv($nom,$idCeator){ + $this->listgw->creerListe($nom,$idCreator); + } + + public function desinscription($login){ + $this->usergw->delUtilisateur($login); + } +} + +?> \ No newline at end of file diff --git a/modeles/Modele/VisitorModel.php b/modeles/Modele/VisitorModel.php new file mode 100644 index 0000000..51e66a7 --- /dev/null +++ b/modeles/Modele/VisitorModel.php @@ -0,0 +1,13 @@ +gw = new ListeGateway($co); + } + +} + +?> \ No newline at end of file diff --git a/modeles/Métier/Liste.php b/modeles/Métier/Liste.php index 10f104f..f4103f5 100644 --- a/modeles/Métier/Liste.php +++ b/modeles/Métier/Liste.php @@ -3,7 +3,7 @@ class Liste { private int $id; private string $nom; - private $taches; + private int $idCreator; function __construct(int $i, string $n, $t){ $this->id=$i; @@ -19,7 +19,7 @@ class Liste { return $this->nom; } - function get_taches(): array { + function get_idCreator(): array { return $this->taches; } } diff --git a/modeles/Métier/Tache.php b/modeles/Métier/Tache.php index 54721a3..cec783c 100644 --- a/modeles/Métier/Tache.php +++ b/modeles/Métier/Tache.php @@ -4,6 +4,7 @@ Class Tache { private int $id; private string $intitule; private boolean $isCompleted; + private int $idListe; function __construct(int $i, string $in, boolean $is){ $this->id = $i; @@ -22,6 +23,10 @@ Class Tache { function get_isCompleted(): boolean { return $this->isCompleted; } + + function get_idListe(): string { + return $this->idListe; + } } ?> \ No newline at end of file diff --git a/views/connection.html b/views/connection.html deleted file mode 100644 index d236ba0..0000000 --- a/views/connection.html +++ /dev/null @@ -1,27 +0,0 @@ - - -
-There was an error in the fields you filled...
-Please enter correct values
-Please enter all the informations :
-You are new here?
- - + +