Mathilde JEAN 2 years ago
commit ec05e97a74

BIN
.DS_Store vendored

Binary file not shown.

@ -1,6 +1,6 @@
<?php <?php
class UserController extends VisitorController{ class UserController{
public function __construct() { public function __construct() {
global $rep,$vues; global $rep,$vues;
@ -10,30 +10,63 @@ class UserController extends VisitorController{
try{ try{
$action = $_REQUEST['action']??null; $action = $_REQUEST['action']??null;
/*
switch($action){ switch($action){
case NULL:
$this->Reinit();
break;
case "deconnection": case "deconnection":
$this->deconnection($arrayErrorViews); $this->deconnection($arrayErrorViews);
break; break;
case "creerListe": case "creerListePv":
$this->creerListe($arrayErrorViews); $this->creerListe($arrayErrorViews);
break; break;
case "supprListe": case "desinscription":
$this->supprListe($arrayErrorViews); $this->desinctription($arrayErrorViews);
break;
case "changerInfos":
$this->changerInfos($arrayErrorViews);
break; break;
default : default :
$arrayErrorViews[]="Erreur innatendue !!!"; $arrayErrorViews[]="Erreur innatendue !!!";
require($rep.$vues['error']); require($rep.$vues['error']);
} }
*/
}catch(PDOException $e){ }catch(PDOException $e){
$dataView[]="Erreur inatendue"; $dataView[]="Erreur inatendue";
require(__DIR__.'/../vues/erreur.php'); require($rep.$vues['erreur']);
}
}
public function deconnection($arrayErrorViews){
// appeler la méthode deco du modèle
UserModel::deconnection();
}
public function creerListePv($arrayErrorViews){
global $rep, $vues;
//recupérer les valeurs du formulaire
$nomListe=$_POST['ListName'];
$privee=$_POST['isPrivate'];
// valider les champs
Validation::val_creation_Liste_PV($nomListe, $arrayErrorViews);
// vider les champs
//Validation::clear_string($_POST['ListName']);
// appelle à la methode du modèle
if($privee == true){
UserModel::creerListePv($nomListe,$_SESSION['login']);
}else{
VisitorModel::creerListe($nomListe);
} }
} }
public function desinscription($arrayErrorViews){
global $rep, $vues;
// recup valeurs des champs
$password=$_POST['password'];
// valider les champs
Validation::val_desinscription($password);
// vider les champs
//Validation::clear_string($_POST['password']);
// appel à la classe userModel
UserModel::desinscription($_SESSION['login']);
}
} }
?> ?>

@ -40,10 +40,6 @@ class VisitorController {
} catch(PDOException $e){ } catch(PDOException $e){
$dataView[]="Erreur inatendue"; $dataView[]="Erreur inatendue";
require(__DIR__.'/../vues/erreur.php'); require(__DIR__.'/../vues/erreur.php');
} catch (Exception $e2)
{
$dVueEreur[] = "Erreur inattendue!!! ";
require ($rep.$vues['erreur']);
} }
exit(0); exit(0);
} }

@ -3,8 +3,24 @@
class FrontControleur{ class FrontControleur{
public function __construct(){ public function __construct(){
$liste_actions_utilisateur = array('deconnection','crerListePv','desinscription','changerInfos');
$liste_actions_visiteur = array('creerListe','suprrListe','connection','inscription','creerTache','cocherTache','supprTache');
global $rep,$vues; global $rep,$vues;
require($rep.$vues['acceuil']); require($rep.$vues['acceuil']);
try{
$utilisateur = UserModel::IsUtilisateur();
$action = $_REQUEST['action'];
if (in_array($action,$liste_actions_utilisateur)){
if($utilisateur == null){
new VisitorController();
} else {
new UserController();
}
} else{
new VisitorController();
}
} catch (Exception $e){require ($rep.$vues['erreur']);}
} }
} }

@ -92,21 +92,22 @@ class ListeGateway {
} }
} }
public function creerListe(string $nom, string $idCreateur){ public function creerListe(string $nom, int $idCreator){
if(!empty($id) && !empty($nom)){
try{ try{
$co = $this->co; $co = $this->co;
$query = "INSERT INTO Liste VALUES (NULL, :nom)"; $insertQuery = "INSERT INTO Liste VALUES (NULL, :nom, :idCreator)";
$co->executeQuery($query, array(':nom' => array($nom, PDO::PARAM_STR)));
$co->executeQuery($insertQuery, array('nom' => array($nom, PDO::PARAM_STR),
'idCreator' => array($idCreator, PDO::PARAM_INT)));
} }
catch(PDOException $Exception){ catch(PDOException $Exception){
echo 'erreur'; echo 'erreur';
echo $Exception->getMessage(); echo $Exception->getMessage();
} }
} }
}
public function delListe(int $id){ public function delListe(int $id){
if(!empty($id)){ if(!empty($id)){
@ -123,7 +124,6 @@ class ListeGateway {
} }
} }
} }
} }
?> ?>

