Mathilde JEAN 2 years ago
commit bcdd70aec9

BIN
.DS_Store vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@ -1,5 +1,9 @@
<?php <?php
/* -----------
Problème avec l'autoloader
----------- */
class Autoload class Autoload
{ {
private static $_instance = null; private static $_instance = null;
@ -34,10 +38,10 @@ class Autoload
{ {
global $rep; global $rep;
$filename = $class.'.php'; $filename = $class.'.php';
$dir = array('modeles/','./','config/','controleurs/'); $dir = array('./','config/','controleurs/','modeles/Gateways/','modeles/Métier/','modeles/Modele');
foreach ($dir as $d){ foreach ($dir as $d){
$file=$rep.$d.$filename; $file=$rep.$d.$filename;
//echo $file; echo $file;
if (file_exists($file)) if (file_exists($file))
{ {
include $file; include $file;

@ -1,7 +1,7 @@
<?php <?php
class Validation { class Validation {
static function val_connexion($usrName,$mdp,&$dataVueEreur) { static function val_connexion($usrName,$mdp,$dataVueEreur) {
if (!isset($usrName)||$usrName=="") { if (!isset($usrName)||$usrName=="") {
$dataVueEreur[] ="Nom d'utilisateur manquant"; $dataVueEreur[] ="Nom d'utilisateur manquant";
throw new Exception('pas de username'); throw new Exception('pas de username');
@ -10,6 +10,27 @@
$dataVueEreur[] ="Mot de passe manquant"; $dataVueEreur[] ="Mot de passe manquant";
throw new Exception('pas de password'); throw new Exception('pas de password');
} }
return $dataVueEreur;
}
static function val_inscription($username,$pwd1,$pwd2,$dataVueEreur){
if (!isset($username)||$username==="") {
$dataVueEreur[] ="Nom d'utilisateur manquant";
throw new Exception('pas de username');
}
if (!isset($pwd1)||$pwd1==="") {
$dataVueEreur[] ="Mot de passe manquant";
throw new Exception('pas de password');
}
if (!isset($pwd2)||$pwd2==="") {
$dataVueEreur[] ="Confirmation mot de passe manquant";
throw new Exception('pas de confirmation password');
}
if($pwd1 !== $pwd2){
$dataVueEreur[]="Mot de passe et confirmation différents";
throw new Exception("Mot de passe et confirmation différents");
}
return $dataVueEreur;
} }
static function clear_string($champ){ static function clear_string($champ){

@ -3,16 +3,22 @@
//Prefixe //Prefixe
$rep=__DIR__.'/../'; $rep=__DIR__.'/../';
//BD //BD
// ---- $bd['dsn'] = "mysql:host=localhost;port=8888;dbname=dbPhp";
// A CHANGER $bd['user'] = "root";
// ---- $bd['pswd'] = "root";
$base="votre_base";
$login="";
$mdp="";
//Vues //Vues
$vues['acceuil']='vues/acceuil.php'; $vues['acceuil']='vues/acceuil.php';
$vues['erreur']='vues/erreur.php'; $vues['erreur']='vues/erreur.php';
$vues['connection']='vues/connection.php'; $vues['connection']='vues/connection.php';
$vues['inscription']='vues/inscription.php'; $vues['inscription']='vues/inscription.php';
$vues['profile']='vues/profile.php';
$vues['listesPrivees']='vues/listesPrivees.php';
$vues['creationListe']='vues/creationListe.php';
// Styles
$styles['commun']='vues/styles/commonStyles.css';
$styles['connection']='vues/styles/connectionStyle.css';
// Assets
$assets['logo']='assets/chekliste.png';
?> ?>

@ -1,14 +1,18 @@
<?php <?php
class UserController{ class ControleurUtilisateur{
public function __construct() { function __construct() {
global $rep,$vues; global $rep,$vues, $dataView;
$arrayErrorViews= array(); $arrayErrorViews= array();
$action = $_REQUEST['action']??null; $action = $_REQUEST['action']??null;
switch($action){ switch($action){
case "accessPrivateLists":
$this->accessPrivateLists($arrayErrorViews);
case "accessProfilePage":
require($rep.$vues['profile']);
break;
case "deconnection": case "deconnection":
$this->deconnection($arrayErrorViews); $this->deconnection($arrayErrorViews);
break; break;
@ -27,14 +31,16 @@ class UserController{
} }
} }
public function deconnection($arrayErrorViews){ function deconnection($arrayErrorViews){
// appeler la méthode deco du modèle global $rep, $vues, $dataView;
$retour = UserModel::deconnection(); $model = new UserModel();
require($rep.$vues['acceuil']); $retour = $model->deconnection();
$_REQUEST['action']=null;
$control= new ControleurVisiteur();
} }
public function creerListePv($arrayErrorViews){ function creerListePv($arrayErrorViews){
global $rep, $vues; global $rep, $vues, $dataView;
//recupérer les valeurs du formulaire //recupérer les valeurs du formulaire
$nomListe=$_POST['ListName']; $nomListe=$_POST['ListName'];
$privee=$_POST['isPrivate']; $privee=$_POST['isPrivate'];
@ -61,8 +67,8 @@ class UserController{
} }
} }
public function changerPassword($arrayErrorViews){ function changerPassword($arrayErrorViews){
global $rep, $vues; global $rep, $vues, $dataView;
$password1=$_POST['password1']; $password1=$_POST['password1'];
$passwordConfirm=$_POST['passwordConfirm']; $passwordConfirm=$_POST['passwordConfirm'];
$newPassword=Validation::val_changer_password($password1,$passwordConfirm); $newPassword=Validation::val_changer_password($password1,$passwordConfirm);
@ -75,6 +81,13 @@ class UserController{
require($rep.$vues['erreur']); require($rep.$vues['erreur']);
} }
} }
function accessPrivateLists($arrayErrorViews){
global $rep, $vues, $dataView;
$model = new UserModel();
$dataView = $model->pullListesPrivees($_SESSION['login']);
require($rep.$vues['listesPrivees']);
}
} }
?> ?>

@ -1,23 +1,30 @@
<?php <?php
class VisitorController { class ControleurVisiteur {
public function __construct() { public function __construct() {
global $rep,$vues; global $rep,$vues,$styles,$assets;
$arrayErrorViews= array(); $arrayErrorViews= array();
try{ try{
$action = $_REQUEST['action']??null; $action = $_REQUEST['action']??null;
switch($action){ switch($action){
case NULL: case NULL:
$this->reinit(); $this->reinit();
break; break;
case 'accessConnectionPage':
require($rep.$vues['connection']);
break;
case "accessInscription":
require($rep.$vues['inscription']);
break;
case "accessCreationListePage":
require($rep.$vues['creationListe']);
break;
case "connection": case "connection":
$this->connection($arrayErrorViews); $this->connection($arrayErrorViews);
break; break;
case "inscription": case "inscription":
$this->inscription($arrayErrorViews); $this->inscription($arrayErrorViews);
break;
case "creerListe": case "creerListe":
$this->creerListe($arrayErrorViews); $this->creerListe($arrayErrorViews);
break; break;
@ -30,74 +37,88 @@ class VisitorController {
case "cocherTache": case "cocherTache":
$this->cocherTache($arrayErrorViews); $this->cocherTache($arrayErrorViews);
break; break;
case "decocherTache":
$this->decocherTache($arrayErrorViews);
break;
case "supprTache": case "supprTache":
$this->supprTache($arrayErrorViews); $this->supprTache($arrayErrorViews);
default : default :
$arrayErrorViews[]="Erreur innatendue !!!"; $arrayErrorViews[]="Erreur innatendue !!!";
require($rep.$vues['error']); require($rep.$vues['acceuil']);
} }
} catch(PDOException $e){ } catch(PDOException $e){
$dataView[]="Erreur inatendue"; $dataView[]="Erreur inatendue";
require('erreur.php'); require(__DIR__.'/../vues/erreur.php');
} }
exit(0); exit(0);
} }
public function reinit(){ public function reinit(){
global $rep,$vues; global $rep,$vues,$dataView;
require($rep.$vues['acceuil.php']); $model = new VisiteurModel();
$dataView = $model->pullPublicLists();
require($rep.$vues['acceuil']);
} }
public function connection(array $vues_erreur){ public function connection(array $vues_erreur){
global $rep,$vues; global $rep,$vues,$dataView;
$usrname=$_POST['login']; $usrname=$_POST['login'];
$pwd=$_POST['mdp']; $pwd=$_POST['mdp'];
Validation::clear_string($pwd); Validation::clear_string($pwd);
Validation::val_connexion($usrname,$pwd,$vues_erreur); Validation::val_connexion($usrname,$pwd,$vues_erreur);
$model= new VisiteurModel();
$model = new VisiteurModel(); if($model->existUser($usrname)){
$worked=$model->connexion(); if(password_verify($pwd,$model->getHashedPassword($usrname))){
/* Utiliser si jamais connexion n'a pas marché et qu'on veut remettre le login dans la page pour que le visiteur n'ait pas à le retaper $model->connexion($usrname);
$dVue = array ( $_REQUEST['action']=null;
'username' => $usrname, $this->reinit();
); }
*/ else{
if($worked==false){ $arrayErrorViews =array('username'=>$usrname,'password'=>$pwd);
require('erreur.php'); require($rep.$vues['erreur']);
}
}
else{
$arrayErrorViews =array('username'=>$usrname,'password'=>$pwd);
require($rep.$vues['erreur']);
} }
} }
public function inscription(array $vues_erreur){ public function inscription(array $vues_erreur){
global $rep,$vues; global $rep,$vues,$dataView;
require($rep.$vues['inscription']); $usrname=$_POST['username'];
$pwd=$_POST['password'];
$usrname=$_POST['login']; $confirm=$_POST['confirmpassword'];
$pwd=$_POST['mdp']; $vues_erreur=Validation::val_inscription($usrname,$pwd,$confirm,$vues_erreur);
Validation::val_connexion($usrname,$pwd,$vues_erreur); if($vues_erreur == []){
$hash= password_hash($pwd,PASSWORD_DEFAULT);
$model = new VisiteurModel(); $model = new VisiteurModel();
$model->inscription(); $model->inscription($usrname,$hash);
}
$_REQUEST['action']=null;
new ControleurVisiteur();
} }
public function creerListe(array $vues_erreur){ public function creerListe(array $vues_erreur){
global $rep, $vues; global $rep, $vues;
require($rep.$vues['creationListe']); $nom=$_POST['name'];
$model = new ListeModel();
$nom=$_POST['nom']; if(isset($_SESSION['login'])){
foreach($_POST['private'] as $valeur){
$model = new VisiteurModel(); $private=$valeur;
$model->creerListe($nom); $model->creerListe($nom,$private);
}
}
else{
$model->creerListe($nom,null);
}
$_REQUEST['action']=null;
$this->reinit();
} }
public function supprListe(array $vues_erreur){ public function supprListe(array $vues_erreur){
global $rep, $vues; global $rep, $vues;
require($rep.$vues['suppressionListe']); require($rep.$vues['suppressionListe']);
$model = new VisiteurModel(); $model = new ListeModel();
$model->supprListe(); $model->supprListe();
} }
@ -107,39 +128,9 @@ class VisitorController {
$intitule = $_POST['intitule']; $intitule = $_POST['intitule'];
$model = new VisiteurModel(); $model = new ListeModel();
$model->creerTache(); $model->creerTache();
} }
public function cocherTache(array $vues_erreur){
global $rep, $vues;
require($rep.$vues['liste']);
$id = $_POST['idTache'];
$model = new VisiteurModel();
$model->cocherTache($id);
}
public function decocherTache(array $vues_erreur){
global $rep, $vues;
require($rep.$vues['liste']);
$id = $_POST['idTache'];
$model = new VisiteurModel();
$model->decocherTache($id);
}
public function supprTache(array $vues_erreur){
global $rep, $vues;
require($rep.$vues['liste']);
$id = $_POST['idTache'];
$model = new VisiteurModel();
$model->supprTache($id);
}
} }
?> ?>

@ -1,28 +1,24 @@
<?php <?php
require('ControleurUtilisateur.php');
require('ControleurVisiteur.php');
class FrontControleur{ class FrontControleur{
public function __construct(){ public function __construct(){
//On démarre la session $liste_actions_utilisateur = array('accessPrivateLists','accessProfilePage','deconnection','crerListePv','desinscription','changerPassword');
$liste_actions_visiteur = array('accessCreationListePage','accessInscription','accessConnectionPage','creerListe','suprrListe','connection','inscription','creerTache','cocherTache','supprTache');
global $rep,$vues,$bd,$dataView,$styles,$assets;
session_start(); session_start();
$liste_actions_utilisateur = array('deconnection','crerListePv','desinscription','changerPassword');
$liste_actions_visiteur = array('creerListe','suprrListe','connection','inscription','creerTache','cocherTache','supprTache');
global $rep,$vues;
try{ try{
$action = isset($_REQUEST['action']) ? (string)$_REQUEST['action']: null; $user=$_SESSION??null;
$action = !empty($_REQUEST['action']) ? (string)$_REQUEST['action']:null;
if (in_array($action,$liste_actions_utilisateur)){ if (in_array($action,$liste_actions_utilisateur)){
if( !isset($_SESSION['login'])){ if($user == null){
new VisitorController(); new ControleurVisiteur();
} else { } else {
new UserController(); new ControleurUtilisateur();
} }
} else{ } else{
new VisiteurController(); new ControleurVisiteur();
} }
} catch (Exception $e){require ($rep.$vues['erreur']);} } catch (Exception $e){require ($rep.$vues['erreur']);}
} }

@ -1,14 +1,32 @@
<?php <?php
require_once(__DIR__.'/controleurs/FrontControleur.php');
// Chargement config // Chargement config
require_once(__DIR__.'/config/config.php'); require_once(__DIR__.'/config/config.php');
// Autoload des classes // Autoload des classes
require_once(__DIR__.'/config/Autoload.php'); //require_once(__DIR__.'/config/Autoload.php');
Autoload::charger(); //Autoload::charger();
require_once(__DIR__.'/config/Validation.php');
require_once(__DIR__.'/controleurs/ControleurUtilisateur.php');
require_once(__DIR__.'/controleurs/ControleurVisiteur.php');
require_once(__DIR__.'/controleurs/FrontControleur.php');
require_once(__DIR__.'/modeles/Gateways/Connection.php');
require_once(__DIR__.'/modeles/Gateways/ListeGateway.php');
require_once(__DIR__.'/modeles/Gateways/UserGateway.php');
require_once(__DIR__.'/modeles/Métier/Liste.php');
require_once(__DIR__.'/modeles/Métier/Tache.php');
require_once(__DIR__.'/modeles/Métier/Utilisateur.php');
require_once(__DIR__.'/modeles/Modele/UserModel.php');
require_once(__DIR__.'/modeles/Modele/VisiteurModel.php');
require_once(__DIR__.'/modeles/Modele/ListModel.php');
// Construction du controleur // Construction du controleur
$cont=new FrontControleur(); //$cont=new FrontControleur();
$cont= new FrontControleur();
?> ?>

@ -9,38 +9,81 @@ class ListeGateway {
$this->co = $co; $this->co = $co;
} }
public function getByCreator(int $idUsr) : array { public function getPublicLists():array{
$listes = null; $listes = array();
$taches = null; $taches = null;
if(!empty($idUsr)){ try {
try { $co = $this->co;
$co = $this->co;
$query = "SELECT idListe FROM HasList WHERE idUser=:idUser"; $query = "SELECT * FROM Liste WHERE nomCreateur IS NULL";
$co->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR))); $co->executeQuery($query, []);
$results = $co->getResults(); $results = $co->getResults();
Foreach($results as $row){ foreach($results as $row){
$idListe = $row['idListe']; $idListe = $row['id'];
$queryTaches = "SELECT t.* FROM Tache t, HasTache h WHERE t.id=h.idTache AND h.idListe=:idListe"; $queryTaches = "SELECT * FROM Tache WHERE idListe=:idListe";
$co->executeQuery($queryTaches, array(':idListe' => array($idListe, PDO::PARAM_STR))); $co->executeQuery($queryTaches, array(':idListe' => array($idListe, PDO::PARAM_INT)));
$resultsTaches = $co->getResults(); $resultsTaches = $co->getResults();
Foreach($resultsTaches as $rowTaches){ foreach($resultsTaches as $rowTaches){
$taches[] = new Tache($rowTaches['id'], $rowTaches['intitule'], $rowTaches['isCompleted'], $rowTaches['description']); if($rowTaches['complete']=="0"){
$taches[] = new Tache($rowTaches['id'], $rowTaches['nom'],false,$idListe);
}else{
$taches[] = new Tache($rowTaches['id'], $rowTaches['nom'],true,$idListe);
} }
$listes[] = new Liste($row['id'], $row['nom'], $taches);
$taches = null;
} }
$listes[] = new Liste($row['id'], $row['nom'],null, $taches);
$taches = null;
} }
catch(PDOException $Exception) { }
echo 'erreur'; catch(PDOException $Exception) {
echo $Exception->getMessage(); echo 'erreur';
echo $Exception->getMessage();
}
return $listes;
}
public function getByCreator(string $usr) : array {
$listes = array();
$taches = null;
try {
$co = $this->co;
$query = "SELECT * FROM Liste WHERE nomCreateur=:nomCrea";
$co->executeQuery($query, array('nomCrea' => array($usr, PDO::PARAM_STR)));
$results = $co->getResults();
foreach($results as $row){
$idListe = $row['id'];
$queryTaches = "SELECT * FROM Tache WHERE idListe=:idListe";
$co->executeQuery($queryTaches, array(':idListe' => array($idListe, PDO::PARAM_INT)));
$resultsTaches = $co->getResults();
foreach($resultsTaches as $rowTaches){
if($rowTaches['complete']=="0"){
$taches[] = new Tache($rowTaches['id'], $rowTaches['nom'],false,$idListe);
}else{
$taches[] = new Tache($rowTaches['id'], $rowTaches['nom'],true,$idListe);
}
}
$listes[] = new Liste($row['id'], $row['nom'],$usr, $taches);
$taches = null;
} }
} }
catch(PDOException $Exception) {
echo 'erreur';
echo $Exception->getMessage();
}
return $listes; return $listes;
} }
@ -92,31 +135,15 @@ class ListeGateway {
} }
} }
public function decocherTache(int $id){ public function creerListe(string $nom, ?string $nomCreator){
if(!empty($id)){
try{
$co = $this->co;
$query = "UPDATE Tache SET isCompleted=false WHERE id=:id";
$co->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR)));
}
catch(PDOException $Exception){
echo 'erreur';
echo $Exception->getMessage();
}
}
}
public function creerListe(string $nom, int $idCreator){
try{ try{
$co = $this->co; $co = $this->co;
$insertQuery = "INSERT INTO Liste VALUES (NULL, :nom, :idCreator)"; $insertQuery = "INSERT INTO Liste VALUES (NULL, :nom, :nomCreator)";
$co->executeQuery($insertQuery, array('nom' => array($nom, PDO::PARAM_STR), $co->executeQuery($insertQuery, array('nom' => array($nom, PDO::PARAM_STR),
'idCreator' => array($idCreator, PDO::PARAM_INT))); 'nomCreator' => array($nomCreator, PDO::PARAM_STR)));
} }
catch(PDOException $Exception){ catch(PDOException $Exception){
echo 'erreur'; echo 'erreur';

@ -1,32 +1,50 @@
<?php <?php
require_once("Connection.php");
require_once("Utilisateur.php");
class UserGateway { class UserGateway {
private $co; private $co;
public function __construct(Connection $co) { function __construct(Connection $co) {
$this->co = $co; $this->co = $co;
} }
public function creerUtilisateur(string $nom, string $pwd){ function getUtilisateurNom(string $usr){
if(!empty($id) && !empty($nom) && empty($password)){ $co=$this->co;
try{ $query="SELECT nom FROM Utilisateur WHERE nom=:nom";
$co = $this->co; $co->executeQuery($query,array('nom'=>array($usr,PDO::PARAM_STR)));
return $co->getResults();
$query = "INSERT INTO Utilisateur VALUES (NULL, :nom, :pwd)"; }
$co->executeQuery($query, array(':nom' => array($nom, PDO::PARAM_STR), ':pwd' => array($pwd, PDO::PARAM_STR))); function getHashedPassword(string $usrname):?string{
} $hashedPwd=null;
catch(PDOException $Excception){ $co=$this->co;
echo 'erreur'; $query="SELECT pwd FROM Utilisateur WHERE nom=:nom";
echo $Exception->getMessage(); $co->executeQuery($query,array('nom'=>array($usrname,PDO::PARAM_STR)));
} $res=$co->getResults();
foreach($res as $row){
$hashedPwd=$row['pwd'];
} }
return $hashedPwd;
} }
public function delUtilisateur(int $id){ function creerUtilisateur(string $nom, string $pwd){
try{
$co = $this->co;
$query = "INSERT INTO Utilisateur VALUES (:nom, :pwd)";
$co->executeQuery($query, array(':nom' => array($nom, PDO::PARAM_STR), ':pwd' => array($pwd, PDO::PARAM_STR)));
}
catch(PDOException $Exception){
echo 'erreur';
echo $Exception->getMessage();
return false;
}
return true;
}
function delUtilisateur(int $id){
if(!empty($id)){ if(!empty($id)){
try{ try{
$co = $this->co; $co = $this->co;
@ -42,7 +60,7 @@ class UserGateway {
} }
} }
public function putUtilisateur(Utilisateur $usr){ function putUtilisateur(Utilisateur $usr){
if(!empty($usr.getId()) && !empty($usr.getNom()) && empty($usr.getPassword())){ if(!empty($usr.getId()) && !empty($usr.getNom()) && empty($usr.getPassword())){
try{ try{
$co = $this->co; $co = $this->co;
@ -66,7 +84,7 @@ class UserGateway {
} }
} }
public function getUtilisateurById(int $id) : Utilisateur { function getUtilisateurById(int $id) : Utilisateur {
$usr = null; $usr = null;
if(!empty($id)){ if(!empty($id)){
try{ try{
@ -78,7 +96,7 @@ class UserGateway {
$results = $co->getResults(); $results = $co->getResults();
Foreach($results as $row){ foreach($results as $row){
$usr = new Utilisateur($row['id'], $row['nom'], $row['pwd']); $usr = new Utilisateur($row['id'], $row['nom'], $row['pwd']);
} }
} }
@ -91,27 +109,32 @@ class UserGateway {
return $usr; return $usr;
} }
public function getUtilisateurbyNameAndPassword(string $nom, string $pwd) : Utilisateur { function getUtilisateurbyName(string $nom) : ?Utilisateur {
$usr = null; $usr = null;
if(!empty($nom) && !empty($password)){ $tabList= null;
try{ try{
$co = $this->co; $co = $this->co;
$query = "SELECT * FROM Utilisateur WHERE nom=:nom AND pwd=:pwd"; $queryLists="SELECT id, nom FROM Liste WHERE nomCreateur=:nomCrea";
$queryUser = "SELECT * FROM Utilisateur WHERE nom=:nom";
$co->executeQuery($query, array(':nom' => array($nom, PDO::PARAM_STR), ':pwd' => array($pwd, PDO::PARAM_STR))); $co->executeQuery($queryLists,array('nomCrea'=>array($nom,PDO::PARAM_STR)));
$res = $co->getResults();
foreach($res as $row){
$tabList[]= new Liste($row['id'],$row['nom'],$nom,array());
}
$co->executeQuery($queryUser, array('nom' => array($nom, PDO::PARAM_STR)));
$results = $co->getResults(); $results = $co->getResults();
Foreach($results as $row){ foreach($results as $row){
$usr = new Utilisateur($row['id'], $row['nom'], $row['pwd']); $usr = new Utilisateur($row['nom'], $row['pwd'],$tabList);
}
}
catch(PDOException $Exception){
echo 'erreur';
echo $Exception->getMessage();
} }
} }
catch(PDOException $Exception){
echo 'erreur';
echo $Exception->getMessage();
}
return $usr; return $usr;
} }

@ -0,0 +1,25 @@
<?php
class ListeModel{
public $listgw;
function __construct(){
global $rep,$vues,$bd;
$co = new Connection($bd['dsn'],$bd['user'],$bd['pswd']);
$this->listgw = new ListeGateway($co);
}
function creerListe(string $nom, $private){
if(isset($_SESSION['login'])){
if($private="on"){
$this->listgw->creerListe($nom,$_SESSION['login']);
}else{
$this->listgw->creerListe($nom,null);
}
}else{
$this->listgw->creerListe($nom,null);
}
}
}
?>

@ -4,29 +4,35 @@ class UserModel{
public $listgw; public $listgw;
public $usergw; public $usergw;
public function __construct(){ function __construct(){
$co = new Connection(); global $rep,$vues,$bd;
$co = new Connection($bd['dsn'],$bd['user'],$bd['pswd']);
$this->usergw = new UserGateway($co); $this->usergw = new UserGateway($co);
$this->listgw = new ListeGateway($co); $this->listgw = new ListeGateway($co);
} }
public function deconnection(){ function deconnection(){
session_unset(); session_unset();
session_destroy(); session_destroy();
$_SESSION = array(); $_SESSION = array();
} }
public function creerListePv($nom,$idCeator){ function creerListePv($nom,$idCeator){
$this->listgw->creerListe($nom,$idCreator); $this->listgw->creerListe($nom,$idCreator);
} }
public function desinscription($login){ function desinscription($login){
$this->usergw->delUtilisateur($login); $this->usergw->delUtilisateur($login);
} }
public function changerPassword($newPassword){ function changerPassword($newPassword){
$this->usergw->putPassword($newPassword); $this->usergw->putPassword($newPassword);
} }
function pullListesPrivees($nom){
$listes=$this->listgw->getByCreator($nom);
return $listes;
}
} }
?> ?>

@ -1,39 +1,42 @@
<?php <?php
class VisiteurModel { class VisiteurModel {
private $gtwUsr; public $gtwUsr;
private $gtwListe; public $gtwListe;
public function __construct() { public function __construct() {
$co = new Connection(); global $rep,$vues,$bd;
$co = new Connection($bd['dsn'],$bd['user'],$bd['pswd']);
$this->gtwUsr = new UserGateway($co); $this->gtwUsr = new UserGateway($co);
$this->gtwListe = new ListeGateway($co); $this->gtwListe = new ListeGateway($co);
} }
public function get_gtwUsr(): UserGateway { public function getHashedPassword(string $usr){
return $this->gtwUsr; return $this->gtwUsr->getHashedPassword($usr);
} }
public function get_gtwListe(): ListeGateway { public function existUser(string $usr):bool{
return $this->gtwListe; if($this->gtwUsr->getUtilisateurNom($usr) != null){
}
public function connexion($login, $mdp){
$results = $this->get_gtwUsr()->getUtilisateurbyNameAndPassword($login, $mdp);
if ($results != NULL){
$_SESSION['role'] = 'user';
$_SESSION['login'] = $login;
return true; return true;
} }
return false; return false;
} }
public function inscription($login, $mdp){ public function connexion($login){
$this->get_gtwUsr()->creerUtilisateur($login, $mdp); $_SESSION['role'] = 'Utilisateur';
$_SESSION['login'] = $login;
} }
public function creerListe($nom) { public function pullPublicLists(){
$this->get_gtwListe()->creerListe($nom, NULL); return $this->gtwListe->getPublicLists();
}
public function inscription($login, $mdp){
$result=$this->gtwUsr->creerUtilisateur($login, $mdp);
if ($result ==true){
$_SESSION['role'] = 'Utilisateur';
$_SESSION['login'] = $login;
}
} }
public function supprListe($id) { public function supprListe($id) {
@ -43,18 +46,6 @@
public function creerTache(string $intitule){ public function creerTache(string $intitule){
$this->get_gtwListe()->creerTache($intitule); $this->get_gtwListe()->creerTache($intitule);
} }
public function cocherTache($id){
$this->get_gtwListe()->completeTache($id);
}
public function decocherTache($id){
$this->get_gtwListe()->decocherTache($id);
}
public function supprTache($id){
$this->get_gtwListe()->delTache($id);
}
} }
?> ?>

@ -1,27 +1,17 @@
<?php <?php
class Liste { class Liste {
private int $id; public int $id;
private string $nom; public string $nom;
private int $idCreator; public ?string $nomCreateur;
public ?array $taches;
function __construct(int $i, string $n, $t){ function __construct(int $i, string $n, ?string $nomCrea,?array $t){
$this->id=$i; $this->id=$i;
$this->nom=$n; $this->nom=$n;
$this->nomCreateur=$nomCrea;
$this->taches=$t; $this->taches=$t;
} }
function get_id(): int {
return $this->id;
}
function get_nom(): string {
return $this->nom;
}
function get_idCreator(): array {
return $this->taches;
}
} }
?> ?>

@ -1,31 +1,16 @@
<?php <?php
Class Tache { Class Tache {
private int $id; public int $id;
private string $intitule; public string $nom;
private boolean $isCompleted; public bool $isCompleted;
private int $idListe; public int $idListe;
function __construct(int $i, string $in, boolean $is){ function __construct(int $i, string $in, bool $is, int $idListe){
$this->id = $i; $this->id = $i;
$this->intitule = $in; $this->nom = $in;
$this->isCompleted = $is; $this->isCompleted = $is;
} $this->idListe=$idListe;
function get_id(): int {
return $this->id;
}
function get_intitule(): string {
return $this->intitule;
}
function get_isCompleted(): boolean {
return $this->isCompleted;
}
function get_idListe(): string {
return $this->idListe;
} }
} }

@ -1,13 +1,11 @@
<?php <?php
Class Utilisateur { Class Utilisateur {
private int $id;
private string $nom; private string $nom;
private string $password; private string $password;
private $listListe; private $listListe;
function __construct(int $i, string $n, string $p, $liste) { function __construct(string $n, string $p, $liste) {
$this->id=$i;
$this->nom=$n; $this->nom=$n;
$this->password=$p; $this->password=$p;
$this->listListe=$liste; $this->listListe=$liste;

BIN
vues/.DS_Store vendored

Binary file not shown.

@ -8,17 +8,58 @@
<body> <body>
<header> <header>
<h1>Welcome to our fantastic to do list app !</h1> <h1>Welcome to our fantastic to do list app !</h1>
<form method="post" name="connection"> <?php
<a href='vues/connection.php'> if(!isset($_SESSION['login'])){
<input class="button" type="button" value="Connection"/> echo '
</a> <div>
<form method="post" name="connection" id="connection">
<input class="button" type="submit" value="Connection"/>
<input type="hidden" name="action" value="accessConnectionPage"/>
</form> </form>
</div>';
}
else{
echo'
<div>
<form method="post" name="profil" id="profil">
<input class="button" type="submit" value="Profile"/>
<input type="hidden" name="action" value="accessProfilePage"/>
</form>
</div>';
}?>
</header> </header>
<?php if(isset($_SESSION['login'])){
echo '
<div>
<form method="post" name="listesPv" id="listesPv">
<input class="button" type="submit" value="Access private lists"/>
<input type="hidden" name="action" value="accessPrivateLists"/>
</form>
</div>';
}?>
<div> <div>
<h2>Todo listes publiques</h2> <h2>Public Lists</h2>
<?php
if(isset($dataView)) {
foreach ($dataView as $liste){
echo $liste->nom;
echo '<br/>';
if($liste->taches != null){
foreach($liste->taches as $tache){
echo ' * '.$tache->nom;
echo '<br/>';
}
}
}
}
?>
<div>
<form method="post" name="createList" id="createList">
<input class="button" type="submit" value="Create List"/>
<input type="hidden" name="action" value="accessCreationListePage"/>
</form>
</div>
</div> </div>
<article>
</article>
</body> </body>
</html> </html>

@ -9,19 +9,25 @@
<h1>You are back ?!</h1> <h1>You are back ?!</h1>
</header> </header>
<div> <div>
<h4>Username</h4> <form method="POST" name="connectionForm" id="connectionForm">
<input type="text" name="login"/> <p>Login
<h4>Password</h4> <input type="text" name="login" required/></p>
<input type="password" name="mdp"/> <p>Password
<input type="password" name="mdp" required/></p>
<br/>
<br/>
<input class="button" type="submit" value="Log In"/>
<input type="hidden" name="action" value="connection">
</form>
<br/> <br/>
<br/> <br/>
<input class="button" type="button" value="Log In"/> </div>
<br/> <div>
<br/> <form method="POST" name="accessInscription" id="accesInscription">
<p>You are new here?</p> <h2>You are new here?</h2>
<a href="inscription.php"> <input class="button" type="submit" value="Sign Up"/>
<input class="button" type="button" value="Sign Up"/> <input type="hidden" name="action" value="accessInscription">
</a> </form>
</div> </div>
</body> </body>
</html> </html>

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<body>
<div>
<h3>Create a new list</h3>
<form method="POST" name="creaListe" id="creaListe">
<p>Name of the liste
<input type="text" name="name" id="name" required/></p>
<?php
if(isset($_SESSION['login'])){
echo '<input type="checkbox" id="private" name="private[]">
<label for="private">Private List?</label>';
}
?>
<input class="button" type="submit" value="Create List"/>
<input type="hidden" name="action" value="creerListe"/>
</form>
</div>
</body>
</html>

@ -10,18 +10,18 @@
</header> </header>
<div> <div>
<p>Please enter all the informations :</p> <form method="POST" name="inscription" id="inscription">
<h4>Username</h4> <h2>Please enter all the informations :</h2>
<input type="text" name="login"/> <p>Login
<h4>Password</h4> <input type="text" name="username" required/></p>
<input type="password" name="mdp"/> <p>Password
<h4>Email</h4> <input type="password" name="password" required/></p>
<input type="email"/> <p>Confirm Password
<h4>Date Of Birth</h4> <input type="password" name="confirmpassword" required/></p>
<input type="date"/> <br/>
<br/> <input class="button" type="submit" value="Sign Up"/>
<br/> <input type="hidden" name="action" value="inscription"/>
<input class="button" type="button" value="Sign Up"/> </form>
</div> </div>
</body> </body>
</html> </html>

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<body>
<div>
<h2>Private Lists</h2>
<?php
if (isset($dataView)) {
foreach ($dataView as $liste){
echo $liste->nom;
echo '<br/>';
if($liste->taches != null){
foreach($liste->taches as $tache){
echo ' * '.$tache->nom;
echo '<br/>';
}
}
}
}
?>
</div>
</body>
</html>

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<body>
<h2>What you wanna young padawan?</h2>
<div>
<form method="POST" name="deconnection">
<input class="button" type="submit" value="Déconnection"/>
<input type="hidden" name="action" value="deconnection"/>
</form>
</div>
<div>
<form method="POST" name="desincription">
<input class="button" type="submit" value="Desinscription"/>
<input type="hidden" name="action" value="desinscription"/>
</form>
</div>
</body>
</html>

Binary file not shown.

@ -0,0 +1,33 @@
html,
body {
height: 100%;
}
body {
display: flex;
align-items: center;
padding-top: 40px;
padding-bottom: 40px;
background-color: #f5f5f5;
}
.form-signin {
max-width: 330px;
padding: 15px;
}
.form-signin .form-floating:focus-within {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
Loading…
Cancel
Save