diff --git a/business/ListTask.php b/business/ListTask.php index 5d0c002..9710ce1 100644 --- a/business/ListTask.php +++ b/business/ListTask.php @@ -4,7 +4,7 @@ private string $nom; private array $taches; private $owner; - private int $dc; // done counter + private int $dc; // done counter # juste visuelle?? function __construct($id, $nom, $owner="", $dc=0) { $this->id = $id; diff --git a/business/User.php b/business/User.php index 7de66c5..3c3c203 100644 --- a/business/User.php +++ b/business/User.php @@ -1,6 +1,6 @@ login = $login; diff --git a/controller/FrontCtrl.php b/controller/FrontCtrl.php index 1f9c58a..a2a11b5 100644 --- a/controller/FrontCtrl.php +++ b/controller/FrontCtrl.php @@ -3,8 +3,8 @@ require_once('../model/UserModel.php'); class FrontController { - private UserModel $ursMdl; - private $action_User; + //private UserModel $ursMdl; + //private $action_User; function __construct($ursMdl=new UserModel(), $action_User=[]){ $this->$ursMdl = $ursMdl; @@ -21,10 +21,11 @@ class FrontController require("VisitCtrl.php"); $visitCtrl = new VisitCtrl(); $visitCtrl.handleAction('connecter'); + // inclure la vue de connexion } else { # sinon # handle action avec controlleur user require("UserCtrl.php"); - $userCtrl = new UserCtrl(); + $userCtrl = new UserCtrl(); //action ici $userCtrl.handleAction($action); } diff --git a/dal/TaskGateway.php b/dal/TaskGateway.php index 8bff2ee..f63b3bc 100644 --- a/dal/TaskGateway.php +++ b/dal/TaskGateway.php @@ -107,5 +107,40 @@ class TaskGateway ':nom'=> array($l->get_nom(),PDO::PARAM_STR), ':user'=> array($l->get_owner(),PDO::PARAM_STR))); } + + public function findUserList($user){ + # pas réussit a faire une jointure optimale donc + # decomposé en plusieurs foncitons: + # findUserList + # findTacheList + + $query='SELECT * from uList where user = :user'; + $this->con->executeQuery($query, array( + ':user' => array($user,PDO::PARAM_STR) + )); + + $results = $this->con->getResults(); + foreach($results as $row){ + $tabLists[]= new ListTask($row[0],$row[1],$row[2],$row[3]); + } + return $tabLists; + } + + public function findListTask($list){ + $query='SELECT * from Tache where idList = :idList'; + + $this->con->executeQuery($query, array( + ':idList' => array($list->get_id(),PDO::PARAM_STR) + )); + + $results = $this->con->getResults(); + + foreach($results as $row){ + $taches[]= new Task($row['id'],$row['titre'],$row['description'],$row['priorite'], + $row['idList'],$row['dateDebut'],$row['dateFin'],$row['isDone']); + } + $list->set_taches($taches); + return $list; + } } ?> diff --git a/model/TaskModel.php b/model/TaskModel.php index 7554801..99d53af 100644 --- a/model/TaskModel.php +++ b/model/TaskModel.php @@ -60,7 +60,19 @@ class TaskModel function loadPublicLists() { - return $this->gtw->find('list','user','NULL'); + return $this->gtw->find('list','user','NULL'); // is null!! + // requete avec jointure pour optimizer requete + } + + function loadPrivateLists($user){ + # prend toutes les listes de l'user + $lists = $this->gtw->findUserList($user); + + # pour chacune de ses listes, charge les taches + foreach($lists as &$row){ + $row = $this->gtw->findListTask($row); + } + return $lists; } } ?> diff --git a/tests/test.php b/tests/test.php index 966084e..2ed5480 100644 --- a/tests/test.php +++ b/tests/test.php @@ -7,7 +7,7 @@ echo "