@ -0,0 +1,28 @@
<?php
class UserModel{
public $listgw;
public $usergw;
public function __construct(){
$co = new Connection();
$this->usergw = new UserGateway($co);
$this->listgw = new ListeGateway($co);
}
public function deconnection(){
session_unset();
session_destroy();
$_SESSION = array();
}
public function creerListePv($nom,$idCeator){
$this->listgw->creerListe($nom,$idCreator);
}
public function desinscription($login){
$this->usergw->delUtilisateur($login);
}
}
?>

@ -0,0 +1,13 @@
<?php
class VisitorModel{
public $gw;
public function __construct(){
$co = new Connection();
$this->gw = new ListeGateway($co);
}
}
?>

@ -3,7 +3,7 @@
class Liste { class Liste {
private int $id; private int $id;
private string $nom; private string $nom;
private $taches; private int $idCreator;
function __construct(int $i, string $n, $t){ function __construct(int $i, string $n, $t){
$this->id=$i; $this->id=$i;
@ -19,7 +19,7 @@ class Liste {
return $this->nom; return $this->nom;
} }
function get_taches(): array { function get_idCreator(): array {
return $this->taches; return $this->taches;
} }
} }

@ -4,6 +4,7 @@ Class Tache {
private int $id; private int $id;
private string $intitule; private string $intitule;
private boolean $isCompleted; private boolean $isCompleted;
private int $idListe;
function __construct(int $i, string $in, boolean $is){ function __construct(int $i, string $in, boolean $is){
$this->id = $i; $this->id = $i;
@ -22,6 +23,10 @@ Class Tache {
function get_isCompleted(): boolean { function get_isCompleted(): boolean {
return $this->isCompleted; return $this->isCompleted;
} }
function get_idListe(): string {
return $this->idListe;
}
} }
?> ?>

@ -1,27 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>connection</title>
<link rel="stylesheet" href="styles/commonStyles.css">
</head>
<body>
<header>
<h1>You are back ?!</h1>
</header>
<div>
<h4>Username</h4>
<input type="text"/>
<h4>Password</h4>
<input type="password"/>
<br/>
<br/>
<input type="button" value="Log In"/>
<br/>
<br/>
<p>You are new here?</p>
<a href="./signUp.html">
<input type="button" value="Sign Up"/>
</a>
</div>
</body>
</html>

@ -1,8 +0,0 @@
<!DOCTYPE html>
<html>
<div>
<h3>Error!</h3>
<p>There was an error in the fields you filled...</p>
<p>Please enter correct values</p>
</div>
</html>

@ -1,27 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>connection</title>
<link rel="stylesheet" href="styles/commonStyles.css">
</head>
<body>
<header>
<h1>Join the good side of the force</h1>
</header>
<div>
<p>Please enter all the informations :</p>
<h4>Username</h4>
<input type="text"/>
<h4>Password</h4>
<input type="password"/>
<h4>Email</h4>
<input type="email"/>
<h4>Date Of Birth</h4>
<input type="date"/>
<br/>
<br/>
<input type="button" value="Sign Up"/>
</div>
</body>
</html>

@ -3,14 +3,15 @@
<head> <head>
<title>Acceuil</title> <title>Acceuil</title>
<link rel="stylesheet" href="views/styles/commonStyles.css"> <link rel="stylesheet" href="../vues/styles/commonStyles.css">
</head> </head>
<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"> <form method="post" name="connection">
<a href='vues/connection.php'>
<input class="button" type="button" value="Connection"/> <input class="button" type="button" value="Connection"/>
<input type="hidden" value="connection"/> </a>
</form> </form>
</header> </header>

@ -19,8 +19,8 @@
<br/> <br/>
<br/> <br/>
<p>You are new here?</p> <p>You are new here?</p>
<a class="button" href="./signUp.html"> <a href="inscription.php">
<input type="button" value="Sign Up"/> <input class="button" type="button" value="Sign Up"/>
</a> </a>
</div> </div>
</body> </body>

Loading…
Cancel
Save