diff --git a/controller/CtrlUser.php b/controller/CtrlUser.php deleted file mode 100644 index b5b97c0..0000000 --- a/controller/CtrlUser.php +++ /dev/null @@ -1,38 +0,0 @@ -Reinit(); - break; - case "validationFormulaire": - $this->ValidationFormulaire($dVueEreur); - break; - //mauvaise action - default: - $dVueEreur[] = "Erreur d'appel php"; - require ($rep.$vues['vuephp1']); - break; - } - } catch (PDOException $e) - { - //si erreur BD, pas le cas ici - $dVueEreur[] = "Erreur inattendue!!! "; - require ($rep.$vues['erreur']); - } - catch (Exception $e2) - { - $dVueEreur[] = "Erreur inattendue!!! "; - require ($rep.$vues['erreur']); - } - exit(0); - } - } - -?> \ No newline at end of file diff --git a/controller/UserCtrl.php b/controller/UserCtrl.php index 063ae51..1dfa5c6 100644 --- a/controller/UserCtrl.php +++ b/controller/UserCtrl.php @@ -1,45 +1,63 @@ con = $con; - $this->model = new UserModel($this->con); - try{ - $action=$_REQUEST['action']; - switch($action){ + $this->userModel = new UserModel($this->con); + $this->taskModel = new TaskModel($this->con); + // try{ + // $action=$_REQUEST['action']; + // switch($action){ - // voir les listes privees - case 'voir_liste_priv': - $this->loadListePriv(); - break; + // // voir les listes privees + // case 'voirListePriv': + // $this->loadListePriv(); + // break; - // ajouter une liste privee - case 'creer_liste_priv': - $this->newListPrivate(); - break; + // // ajouter une liste privee + // case 'creerListePriv': + // $this->newListPrivate(); + // break; + // case 'deconnecter': + // $this->deconnexion(); + // break; - } - } catch(Exception $e) { - require("../view/erreur.php"); - } + // } + // } catch(Exception $e) { + // require("../view/erreur.php"); + // } } public function loadListePriv(){ $name = "Liste privée"; - $TabList = array(); // $TabList[] = new ListTask(0, "Projet PHP"); // $TabList[] = new ListTask(1, "Projet Blazor"); - $TabListPriv = $this->model->getPrivateList(); + $TabList = $this->taskModel->loadPrivateLists($_SESSION['login']); require("../view/liste.php"); } public function newListPrivate(){ $nom=$_POST['listeNom']; - insertL(new ListTask(0, $nom, $_SESSION['login'])); + // $nom = "New List"; + $this->taskModel->addList($nom,$_SESSION['login']); + } + + function loadHome(){ + $user = false; + $public_lists = $this->taskModel->loadPublicLists(); + require("../view/home.php"); + } + + public function deconnexion(){ + $usrModel->deconnexion(); + loadHome(); } } ?> diff --git a/dal/TaskGateway.php b/dal/TaskGateway.php index bcf5695..ab1957a 100644 --- a/dal/TaskGateway.php +++ b/dal/TaskGateway.php @@ -56,6 +56,7 @@ class TaskGateway # une fois pour prendre toutes les listes qui ont l'id de l'user # pour toutes ces listes (foreach), find toutes chaque tache associé public function find($table, $element="", $valeur=""){ + $tabResult = array(); if($table =='task'){ if(strcmp($element,"")==0) { @@ -75,7 +76,7 @@ class TaskGateway $tabTaches[]=new Task($row['titre'],$row['description'],$row['priorite'], $row['idList'],$row['dateDebut'],$row['dateFin'],$row['isDone'],$row['id']); } - return $tabTaches; + return $tabResult; } else if($table == 'list'){ if(strcmp($element,"")==0) @@ -95,10 +96,13 @@ class TaskGateway { $tabList[]=new ListTask($row['nom'],$row['user'],$row['dc'],$row['id']); } - return $tabList; + return $tabResult; } } +// SELECT tache.id FROM Tache tache, Liste liste +// tache.idListe = liste.id AND liste.user IS NULL; + /* # LIST FUNCTIONS */ /*create, update, delete, read(select info)*/ public function insertL(ListTask $l){ @@ -119,7 +123,7 @@ class TaskGateway $this->con->executeQuery($query, array( ':user' => array($user,PDO::PARAM_STR) )); - + $tabLists = array(); $results = $this->con->getResults(); foreach($results as $row){ $tabLists[]= new ListTask($row[1],$row[2],$row[3],$row[0]); @@ -149,6 +153,7 @@ class TaskGateway $query='SELECT * from uList where user is NULL'; $this->con->executeQuery($query); + $tabLists = array(); $results = $this->con->getResults(); foreach($results as $row){ $tabLists[]= new ListTask($row[1],$row[2],$row[3],$row[0]); diff --git a/index.php b/index.php index f35ba96..08ca4c4 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,9 @@ diff --git a/tests/credentials.php b/tests/credentials.php index 9d5efdf..ae601d6 100644 --- a/tests/credentials.php +++ b/tests/credentials.php @@ -1,4 +1,4 @@ diff --git a/tests/test.php b/tests/test.php index 7d368f5..cf707c8 100644 --- a/tests/test.php +++ b/tests/test.php @@ -12,12 +12,12 @@ require_once("../controller/VisitorCtrl.php"); # connection include("credentials.php"); -$con = new Connection('mysql:host=localhost;dbname=phpproject', 'nifranco', 'achanger'); -var_dump($con); +$con = new Connection('mysql:host=localhost;dbname=dbanboudoul', 'anboudoul', 'mdpMYSQL'); # gateway +// $t = new Task(3,'richarlison voltar pro flu','desc.','urgent','0'); // $tgt = new TaskGateway($con); -//$tgt->insert($t); +// $tgt->insertT($t); //$tgt->delete('10'); //$taches = $tgt->findUserList('nifranco'); // foreach($taches as $t){ @@ -25,13 +25,25 @@ var_dump($con); // } # test find -/*$tasks=$tgt->find('idList','001'); -foreach($tasks as $i) - echo $i->get_id()."
"; */ +// $tasks=$tgt->find('idList','001'); +// foreach($tasks as $i) +// echo $i->get_id()."
"; + +# Test du modele Tache +// $mt= new TaskModel($con); +//$mt->addTask('3','testIsDone','desc.','urgent','001'); +//$mt->modifTask('3','isDone','1'); +//$tasks = $mt->getTaskBy('titre','tache1'); +// $tasks = $mt->getAllTask(); +// foreach($tasks as $i) +// echo $i->get_id()."
"; # Test LOAD PRIVATE TASKS $mt= new TaskModel($con); //$mt->addList('private','nifranco'); +# Test LOAD PRIVATE TASKS +// $mt= new TaskModel($con); +// $mt->addList('private','nifranco'); // $lists = $mt->loadPublicLists(); // foreach($lists as $l){ @@ -41,16 +53,20 @@ $mt= new TaskModel($con); // echo $t->get_id()."
"; // } // } +// //$tasks = $mt->getTaskBy('titre','tache1'); +// $tasks = $mt->getAllTask(); +// foreach($tasks as $i) +// echo $i->get_id()."
"; +// $tasks = $mt->loadPublicLists(); +// foreach($tasks as $i) +// echo $i->get_id()."
"; // $mt->addList('002','todo2','nifranco'); // $mt->modifList('2','nom','22do'); //mt->supList('2'); - - -$public_lists = $mt->loadPrivateLists('nifranco'); -$user = true; -//require("../view/newList.php"); -require("../view/home.php"); +// $public_lists = $mt->loadPrivateLists('nifranco'); +// $user = true; +//require("../view/home.php"); //require("../view/register.php"); //require("../view/connection.php"); /* ------------- @@ -72,13 +88,33 @@ require('../controller/UserCtrl.php'); // Test Modèle User -$mu = new UserModel($con); +//$mu = new UserModel($con); //$res = $mu->connexion('nifranco','achanger'); //var_dump($res); +$mdl = new UserModel($con); // $mdl->ajouter('Anna', 'unmdptrescomplique'); // $mdl->modifLogin('Anna', 'Aeryn'); // $mdl->modifMdp('Aeryn', 'wtfmec'); -// $mdl->supprimer('Aeryn'); +// $mdl->supprimer('Aeryn'); +$mdl->connexion('Aeryn', 'wtfmec'); + +$mt->addList("Test Liste"); +$mt->addList("Liste publique"); +$mt->addList("Liste privée", "Aeryn"); +$mt->addList("Projet de PHP", "Aeryn"); +$mt->addList("Projet Blazor", "Aeryn"); +$mt->addList("Projet de PHP", "RicharlisonR9"); +$mt->addList("Projet Blazor", "RicharlisonR9"); + +// TEST USER CONTROLLER + + +session_start(); +$_SESSION['login'] = 'RicharlisonR9'; +$usrctrl = new UserCtrl($con); +$usrctrl->loadHome(); + + ?> diff --git a/view/html/list.html b/view/html/list.html index 7563734..dc58cc5 100644 --- a/view/html/list.html +++ b/view/html/list.html @@ -23,40 +23,28 @@ - - - - - - - - - - - - - - - - - - - - - - - -
TaskImportanceActions
Faire le controlleurUrgent - - -
Finir les vuesMoyen - - -
Gestion des erreursImportant - - - -
+ + + Task + Importance + Actions + + + + + '.$task->get_titre().' + '.$task->get_priorite().' + + + + + '; + } + ?> + + diff --git a/view/liste.php b/view/liste.php index d11235d..0cf1a4c 100644 --- a/view/liste.php +++ b/view/liste.php @@ -1,14 +1,19 @@ - + + + - '; - echo '

