Maintenant, tout dans le executor.php. Fin de tempPreMega.

Ajout d'un super simulateur de tours de Monoï dans la page 404.
This commit is contained in:
Mysaa
2021-06-06 12:48:11 +02:00
parent 228f54d140
commit 38ec48c9fc
55 changed files with 1853 additions and 1042 deletions
+37 -13
View File
@@ -6,6 +6,7 @@ class Projet{
protected $dateCreation;
protected $owner;
protected $secondaryOwners;
protected $publik;
protected $valid;
@@ -19,8 +20,9 @@ class Projet{
$this->owner = new Membre($rep['ownerID']);
$this->dateCreation = $rep['dateCreation'];
$this->secondaryOwners = array();
foreach (explode(';',$rep['secondaryOwners']) AS $secondaryOwner)
foreach (explode(';',$rep['secondaryOwnersID']) AS $secondaryOwner)
$this->secondaryOwners[] = new Membre($secondaryOwner);
$this->publik = $rep['public'];
}else{
$this->valid = FALSE;
}
@@ -38,7 +40,7 @@ class Projet{
foreach($this->secondaryOwners AS $secondaryOwner)
$out .= '\tSecondary owner:{' . substr(str_replace('\n\t',';',$secondaryOwner->__toString()),0,-1) . '}\n';
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
return out;
return $out;
}
//Getters
@@ -62,10 +64,14 @@ class Projet{
return $this->dateCreation;
}
public function isPublic(){
return $this->publik == 1;
}
//Useful getters
public function haveRights($member){
return $member->getID() == $owner->getID() or in_array($member,$this->secondaryOwners);
return $member->getID() == $this->owner->getID() or in_array($member,$this->secondaryOwners);
}
//Setters
@@ -92,7 +98,7 @@ class Projet{
private static function projectGetterOutput($req){
$out = array();
while($rep = $req->fetch())
$out[] = new Project($rep['ID']);
$out[] = new Projet($rep['ID']);
switch(count($out)){
case 0:
return NULL;
@@ -104,19 +110,19 @@ class Projet{
}
public static function getFromName($name){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE name=?');
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE name=?');
$req->execute(array($name));
return projectGetterOutput($req);
}
public static function getFromOwner($owner){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE owner=?');
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE owner=?');
$req->execute(array($owner->getID()));
return projectGetterOutput($req);
}
public static function getFromSecondaryOwner($secondaryOwner){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project');
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
$req->execute();
$out = array();
while ($rep = $req->fetch()) {
@@ -141,25 +147,44 @@ class Projet{
}
public static function getCreatedLaterThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE dateCreation>?');
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE dateCreation>?');
$req->execute(array($date));
return projectGetterOutput($req);
}
public static function getCreatedEarlierThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE dateCreation<?');
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE dateCreation<?');
$req->execute(array($date));
return projectGetterOutput($req);
}
public static function getWhichHeCanAccess($he){
//TODO Faire la selection directement grâce à une requette SQL
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project');
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
$req->execute(array());
$out = array();
while ( $rep = $req->fetch()) {
$projet = new Projet($rep['ID']);
if ($projet->haveRights($membre))
if ($projet->haveRights($he))
$out[] = $projet;
}
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public static function getOthers($he){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
$req->execute(array());
$out = array();
while ( $rep = $req->fetch()) {
$projet = new Projet($rep['ID']);
if ($he?$he->isAdminLevelGreaterThan(12):FALSE || $projet->isPublic())
$out[] = $projet;
}
switch(count($out)){
@@ -173,5 +198,4 @@ class Projet{
}
}
}