generated from Templates_CodeFirst/templateHtmlCss
parent
6a1acab12f
commit
482c558202
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
|
||||
class MdlListe{
|
||||
|
||||
private $con;
|
||||
|
||||
public function __construct(Connection $con){
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
|
||||
public function insert(string $name, bool $private, ?User $creator): Liste{
|
||||
$gate=new ListeGateway($this->con);
|
||||
$l=new Liste(0, $name, $private, $creator, []);
|
||||
$gate->insert($l);
|
||||
$id=$gate->getLastId();
|
||||
$l->setId($id[0]['oldId']);
|
||||
return $l;
|
||||
}
|
||||
|
||||
public function delete(Liste $liste){
|
||||
$gate=new ListeGateway($this->con);
|
||||
$gate->delete($liste);
|
||||
}
|
||||
|
||||
public function update(Liste $liste, string $name, string $content, bool $private){
|
||||
$gate=new ListeGateway($this->con);
|
||||
$liste->setName($name);
|
||||
$liste->setContent($content);
|
||||
if ($liste->getCreator()!=null){
|
||||
$liste->setPrivate($private);
|
||||
}
|
||||
$gate->update($liste);
|
||||
}
|
||||
|
||||
public function findByName(string $name, ?User $u): array{
|
||||
$gate=new ListeGateway($this->con);
|
||||
$gateTache=new TacheGateway($this->con);
|
||||
$results=$gate->findByName($name);
|
||||
$tabListe=[];
|
||||
foreach ($results as $row ) {
|
||||
$tabTache=[];
|
||||
$taches=$gateTache->getTacheFromIdList($row['id']);
|
||||
foreach($taches as $tata){
|
||||
$tabTache[]=new Tache($tata['id'], $tata['name'], $tata['content'], $tata['completed']);
|
||||
}
|
||||
if ($row['private']==false){
|
||||
$tabListe[]=new Liste($row['id'], $row['name'], $row['private'], null, $tabTache);
|
||||
}
|
||||
if ($row['idCreator']==$u->getId()){
|
||||
$tabListe[]=new Liste($row['id'], $row['name'], $row['private'], $u, $tabTache);
|
||||
}
|
||||
}
|
||||
return $tabListe;
|
||||
}
|
||||
|
||||
public function findByUser(User $u): array{
|
||||
$gate=new ListeGateway($this->con);
|
||||
$gateTache=new TacheGateway($this->con);
|
||||
|
||||
$results=$gate->findByUserId($u->getId());
|
||||
$tabListe=[];
|
||||
foreach ($results as $row ) {
|
||||
$tabTache=[];
|
||||
$taches=$gateTache->getTacheFromIdList($row['id']);
|
||||
foreach($taches as $tata){
|
||||
$tabTache[]=new Tache($tata['id'], $tata['name'], $tata['content'], $tata['completed']);
|
||||
}
|
||||
$tabListe[]=new Liste($row['id'], $row['name'], $row['private'], $u, $tabTache);
|
||||
}
|
||||
return $tabListe;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
|
||||
class MdlTache{
|
||||
|
||||
private $con;
|
||||
|
||||
public function __construct(Connection $con){
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
|
||||
public function insert(string $name, string $content ,bool $completed, string $idListe): Tache{
|
||||
$gate=new TacheGateway($this->con);
|
||||
$t=new Tache(0, $name, $content, $completed);
|
||||
$gate->insert($t);
|
||||
$id=$gate->getLastId();
|
||||
$t->setId($id[0]['oldId']);
|
||||
return $t;
|
||||
}
|
||||
|
||||
public function delete(Tache $tache){
|
||||
$gate=new TacheGateway($this->con);
|
||||
$gate->delete($tache);
|
||||
}
|
||||
|
||||
public function update(Tache $tache, string $name, string $content, bool $completed){
|
||||
$gate=new ListeGateway($this->con);
|
||||
$tache->setName($name);
|
||||
$tache->setContent($content);
|
||||
$tache->setCompleted($completed);
|
||||
$gate->update($tache);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
|
||||
class MdlUser{
|
||||
|
||||
private $con;
|
||||
|
||||
public function __construct(Connection $con){
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
public function getUserForConnection(string $username, string $password): ?User{
|
||||
if (!empty($username) && !empty($password)){
|
||||
$results=[];
|
||||
$gate=new UserGateway($this->con);
|
||||
$results=$gate->findByNamePassword($username, $password);
|
||||
if (!empty($results)){
|
||||
$user=new User($results[0]['id'], $results[0]['username'], $results[0]['password']);
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function insert(string $username, string $password): ?User{
|
||||
$gate=new UserGateway($this->con);
|
||||
$results=$gate->findByName($username);
|
||||
if ($results==null){
|
||||
$u=new User(0, $username, $password);
|
||||
$gate->insert($u);
|
||||
$id=$gate->getLastId();
|
||||
$u->setId($id[0]['oldId']);
|
||||
return $u;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function delete(User $user){
|
||||
$gate=new UserGateway($this->con);
|
||||
$gate->delete($user);
|
||||
}
|
||||
|
||||
public function update(User $user, string $username, string $password){
|
||||
$user->setUsername($username);
|
||||
$user->setPassword($password);
|
||||
$gate=new UserGateway($this->con);
|
||||
$gate->update($user);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in new issue