From d216c395f2a7622e86177c2c0bd1f3a7aedeac6b Mon Sep 17 00:00:00 2001 From: "nicolas.franco" Date: Fri, 23 Dec 2022 11:43:30 +0100 Subject: [PATCH] addList working with view --- business/ListTask.php | 2 +- config/config.php | 4 ++-- controller/FrontCtrl.php | 3 ++- controller/VisitorCtrl.php | 10 ++++++++-- index.php | 1 - model/UserModel.php | 5 ++--- view/home.php | 10 ++++++---- view/newList.php | 2 +- view/newTask.php | 31 ++++++++++++++++--------------- 9 files changed, 38 insertions(+), 30 deletions(-) diff --git a/business/ListTask.php b/business/ListTask.php index f5e3a8a..1815050 100644 --- a/business/ListTask.php +++ b/business/ListTask.php @@ -7,7 +7,7 @@ private int $dc; // done counter # juste visuelle?? function __construct($nom, $owner="",$dc=0,$id=0) { - if($id=0) + if($id==0) $this->id = (int)null; else $this->id = $id; diff --git a/config/config.php b/config/config.php index d192ac5..738b56b 100644 --- a/config/config.php +++ b/config/config.php @@ -3,8 +3,8 @@ $rep=__DIR__.'/../'; - //$con = new Connection('mysql:host=localhost;dbname=phpproject', 'nifranco', 'achanger'); - $con = new Connection('mysql:host=localhost;dbname=dbanboudoul', 'anboudoul', 'mdpMYSQL'); + $con = new Connection('mysql:host=localhost;dbname=phpproject', 'nifranco', 'achanger'); + //$con = new Connection('mysql:host=localhost;dbname=dbanboudoul', 'anboudoul', 'mdpMYSQL'); $TMessage = array(); diff --git a/controller/FrontCtrl.php b/controller/FrontCtrl.php index c5040b8..1a4defa 100644 --- a/controller/FrontCtrl.php +++ b/controller/FrontCtrl.php @@ -15,7 +15,8 @@ class FrontCtrl $this->usrMdl = new UserModel($con); $this->action_User = array('deconnexion','loadListePriv','newListPrivate'); try{ - $this->isUser = $this->usrMdl->isConnected(); // cette fonction retourne quoi? + + $this->isUser = $this->usrMdl->isConnected(); $action = $_REQUEST['action'] ?? null; if(($i = array_search($action,$this->action_User)) !== false){ # si action dans la liste d'actions user diff --git a/controller/VisitorCtrl.php b/controller/VisitorCtrl.php index 7545e30..cd5e6b7 100644 --- a/controller/VisitorCtrl.php +++ b/controller/VisitorCtrl.php @@ -20,6 +20,7 @@ class VisitorCtrl else $action = null; + //if(isset($_POST['listId'])) var_dump($_POST['listId']); switch($action){ case null: $this->loadHome(); @@ -124,15 +125,20 @@ class VisitorCtrl function go_task(){ $user = $this->isUser; + if(isset($_POST['listId'])) $_SESSION['listId'] = $_POST['listId']; 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(); } function eraseTask(){ - + $this->taskModel->supTask($_POST['idT']); + $this->loadHome(); } } diff --git a/index.php b/index.php index 8cec805..9248503 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,6 @@ require('config/Validation.php'); require("view/erreur.php"); require_once("controller/FrontCtrl.php"); - $fc = new FrontCtrl($con, $TabVues); ?> diff --git a/model/UserModel.php b/model/UserModel.php index 9123dd6..5cf0fad 100644 --- a/model/UserModel.php +++ b/model/UserModel.php @@ -31,11 +31,10 @@ function isConnected(){ //teste rôle dans la session, retourne instance d’objet ou booleen Validation::val_form_texte($_SESSION['login'], $TMessage); - if(isset($_SESSION['login'])){ + if(isset($_SESSION['login']) && $_SESSION['login']!="") return true; - } else { + else return false; - } } function ajouter($login, $mdp){ diff --git a/view/home.php b/view/home.php index 10db73d..467fb94 100644 --- a/view/home.php +++ b/view/home.php @@ -61,12 +61,14 @@

'.$l->get_nom().'

-
+
+ +
-
+ @@ -84,8 +86,8 @@ '; } diff --git a/view/newList.php b/view/newList.php index 8afbc1a..4984108 100644 --- a/view/newList.php +++ b/view/newList.php @@ -63,7 +63,7 @@ - + - +
@@ -14,8 +14,8 @@ - + \ No newline at end of file
'.$t->get_titre().' '.$t->get_priorite().' - - + +