diff --git a/src/.htaccess b/src/.htaccess index ec1fb4b..8cdac8d 100755 --- a/src/.htaccess +++ b/src/.htaccess @@ -18,4 +18,5 @@ RewriteRule ^MonProfil$ index.php?action=redirectionProfil [L] RewriteRule ^supprimerCompte$ index.php?action=supprimerCompte [L] RewriteRule ^previousPage$ index.php?action=pagePrécédente [L] RewriteRule ^nextPage$ index.php?action=pageSuivante [L] -RewriteRule ^Users$ index.php?action=voirUser [L] \ No newline at end of file +RewriteRule ^Users$ index.php?action=voirUser [L] +RewriteRule ^listePrive$ index.php?action=listePrive [L] \ No newline at end of file diff --git a/src/config/config.php b/src/config/config.php index 2001310..6595dbf 100755 --- a/src/config/config.php +++ b/src/config/config.php @@ -12,6 +12,7 @@ $dsn='mysql:host=londres.uca.local;dbname=dbemkartal1'; $vues['erreur']='vue/html/erreur.php'; $vues['inscription']='vue/html/inscription.php'; $vues['listPublic']='vue/html/PageListePublic.php'; +$vues['listPrive']='vue/html/PageListePrive.php'; $vues['login']='vue/html/login.php'; $vues['NavBar']='vue/html/NavBar.php'; $vues['profil']='vue/html/profil.php'; diff --git a/src/controller/CtrlUtilisateur.php b/src/controller/CtrlUtilisateur.php index eab90f0..764ed13 100755 --- a/src/controller/CtrlUtilisateur.php +++ b/src/controller/CtrlUtilisateur.php @@ -37,6 +37,34 @@ class CtrlUtilisateur { $this->changerMotDePasse($dVueErreur); break; + case "listePrive": + $this->ConsulterListePrive($dVueErreur); + break; + + case "SupprimerTachePrive": + $this->SupprimerTachePrive($dVueErreur); + break; + + case "AjouterTachePrive": + $this->AjouterTachePrive($dVueErreur); + break; + + case "ModifierListePrive": + $this->ModifierListePrive($dVueErreur); + break; + + case "checkPrive": + $this->checkPrive($dVueErreur); + break; + + case "AjouterListePrive": + $this->AjouterListePrive($dVueErreur); + break; + + case "SupprimerListePrive": + $this->SupprimerListePrive($dVueErreur); + break; + default: $dVueErreur[] = "Erreur d'appel php"; require ($rep.$vues['erreur']); @@ -106,6 +134,86 @@ class CtrlUtilisateur { } + function ConsulterListePrive(array $dVueErreur) { + global $rep,$vues; + $listesPrive = MdlUtilisateur::RecupererListePrive(); + $taches = MdlVisiteur::RecupererTache(); + $action=NULL; + require ($rep.$vues['listPrive']); + } + + function SupprimerTachePrive(array $dVueErreur){ + global $rep,$vues; + $tache = MdlVisiteur::SupprimerTache(); + $this->ConsulterListePrive($dVueErreur); + } + + function SupprimerListePrive(array $dVueErreur){ + global $rep,$vues; + $liste = MdlVisiteur::SupprimerListe(); + $this->ConsulterListePrive($dVueErreur); + + } + + public function AjouterTachePrive(array $dVueErreur){ + global $rep,$vues; + try{ + $tache = MdlVisiteur::AjouterTache($dVueErreur); + $this->ConsulterListePrive($dVueErreur); + } + catch (Exception $e) + { + $ErreurLog=$e->getMessage(); + $listesPrive= MdlUtilisateur::RecupererListePrive(); + $taches = MdlVisiteur::RecupererTache(); + $action=NULL; + require ($rep.$vues['listPrive']); + } + } + + + public function ModifierListePrive(array $dVueErreur){ + global $rep,$vues; + try{ + $tache = MdlVisiteur::ModifierListe($dVueErreurs); + $this->ConsulterListePrive($dVueErreur); + } + catch (Exception $e) + { + $ErreurLog=$e->getMessage(); + $listesPrive= MdlUtilisateur::RecupererListePrive(); + $taches = MdlVisiteur::RecupererTache(); + $action=NULL; + require ($rep.$vues['listPublic']); + } + } + + + public function checkPrive() + { + global $rep,$vues; + $tache = MdlVisiteur::check(); + $this->ConsulterListePrive($dVueErreur); + } + + public function AjouterListePrive(array $dVueErreur){ + global $rep,$vues; + + try{ + $tache = MdlUtilisateur::AjouterListePrive($dVueErreur); + $this->ConsulterListePrive($dVueErreur); + } + catch (Exception $e) + { + $ErreurLog=$e->getMessage(); + $listes = MdlUtilisateur::RecupererListePrive(); + $taches = MdlVisiteur::RecupererTache(); + $action=NULL; + require ($rep.$vues['listPrive']); + } + + } + }//fin class ?> diff --git a/src/controller/CtrlVisiteur.php b/src/controller/CtrlVisiteur.php index ee06715..5854989 100755 --- a/src/controller/CtrlVisiteur.php +++ b/src/controller/CtrlVisiteur.php @@ -158,13 +158,28 @@ class CtrlVisiteur { } function SupprimerListe(array $dVueErreur){ + global $rep,$vues; $liste = MdlVisiteur::SupprimerListe(); - $this->ConsulterListePublic($dVueErreur); + $listes = MdlVisiteur::RecupererListePublic(); + $taches = MdlVisiteur::RecupererTache(); + $action=NULL; + require ($rep.$vues['listPublic']); } public function AjouterTache(array $dVueErreur){ - $tache = MdlVisiteur::AjouterTache(); - $this->ConsulterListePublic($dVueErreur); + global $rep,$vues; + try{ + $tache = MdlVisiteur::AjouterTache($dVueErreur); + $this->ConsulterListePublic($dVueErreur); + } + catch (Exception $e) + { + $ErreurLog=$e->getMessage(); + $listes = MdlVisiteur::RecupererListePublic(); + $taches = MdlVisiteur::RecupererTache(); + $action=NULL; + require ($rep.$vues['listPublic']); + } } public function AjouterListePublic(array $dVueErreur){ @@ -185,10 +200,22 @@ class CtrlVisiteur { } public function ModifierListe(array $dVueErreur){ - $tache = MdlVisiteur::ModifierListe(); - $this->ConsulterListePublic($dVueErreur); + global $rep,$vues; + try{ + $tache = MdlVisiteur::ModifierListe($dVueErreurs); + $this->ConsulterListePublic($dVueErreur); + } + catch (Exception $e) + { + $ErreurLog=$e->getMessage(); + $listes = MdlVisiteur::RecupererListePublic(); + $taches = MdlVisiteur::RecupererTache(); + $action=NULL; + require ($rep.$vues['listPublic']); + } } + public function check(array $dVueErreur) { $tache = MdlVisiteur::check(); diff --git a/src/controller/FrontControleur.php b/src/controller/FrontControleur.php index 549a763..ebb9f39 100755 --- a/src/controller/FrontControleur.php +++ b/src/controller/FrontControleur.php @@ -11,7 +11,7 @@ class FrontControleur { $string_actor=' '; $listeActions=array( - 'Utilisateur' => array('logout','redirectionProfil','supprimerCompte','modifMdp'), + 'Utilisateur' => array('logout','redirectionProfil','supprimerCompte', 'listePrive','AjouterListePrive', 'SupprimerListePrive', 'AjouterTachePrive', 'ModifierListePrive', 'SupprimerTachePrive'), 'Admin' => array('voirUser') ); diff --git a/src/modele/MdlUtilisateur.php b/src/modele/MdlUtilisateur.php index 4afe70c..fe3be89 100755 --- a/src/modele/MdlUtilisateur.php +++ b/src/modele/MdlUtilisateur.php @@ -79,5 +79,19 @@ class MdlUtilisateur } + public function AjouterListePrive(&$dVueErreur){ + $taskGtw = new ListeGateway(); + $nom=$_POST['nom-ajout-liste']; + $description=$_POST['description-ajout-liste']; + $idCreateur =Validation::cleanInt($_SESSION['id']); + Validation::val_form_add($nom,$description,$dVueErreur); + $taskGtw->Ajouter($nom, $description,0, $idCreateur); + } + + public static function RecupererListePrive(){ + $userGtw = new ListeGateway(); + return $userGtw->getListePrive(0,10); + } + } diff --git a/src/modele/MdlVisiteur.php b/src/modele/MdlVisiteur.php index c3be432..636b495 100755 --- a/src/modele/MdlVisiteur.php +++ b/src/modele/MdlVisiteur.php @@ -16,12 +16,9 @@ class MdlVisiteur $userGtw->AjouterUtilisateur($_POST["nom-Form"],$_POST["prenom-Form"],$_POST["pseudo-Form"],$_POST["mail"],$hash); } - public static function RecupererListePublic(){ +public static function RecupererListePublic(){ $userGtw = new ListeGateway(); - if(isset($_COOKIE['page'])) - return $userGtw->getListePublic(($_COOKIE['page']-1)*10,10); - else - return $userGtw->getListePublic(1,10); + return $userGtw->getListePublic(0,10); } public static function RecupererTache(){ @@ -43,7 +40,7 @@ class MdlVisiteur $userGtw->Supprimer($id); } - public function AjouterTache(){ + public function AjouterTache(&$dVueErreur){ $taskGtw = new TacheGateway(); $id = $_POST['idListe']; $nom = $_POST['nom-ajout']; @@ -52,11 +49,12 @@ class MdlVisiteur $taskGtw->AjouterTache($nom, $description,false,$id); } - public function ModifierListe(){ + public function ModifierListe(&$dVueErreur){ $userGtw = new ListeGateway(); $id = $_POST['idListe']; - $nom = $_POST['nom-modif-liste']; - $description = $_POST['description-modif-liste']; + $nom = Validation::cleanText($_POST['nom-modif-liste']); + $description = Validation::cleanText($_POST['description-modif-liste']); + if($description == NULL){ $userGtw->EditerNom($id, $nom); } @@ -69,11 +67,11 @@ class MdlVisiteur } public function AjouterListePublic(&$dVueErreur){ - $listGtw = new ListeGateway(); + $taskGtw = new ListeGateway(); $nom=$_POST['nom-ajout-liste']; $description=$_POST['description-ajout-liste']; Validation::val_form_add($nom,$description,$dVueErreur); - $listGtw->Ajouter($nom, $description,1, true); + $taskGtw->Ajouter($nom, $description,1, null); } public function check(){ @@ -82,4 +80,5 @@ class MdlVisiteur $taskGtw->isDone($id); } + } diff --git a/src/modele/gateway/ListeGateway.php b/src/modele/gateway/ListeGateway.php index c5c12dc..3fb6ed8 100755 --- a/src/modele/gateway/ListeGateway.php +++ b/src/modele/gateway/ListeGateway.php @@ -63,5 +63,14 @@ class ListeGateway{ } return $listes; } + public function getListePrive($offset,$limit){ + $query = "SELECT * FROM ToDoList_Liste WHERE !estPublic LIMIT $offset, $limit"; + $this->con->executeQuery($query); + $listes = []; + foreach ($this->con->getResults() as $liste) { + $listes[] = new Liste($liste["id"],$liste["nom"],$liste["description"],$liste["dateCreation"],$liste["estPublic"],$liste["idUtilisateur"]); + } + return $listes; + } } ?> \ No newline at end of file diff --git a/src/vue/html/NavBar.php b/src/vue/html/NavBar.php index ac16dce..de9d24c 100755 --- a/src/vue/html/NavBar.php +++ b/src/vue/html/NavBar.php @@ -20,7 +20,7 @@
Listes Publiques
-
Mes listes
+
Mes listes
Les utilisateurs
diff --git a/src/vue/html/PageListePrive.php b/src/vue/html/PageListePrive.php new file mode 100644 index 0000000..13da8de --- /dev/null +++ b/src/vue/html/PageListePrive.php @@ -0,0 +1,339 @@ + + + + + + + Home Page + + + + + + + + + + +
+
+
+ + + +
+ +
+ + getIdUtilisateur() == $_SESSION['id']){ + + $done = 0; + $total = 0; + ?> + + + +
+
+
+
+
+
+

+ getNom()?> + + + + + + + +

+

getDescription()?> +

getDateCreation()?> : getIdUtilisateur()?>

+
+ + + + +
+ +
+ + + +
+ +
+ + + +
    + getIdListe() == $liste->getId()){ + if($tache->getEstValide() == 1){ + $done = $done + 1; + } + $total = $total + 1; + ?> +
  • +
    + getEstValide() == 1) echo "checked" ?>> + +
    + getNom() ?> : getDescription() ?> + + + + +
  • + +
+
+
+ +
%;">
+
+
+
+
+
+ + + + + + + + + + + \ No newline at end of file