Fin du dossier megaprocess, encore de nouvelles classesx

This commit is contained in:
Mysaa
2021-06-06 12:29:03 +02:00
parent fba5123944
commit 228f54d140
19 changed files with 530 additions and 5595 deletions
+64
View File
@@ -0,0 +1,64 @@
<?php
class Projet{
protected $ID;
protected $name;
protected $dateCreation;
protected $owner;
protected $secondaryOwners;
protected $valid;
public function __construct($ID){
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->name = $rep['name'];
$this->owner = new Membre($rep['ownerID']);
$this->dateCreation = $rep['dateCreation'];
$this->secondaryOwners = array();
foreach (explode(';',$rep['secondaryOwners']) AS $secondaryOwner)
$this->secondaryOwners[] = new Membre($secondaryOwner);
}else{
$this->valid = FALSE;
}
}
public function exists(){
return $this->valid;
}
public function __toString(){
$out = 'Projet\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tName:' . $this->name . '\n';
$out .= '\tOwner:{' . substr(str_replace('\n\t',';',$this->owner->__toString()),0,-1) . '}\n';
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;
}
//Getters
public function getID(){
return $this->ID;
}
public function getName(){
return $this->name;
}
public function getOwner(){
return $this->owner;
}
public function getSecondaryOwners(){
return $this->secondaryOwners;
}
public function getDateCreation(){
return $this->dateCreation;
}
}