'.$name.'

'; - echo '
'; - foreach($TabList as $liste){ - echo ''; - } - echo '
'; -?> \ No newline at end of file + rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" + crossorigin="anonymous"> + + + '.$name.'
'; + echo '
'; + foreach($TabList as $liste){ + echo ''; + } + echo '
'; + ?> + + diff --git a/view/newList.php b/view/newList.php index e363d52..d98fa6e 100644 --- a/view/newList.php +++ b/view/newList.php @@ -1,4 +1,5 @@ +<<<<<<< HEAD @@ -89,4 +90,46 @@ - \ No newline at end of file + +======= + + + + + + +
+
+
+
+
+
+ +

New List

+
+
+
+ +
+
+ +
+ +
+ +
+ +
+
+ +
+
+
+
+
+
+ + +>>>>>>> 7b122c7d82038ee7f446b68857346a652573775c diff --git a/view/task.php b/view/task.php new file mode 100644 index 0000000..dc58cc5 --- /dev/null +++ b/view/task.php @@ -0,0 +1,56 @@ + + + + + + + +
+
+
+
+
+
+ +

My List

+
+ +
+ +
+
+ + + + + + + + + + + + + + + '; + } + ?> + +
TaskImportanceActions
'.$task->get_titre().''.$task->get_priorite().' + + +
+ +
+
+
+
+
+
+ +