diff --git a/controller/FrontCtrl.php b/controller/FrontCtrl.php index 99cf3d2..352b578 100644 --- a/controller/FrontCtrl.php +++ b/controller/FrontCtrl.php @@ -13,7 +13,7 @@ class FrontCtrl session_start(); $this->TMessage = $TMessage; $this->TabVues = $TabVues; - $this->usrMdl = new UserModel($con); + $this->usrMdl = new UserModel($con, $this->TMessage); $this->action_User = array('deconnecter', 'voirListePriv', 'creerListePriv', 'supprimerListePriv'); try{ diff --git a/controller/UserCtrl.php b/controller/UserCtrl.php index 379462d..8c318a5 100644 --- a/controller/UserCtrl.php +++ b/controller/UserCtrl.php @@ -13,7 +13,7 @@ class UserCtrl $this->TabVues = $TabVues; $this->TMessage = $TMessage; $this->con = $con; - $this->userModel = new UserModel($this->con); + $this->userModel = new UserModel($this->con, $this->TMessage); $this->taskModel = new TaskModel($this->con); try{ $action=$_REQUEST['action']; diff --git a/controller/VisitorCtrl.php b/controller/VisitorCtrl.php index d82f1f4..63a73fe 100644 --- a/controller/VisitorCtrl.php +++ b/controller/VisitorCtrl.php @@ -14,7 +14,7 @@ class VisitorCtrl $this->isUser = $isUser; $dvueErreur = array(); $this->taskModel = new TaskModel($con); - $this->userModel = new UserModel($con); + $this->userModel = new UserModel($con, $this->TMessage); try{ if(isset($_REQUEST['action'])) $action = $_REQUEST['action']; @@ -151,24 +151,34 @@ class VisitorCtrl function go_task(){ $user = $this->isUser; if(isset($_POST['listId'])) $_SESSION['listId'] = $_POST['listId']; + if(isset($_POST['isPriv'])) $_SESSION['isPriv'] = $_POST['isPriv']; require("view/newTask.php"); } function addTask(){ - //$titre,$desc,$priorite,$idList,$dateDeb="",$dateFin="",$isDone=false,$id=0 $this->taskModel->addTask($_POST['titreT'],$_POST['descT'], $_POST['prioriteT'],$_SESSION['listId'],$_POST['dateDebT'],$_POST['dateFinT']); - $this->loadHome(); + + if(isset($_SESSION['isPriv']) && $_SESSION['isPriv']) + header("Location:index.php?action=voirListePriv"); + else + $this->loadHome(); } function eraseTask(){ $this->taskModel->supTask($_POST['idT']); - $this->loadHome(); + if(!empty($_POST['isPriv'])) + header("Location:index.php?action=voirListePriv"); + else + $this->loadHome(); } function isDone(){ $this->taskModel->modifTask($_POST['idT'],'isDone',true); - $this->loadHome(); + if($_POST['isPriv']) + header("Location:index.php?action=voirListePriv"); + else + $this->loadHome(); } } ?> \ No newline at end of file diff --git a/dal/UserGateway.php b/dal/UserGateway.php index 4bee498..ed5f035 100644 --- a/dal/UserGateway.php +++ b/dal/UserGateway.php @@ -47,7 +47,7 @@ $query = 'SELECT mdp FROM User WHERE login = :login'; $this->con->executeQuery($query, array(':login'=>array($login, PDO::PARAM_STR))); $result = $this->con->getResults(); - + if(empty($result[0][0])) return; if(password_verify($mdp, $result[0][0])) return $login; } diff --git a/model/UserModel.php b/model/UserModel.php index 3f12220..0a74197 100644 --- a/model/UserModel.php +++ b/model/UserModel.php @@ -6,15 +6,17 @@ class UserModel{ private $con; private $gat; + private $TMessage; - public function __construct(Connection $con) { + public function __construct(Connection $con, $TMessage) { + $this->TMessage = $TMessage; $this->con = $con; $this->gat = new UserGateway($con); } function connexion($login, $mdp){ - Validation::val_form_texte($login, $TMessage); - Validation::val_form_mdp($mdp, $TMessage); + Validation::val_form_texte($login, $this->TMessage); + Validation::val_form_mdp($mdp, $this->TMessage); $result = $this->gat->findUser($login, $mdp); if(!isset($result)) echo 'not set works'; @@ -30,7 +32,7 @@ } function isConnected(){ //teste rôle dans la session, retourne instance d’objet ou booleen - Validation::val_form_texte($_SESSION['login'], $TMessage); + Validation::val_form_texte($_SESSION['login'], $this->TMessage); if(isset($_SESSION['login']) && $_SESSION['login']!="") return true; else @@ -38,26 +40,26 @@ } function ajouter($login, $mdp){ - Validation::val_form_texte($login, $TMessage); - Validation::val_form_mdp($mdp, $TMessage); + Validation::val_form_texte($login, $this->TMessage); + Validation::val_form_mdp($mdp, $this->TMessage); $user = $this->findByLogin($login); if (empty($user)) $this->gat->create($login, $mdp); } function supprimer($login){ - Validation::val_form_texte($login, $TMessage); + Validation::val_form_texte($login, $this->TMessage); $this->gat->delete($login); } function modifMdp($login, $mdp){ - Validation::val_form_texte($login, $TMessage); - Validation::val_form_mdp($mdp, $TMessage); + Validation::val_form_texte($login, $this->TMessage); + Validation::val_form_mdp($mdp, $this->TMessage); $this->gat->updateMdp($login, $mdp); } function findByLogin($login){ - Validation::val_form_texte($login, $TMessage); + Validation::val_form_texte($login, $this->TMessage); $user = null; if ($login !== " " && $login != null ) { @@ -70,8 +72,8 @@ } function modifLogin($oldLogin, $newLogin){ - Validation::val_form_texte($oldLogin, $TMessage); - Validation::val_form_texte($newLogin, $TMessage); + Validation::val_form_texte($oldLogin, $this->TMessage); + Validation::val_form_texte($newLogin, $this->TMessage); $user = $this->findByLogin($oldLogin); if (empty($user)) $this->gat->updateLogin($oldLogin, $newLogin); diff --git a/view/js/home.js b/view/js/home.js index f404d30..b787a8e 100644 --- a/view/js/home.js +++ b/view/js/home.js @@ -24,3 +24,12 @@ window.addEventListener('DOMContentLoaded', event => { } }); + +function hideShow() { + var x = document.getElementById("myDIV"); + if (x.style.display === "none") { + x.style.display = "block"; + } else { + x.style.display = "none"; + } +} diff --git a/view/privHome.php b/view/privHome.php index a7f5192..9b51ca0 100644 --- a/view/privHome.php +++ b/view/privHome.php @@ -67,15 +67,16 @@ +
Task | -Importance | -Actions | -
---|---|---|
Task | +Importance | +Actions | +
-
-
+
+
+
+
+
|
';
- }
+ }
} else {
echo '
Starting date : '.$t->get_dateDeb().'
+'.$t->get_dateFin().'
+