Nouvelle classe Membre, différente. D'autres modifs....
This commit is contained in:
+57
-7
@@ -20,7 +20,7 @@ class Projet{
|
||||
$this->owner = new Membre($rep['ownerID']);
|
||||
$this->dateCreation = $rep['dateCreation'];
|
||||
$this->secondaryOwners = array();
|
||||
foreach (explode(';',$rep['secondaryOwnersID']) AS $secondaryOwner)
|
||||
foreach (($rep['secondaryOwnersID']!="")?explode(';',$rep['secondaryOwnersID']):[] AS $secondaryOwner)
|
||||
$this->secondaryOwners[] = new Membre($secondaryOwner);
|
||||
$this->publik = $rep['public'];
|
||||
}else{
|
||||
@@ -40,6 +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';
|
||||
$out .= '\tPublic:' . $this->publik == "1" . '\n';
|
||||
return $out;
|
||||
}
|
||||
|
||||
@@ -65,7 +66,7 @@ class Projet{
|
||||
}
|
||||
|
||||
public function isPublic(){
|
||||
return $this->publik == 1;
|
||||
return $this->publik;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,9 +79,21 @@ class Projet{
|
||||
public function setSecondaryOwners($secondaryOwners){
|
||||
$this->secondaryOwners = $secondaryOwners;
|
||||
$secondaryOwnersID = array();
|
||||
foreach($secondaryOwners AS $secondaryOwner)$secondaryOwnersID[] = $secondaryOwner->getID();
|
||||
$req = $GLOBALS['bdd']->prepare('UPDATE projets SET secondaryOwners=? WHERE ID=?');
|
||||
$req->execute(array(implode(';',$secondaryOwnersID),$this->ID));
|
||||
foreach($secondaryOwners as $secondaryOwner)$secondaryOwnersID[] = $secondaryOwner->getID();
|
||||
$req = $GLOBALS['bdd']->prepare('UPDATE projets SET secondaryOwnersID=? WHERE ID=?');
|
||||
$req->execute(array(implode(';',$secondaryOwnersID),$this->getID()));
|
||||
}
|
||||
|
||||
public function setPublicy($publicy){
|
||||
$this->publik = $publicy;
|
||||
$req = $GLOBALS['bdd']->prepare('UPDATE projets SET public=? WHERE ID=?');
|
||||
$req->execute(array($publicy?1:0,$this->getID()));
|
||||
}
|
||||
|
||||
public function setOwner($nOwner){
|
||||
$this->owner = $nOwner;
|
||||
$req = $GLOBALS['bdd']->prepare('UPDATE projets SET ownerID=? WHERE ID=?');
|
||||
$req->execute(array($nOwner->getID(),$this->getID()));
|
||||
}
|
||||
|
||||
public function addSecondaryOwner($secondaryOwner){
|
||||
@@ -159,7 +172,7 @@ class Projet{
|
||||
}
|
||||
|
||||
public static function getWhichHeCanAccess($he){
|
||||
//TODO Faire la selection directement grâce à une requette SQL
|
||||
//TODO Faire la selection directement gràce à une reqete SQL
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
|
||||
$req->execute(array());
|
||||
$out = array();
|
||||
@@ -184,7 +197,7 @@ class Projet{
|
||||
$out = array();
|
||||
while ( $rep = $req->fetch()) {
|
||||
$projet = new Projet($rep['ID']);
|
||||
if ($he?$he->isAdminLevelGreaterThan(12):FALSE || $projet->isPublic())
|
||||
if ($he?$he->isAdminLevelGreaterThan(12):FALSE || $projet->isPublic() == '1')
|
||||
$out[] = $projet;
|
||||
}
|
||||
switch(count($out)){
|
||||
@@ -197,5 +210,42 @@ class Projet{
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$req = $GLOBALS['bdd']->prepare('DELETE FROM projets WHERE ID=?');
|
||||
$req->execute(array($this->getID()));
|
||||
$this->valid = FALSE;
|
||||
}
|
||||
|
||||
public function newVersion($name,$langage,$tags,$insertIndex){
|
||||
if(Version::getFromProjectAndName($this, $name))
|
||||
return USED_NAME;
|
||||
if(!preg_match("#^[a-zA-Z0-9\\-_+ ]+$#", $name ))
|
||||
return INVALID_NAME;
|
||||
if(Version::getFromProjectLanguageAndVersionAbs($this,$langage, $insertIndex))
|
||||
return USED_INDEX;
|
||||
$req = $GLOBALS['bdd']->prepare('INSERT INTO versions (name,sendDate,publicFiles,tags,projectID,languageID,versionAbs) VALUES (?,NOW(),"",?,?,?,?)');
|
||||
$req->execute(array($name,$tags,$this->getID(),$langage->getID(),$insertIndex));
|
||||
return VERSION_CREATED;
|
||||
}
|
||||
|
||||
public function editVersion($versionToEdit,$name,$langage,$tags,$insertIndex){
|
||||
$namedVersion = Version::getFromProjectAndName($this, $name);
|
||||
if(($namedVersion)?$namedVersion->getID() != $versionToEdit->getID():FALSE)
|
||||
return USED_NAME;
|
||||
if(!preg_match("#^[a-zA-Z0-9\\-_+ ]+$#", $name ))
|
||||
return INVALID_NAME;
|
||||
$versionedVersion = Version::getFromProjectLanguageAndVersionAbs($this,$langage, $insertIndex);
|
||||
if(($versionedVersion)?$versionedVersion->getID() != $versionToEdit->getID():FALSE)
|
||||
return USED_INDEX;
|
||||
$req = $GLOBALS['bdd']->prepare('UPDATE versions SET name=?,tags=?,languageID=?,versionAbs=? WHERE ID=?');
|
||||
$req->execute(array($name,$tags,$langage->getID(),$insertIndex,$versionToEdit->getID()));
|
||||
return VERSION_EDITED;
|
||||
}
|
||||
|
||||
const INVALID_NAME = "sfygmal";
|
||||
const USED_NAME = "cflmfyqsdlm";
|
||||
const USED_INDEX = "jhmvm";
|
||||
const VERSION_CREATED = "jzbtdbgv";
|
||||
const VERSION_EDITED = "jzbqgsderftdbgv";
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user