Découpage du traitement en ercore plus de classes
This commit is contained in:
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
class Discussion{
|
||||
|
||||
protected $ID;
|
||||
protected $name;
|
||||
protected $creator;
|
||||
protected $dateCreation;
|
||||
protected $accessibility;
|
||||
|
||||
protected $valid;
|
||||
|
||||
public function __construct($ID){
|
||||
$this->ID = $ID;
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE ID=?');
|
||||
$req->execute(array($ID));
|
||||
if($rep = $req->fetch()){
|
||||
$this->valid = TRUE;
|
||||
$this->name = $rep['name'];
|
||||
$this->creatorID = new Membre($rep['creatorID']);
|
||||
$this->dateCreation = $rep['dateCreation'];
|
||||
$this->accessibility = $rep['accessibility'];
|
||||
}else{
|
||||
$this->valid = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
public function exists(){
|
||||
return $this->valid;
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
$out = 'Discussion\n';
|
||||
$out .= '\tID:' . $this->ID . '\n';
|
||||
$out .= '\tName:' . $this->name . '\n';
|
||||
$out .= '\tCreator:{' . substr(str_replace('\n\t',';',$this->creator->__toString()),0,-1) . '}\n';
|
||||
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
|
||||
$out .= '\tAccessibility:' . $this->accessibility . '\n';
|
||||
return out;
|
||||
}
|
||||
|
||||
//Getters
|
||||
public function getID(){
|
||||
return $this->ID;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getCreator(){
|
||||
return $creator;
|
||||
}
|
||||
|
||||
public function getDateCreation(){
|
||||
return $this->dateCreation;
|
||||
}
|
||||
|
||||
public function getAccessibility(){
|
||||
return $this->accessibility;
|
||||
}
|
||||
|
||||
|
||||
//Useful Getters
|
||||
public function canAccess($membre){
|
||||
$out = $this->accessibility === 'p';
|
||||
$out = $out or $membre->getID() === $this->creator->getID();
|
||||
if(preg_match ( "#^a[0-9]+$#", $this->accessibility ) == 1)
|
||||
$out = $out or intval ( substr ( $this->accessibility, 1 ) ) <= $membre->getAdminLevel();
|
||||
$out = $out or preg_match ( '#^x([0-9]+;)*' . $membre->getID() . '(;[0-9]+)*$#', $disc ['autorized'] ) == 1;
|
||||
$out = $out or $membre->getAdminLevel() >= 14;
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
//Setters
|
||||
public function rename($newName){
|
||||
if(!exists())
|
||||
return NULL;
|
||||
if(getFromName($newName))
|
||||
return Discussion::NAME_ALREADY_USED;
|
||||
if(strlen($newName)>255)
|
||||
return Discussion::TOO_LONG_NAME;
|
||||
$regex = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.
|
||||
'éèàµ_\\-\'()\\[\\]\\\\/,;:.§!ù%£$¤=+\\-*\\#~"|ç@';
|
||||
$regex = '#^['.$regex.']+$#';
|
||||
if(preg_match($regex,$newName) != 1)
|
||||
return Discussion::ILLEGAL_NAME;
|
||||
$req->$GLOBALS['bdd']->prepare('UPDATE discussions SET name=? WHERE ID=?');
|
||||
$req->execute(array($newName,$this->ID));
|
||||
return Discussion::NAME_CHANGED;
|
||||
}
|
||||
|
||||
public function changeAccessibility($newAccessibility){
|
||||
if(!exists())
|
||||
return NULL;
|
||||
if($newAccessibility !== 'p' and
|
||||
preg_match('#x([0-9]+;)*[0-9]+#',$newAccessibility) != 1 and
|
||||
preg_match('#a[0-9]+#',$newAccessibility) != 1)
|
||||
return Discussion::MALFORMED_ACCESIBILITY;
|
||||
$req = $GLOBALS['bdd']->prepare('UPDATE discussions SET accessibility=? WHERE ID=?');
|
||||
$req->execute(array($newAccessibility,$this->ID));
|
||||
return Discussion::ACCESSIBILITY_CHANGED;
|
||||
}
|
||||
|
||||
public function setDateCreation($newDateCreation){
|
||||
if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $date, $matches) != 1)
|
||||
return Discussion::MALFORMED_DATE;
|
||||
if (!checkdate($matches[2], $matches[3], $matches[1]))
|
||||
return Discussion::MALFORMED_DATE;
|
||||
$req = $GLOBALS['bdd']->prepare('UPDATE discussions SET dateCreation=? WHERE ID=?');
|
||||
$req->execute(array($newDateCreation,$this->ID));
|
||||
return Discussion::DATE_CREATION_CHANGED;
|
||||
}
|
||||
|
||||
//Discussions getters
|
||||
private static function discussionGetterOutput($req){
|
||||
$out = array();
|
||||
while($rep = $req->fetch())
|
||||
$out[] = new Discussion($rep['ID']);
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFromName($name){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE name=?');
|
||||
$req->execute(array($name));
|
||||
return discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromCreator($creator){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE creatorID=?');
|
||||
$req->execute(array($creator->getID()));
|
||||
return discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromDateCreation($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation=?');
|
||||
$req->execute(array($date));
|
||||
return discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromAccessibility($accessibility){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE creatorID=?');
|
||||
$req->execute(array($accessibility));
|
||||
return discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedLaterThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation>?');
|
||||
$req->execute(array($date));
|
||||
return discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedEarlierThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation<?');
|
||||
$req->execute(array($date));
|
||||
return discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getWhichHeCanAccess($he){
|
||||
//TODO utiliser une regex dans la requete SQL pour selectionner les discussions autorisées
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions');
|
||||
$req->execute(array());
|
||||
$out = array();
|
||||
while ( $rep = $req->fetch()) {
|
||||
$disc = new Discussion($rep['ID']);
|
||||
if ($disc->canAccess($membre))
|
||||
$out[] = $disc;
|
||||
}
|
||||
if($out)
|
||||
return $out;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Exceptions texts
|
||||
|
||||
//rename()
|
||||
const NAME_ALREADY_USED = 'Nom déjà utilisé';
|
||||
const ILLEGAL_NAME = 'Le nom de la discussion est incorrect : les caractères autorisés sont :'.
|
||||
'<br/> abcdefghijklmnopqrstuvwxyz<wbr/>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<wbr/>'.
|
||||
'éèàμ_-\'()[\\]\\\\/<wbr/>,;:.§!ù%£$¤=+-*\\#~"|ç@';
|
||||
const TOO_LONG_NAME = 'Le nom est trop long : maximum 256 caractères';
|
||||
const NAME_CHANGED = 'Le nom a bien été changé !';
|
||||
|
||||
//changeAccessibility()
|
||||
const MALFORMED_ACCESSIBILITY = 'L\'accessibilité doit être de la forme : "p" ou "x31;41;59;26;53" ou "a42"';
|
||||
const ACCESSIBILITY_CHANGED = 'L\'accessibilité a bien été changée !';
|
||||
|
||||
//setDateCreation()
|
||||
const MALFORMED_DATE = 'La date de création doit être de la forme "AAAA:MM:JJ hh:mm:ss"';
|
||||
const DATE_CREATION_CHANGED = 'La date de création a bien été changée';
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
class Langage{
|
||||
|
||||
const java = new Langage(0, "Java", "jar java javadoc");
|
||||
const vba = new Langage(1, "VBA", "xlsm vb");
|
||||
|
||||
protected static $languages = array();
|
||||
|
||||
protected $ID;
|
||||
protected $name;
|
||||
protected $avalivableFiles;//String "jar xlsx javadoc" in constructor , stored as a string array
|
||||
|
||||
|
||||
protected function __construct($ID,$name,$avalivableFiles){
|
||||
$this->ID = $ID;
|
||||
$this->name = $name;
|
||||
$this->avalivableFiles = explode(" ",$avalivableFiles);
|
||||
$languages[] = $this;
|
||||
}
|
||||
|
||||
public function getID(){
|
||||
return $this->ID;
|
||||
}
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
public function getAvalivableFiles(){
|
||||
return $this->avalivableFiles;
|
||||
}
|
||||
public function isJarAvalivable(){
|
||||
return in_array("jar",$this->avalivableFiles);
|
||||
}
|
||||
public function isJavaAvalivable(){
|
||||
return in_array("java",$this->avalivableFiles);
|
||||
}
|
||||
public function isJavadocAvalivable(){
|
||||
return in_array("javadoc",$this->avalivableFiles);
|
||||
}
|
||||
public function isXlsmAvalivable(){
|
||||
return in_array("xlsm",$this->avalivableFiles);
|
||||
}
|
||||
public function isVbAvalivable(){
|
||||
return in_array("vb",$this->avalivableFiles);
|
||||
}
|
||||
|
||||
public static function getFromID($ID){
|
||||
foreach(self::$languages AS $language){
|
||||
if($language->getID() == $ID)
|
||||
return $language;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
+212
-1
@@ -1 +1,212 @@
|
||||
<?phpclass Membre{ const DEFAULT_BANNER = "pictures/bande.png"; protected $id; protected $password; protected $pseudo; protected $adminLevel; protected $dateCreation; protected $requiredBanner; protected $personnalMessage; protected $connected; public function __construct($id = NULL,$pass = NULL){ $this->id = $id ?? $_SESSION['session_id']; $this->password = $pass ?? $_SESSION['session_mdp']; $connected = FALSE; } public function connect(){ $req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' ); $req->execute (array($this->id)); if ($rep = $req->fetch ()){ $connected = password_verify ( $this->pass, $rep ['mdp'] ); $this->adminLevel = $connected?$result ['administration']:-1; $this->pseudo = $connected?$result['pseudo']:NULL; if($connected)decodeData($rep['data']); return $this->connected = $connected; }else{ $req->closeCursor (); return $this->connected = FALSE; } } public function hasPersonnalMessage(){ return isset($this->personnalMessage); } public function showPersonnalMessage(){ $msg = $this->personnalMessage; $this->personnalMessage = NULL; return $msg; } private function decodeData($data) { $jsonData = json_decode($data); //Set the data's required_banner if it is defined , otherwise sets the DEFAULT_BANNER $this->requiredBanner = $jsonData['requiredBanner'] ?? self::DEFAULT_BANNER; $this->personnalMessage = $jsonData['personnalMessage'] ?? NULL; } private function encodeData(){ $jsonArray = array(); //Set requiredBanner only if it is different from DEFAULT_BANNER $jsonArray['requiredBanner'] = $this->requiredBanner !== self::DEFAULT_BANNER ? $this->requiredBanner : NULL; $jsonArray['personnalMessage'] = $this->personnalMessage ?? NULL; return json_encode($jsonArray); } public function getAdminLevel(){ return $this->adminLevel; } public function getBanner() { return $this->requiredBanner; } public function isConnected(){ return $connected; } public static function tryToConnect($pseudo = NULL,$mdp = NULL){ $pseudo = $pseudo ?? $_POST ['pseudo']; $mdp = $mdp ?? $_POST ['mdp']; $req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE pseudo=?' ); $req->execute ( array ( $pseudo ) ); $reponce = $req->fetch (); if ($reponce != NULL) { if (password_verify ( $mdp, $reponce ['mdp'] )) { $req->closeCursor (); return $reponce ['ID']; } else { $req->closeCursor (); return 'errormdp'; } } else { $req->closeCursor (); return 'errorpseudo'; } } public static function registerPerson($pseudo, $mdp) { $req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM users WHERE pseudo=?" ); $req->execute (array($_POST ['pseudo'])); if ($req->fetch ()) return 'usedPseudo'; $req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())' ); $req->execute(array($_POST ['pseudo'],password_hash ( $_POST ['mdp'], PASSWORD_DEFAULT))); return 'ok'; }}
|
||||
<?php
|
||||
class Membre {
|
||||
const DEFAULT_BANNER = "pictures/bande.png";
|
||||
|
||||
protected $ID;
|
||||
protected $pseudo;
|
||||
protected $hashedPassword;
|
||||
protected $adminLevel;
|
||||
protected $dateCreation;
|
||||
protected $requiredBanner;
|
||||
protected $personnalMessage;
|
||||
|
||||
protected $connected;
|
||||
protected $valid;
|
||||
|
||||
public function __construct($ID) {
|
||||
$this->ID = $ID;
|
||||
$this->connected = FALSE;
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE ID=?');
|
||||
$req->execute(array($ID));
|
||||
if($rep = $req->fetch()){
|
||||
$this->valid = TRUE;
|
||||
$this->pseudo = $rep['pseudo'];
|
||||
$this->adminLevel = $rep['adminLevel'];
|
||||
$this->dateCreation = $rep['dateCreation'];
|
||||
$this->hashedPassword = $rep['hashedPassword'];
|
||||
$this->decodeData($rep['data']);
|
||||
}else{
|
||||
$this->valid = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
public function connect($password) {
|
||||
$this->connected = password_verify ( $this->pass, $rep ['mdp'] );
|
||||
|
||||
return $this->connected;
|
||||
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
$out = 'Membre\n';
|
||||
$out .= '\tID:' . $this->ID . '\n';
|
||||
$out .= '\tPseudo:' . $this->pseudo . '\n';
|
||||
$out .= '\tAdmin level:' . $this->adminLevel . '\n';
|
||||
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
|
||||
$out .= '\tRequired banner:' . $this->requiredBanner . '\n';
|
||||
$out .= '\tPersonnal message:' . $this->personnalMessage . '\n';
|
||||
return out;
|
||||
}
|
||||
|
||||
public function isConnected(){
|
||||
return $this->connected;
|
||||
}
|
||||
|
||||
public function exists(){
|
||||
return $this->valid;
|
||||
}
|
||||
|
||||
private function decodeData($data) {
|
||||
$jsonData = json_decode ( $data );
|
||||
// Set the data's required_banner if it is defined , otherwise sets the DEFAULT_BANNER
|
||||
$this->requiredBanner = $jsonData ['requiredBanner'] ?? self::DEFAULT_BANNER;
|
||||
$this->personnalMessage = $jsonData ['personnalMessage'] ?? NULL;
|
||||
}
|
||||
|
||||
|
||||
//Getters
|
||||
public function getID(){
|
||||
return $this->ID;
|
||||
}
|
||||
|
||||
public function getPseudo(){
|
||||
return $this->pseudo;
|
||||
}
|
||||
|
||||
public function getAdminLevel() {
|
||||
return $this->adminLevel;
|
||||
}
|
||||
|
||||
public function getDateCreation(){
|
||||
return $this->dateCreation;
|
||||
}
|
||||
|
||||
public function getRequiredBanner() {
|
||||
return $this->requiredBanner;
|
||||
}
|
||||
|
||||
public function getPersonnalMessage(){
|
||||
return $this->personnalMessage;
|
||||
}
|
||||
|
||||
|
||||
//Useful getters
|
||||
public function isAdminLevelLowerThan($max){
|
||||
return $this->adminLevel<$max;
|
||||
}
|
||||
|
||||
public function isAdminLevelGreaterThan($min){
|
||||
return $this->adminLevel>$max;
|
||||
}
|
||||
|
||||
public function isAdminLevelLowerOrEqualThan($max){
|
||||
return $this->adminLevel<$max;
|
||||
}
|
||||
|
||||
public function isAdminLevelGreaterOrEqualThan($min){
|
||||
return $this->adminLevel>$max;
|
||||
}
|
||||
|
||||
public function hasPersonnalMessage() {
|
||||
return isset ( $this->personnalMessage );
|
||||
}
|
||||
|
||||
public function showPersonnalMessage() {
|
||||
$msg = $this->personnalMessage;
|
||||
$this->setPersonnalMessage = NULL;
|
||||
return $msg;
|
||||
}
|
||||
|
||||
//Setters
|
||||
public function changePassword($newPassword){
|
||||
if(strlen($newPassword)>255)
|
||||
return Membre::PASSWORD_TOO_LONG;
|
||||
$req = $GLOBALS['bdd']->prepare('UPDATE membres SET mdp=? WHERE ID=?');
|
||||
$req->execute(array(password_hash ( $newPassword, PASSWORD_DEFAULT ),$this->ID));
|
||||
return Membre::PASSWORD_CHANGED;
|
||||
}
|
||||
|
||||
|
||||
//Membre getters
|
||||
private static function memberGetterOutput($req){
|
||||
$out = array();
|
||||
while($rep = $req->fetch())
|
||||
$out[] = new Membre($rep['ID']);
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFromPseudo($pseudo){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE pseudo=?');
|
||||
$req->execute(array($pseudo));
|
||||
return membreGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromAdminLevel($level){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE adminLevel=?');
|
||||
$req->execute(array($level));
|
||||
return membreGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromDateCreation($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE dateCreation=?');
|
||||
$req->execute(array($date));
|
||||
return membreGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedLaterThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE dateCreation>?');
|
||||
$req->execute(array($date));
|
||||
return membreGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedEarlierThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE dateCreation<?');
|
||||
$req->execute(array($date));
|
||||
return membreGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getAdminGreaterThan($min){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE adminLevel>?');
|
||||
$req->execute(array($min));
|
||||
return membreGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getAdminLowerThan($max){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE adminLevel<?');
|
||||
$req->execute(array($max));
|
||||
return membreGetterOutput($req);
|
||||
}
|
||||
|
||||
|
||||
//Membre creator
|
||||
public static function registerPerson($pseudo, $mdp) {
|
||||
if (Membre::getFromPseudo($pseudo))
|
||||
return Membre::USED_USERNAME;
|
||||
$req = $GLOBALS ['bdd']->prepare ('INSERT INTO membres(pseudo,mdp,date_creation) VALUES (?,?,NOW())');
|
||||
$req->execute (array($pseudo,password_hash( $mdp, PASSWORD_DEFAULT)));
|
||||
return Membre::USERNAME_CHANGED;
|
||||
}
|
||||
|
||||
|
||||
//Outputs texts
|
||||
|
||||
//changePassword
|
||||
const PASSWORD_TOO_LONG = 'Le mot de passe est trop long ! (Max : 255 caractères)';
|
||||
const PASSWORD_CHANGED = 'Le mot de passe a bien été changé';
|
||||
|
||||
//registerPerson
|
||||
const USED_USERNAME = 'Le pseudonyme est déjà utilisé';
|
||||
const PERSON_REGISTERED = 'Le membre a bien été inscrit !';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
class Message{
|
||||
|
||||
protected $ID;
|
||||
protected $sender;
|
||||
protected $sendDate;
|
||||
protected $text;
|
||||
protected $discussion;
|
||||
|
||||
protected $valid;
|
||||
|
||||
public function __construct($ID){
|
||||
$this->ID = $ID;
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE ID=?');
|
||||
$req->execute(array($ID));
|
||||
if($rep = $req->fetch()){
|
||||
$this->valid = TRUE;
|
||||
$this->sender = new Membre($rep['senderID']);
|
||||
$this->sendDate = $rep['sendDate'];
|
||||
$this->text = $rep['text'];
|
||||
$this->discussion = new Discussion($rep['discussionID']);
|
||||
}else{
|
||||
$this->valid = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
public function exists(){
|
||||
return $this->valid;
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
$out = 'Message\n';
|
||||
$out .= '\tID:' . $this->ID . '\n';
|
||||
$out .= '\tSender:{' . substr(str_replace('\n\t',';',$this->sender->__toString()),0,-1) . '}\n';
|
||||
$out .= '\tSend date:' . $this->sendDate . '\n';
|
||||
$out .= '\tText:' . $this->text . '}\n';
|
||||
$out .= '\tDiscussion:' . substr(str_replace('\n\t',';',$this->discussion->__toString()),0,-1) . '\n';
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
//Getters
|
||||
public function getID(){
|
||||
return $this->ID;
|
||||
}
|
||||
|
||||
public function getSender(){
|
||||
return $this->sender;
|
||||
}
|
||||
|
||||
public function getSendDate(){
|
||||
return $this->sendDate;
|
||||
}
|
||||
|
||||
public function getText(){
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function getDiscussion(){
|
||||
return $this->discussion;
|
||||
}
|
||||
|
||||
|
||||
//Useful getters
|
||||
public function canEdit($person){
|
||||
return $person->isAdminLevelGreaterOrEqualThan(6) || $person->getID() == $this->sender->getID();
|
||||
}
|
||||
|
||||
|
||||
//Setters
|
||||
public function editText($newText){
|
||||
$this->text = htmlSepcialChars($newText);
|
||||
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussion_id,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
|
||||
$req->execute (array ($this->discussion->getID(),$this->text,$this->sender->getID()));
|
||||
}
|
||||
|
||||
//Message getter
|
||||
private static function messagesGetterOutput($req){
|
||||
$out = array();
|
||||
while($rep = $req->fetch())
|
||||
$out[] = new Discussion($rep['ID']);
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFromSender($param) {
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE senderID=?');
|
||||
$req->execute(array($sender->getID()));
|
||||
return messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
|
||||
public static function getFromSendDate($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE sendDate=?');
|
||||
$req->execute(array($date));
|
||||
return messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getSendedLaterThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE sendDate>?');
|
||||
$req->execute(array($date));
|
||||
return messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getSendedEarlierThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE sendDate<?');
|
||||
$req->execute(array($date));
|
||||
return messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromText($text) {
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE text=?');
|
||||
$req->execute(array($text));
|
||||
return messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromDiscussion($discut){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE discussionID=?');
|
||||
$req->execute(array($discut->getID()));
|
||||
return messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
|
||||
//Message creator
|
||||
public static function sendMessage($sender,$discussion,$text){
|
||||
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussion_id,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
|
||||
$req->execute (array($discussion->getID(),htmlspecialchars ($text),$sender->getID()));
|
||||
}
|
||||
|
||||
}
|
||||
+175
-176
@@ -1,177 +1,176 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
|
||||
//Useful getters
|
||||
public function haveRights($member){
|
||||
return $member->getID() == $owner->getID() or in_array($member,$this->secondaryOwners);
|
||||
}
|
||||
|
||||
//Setters
|
||||
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));
|
||||
}
|
||||
|
||||
public function addSecondaryOwner($secondaryOwner){
|
||||
$this->secondaryOwners[] = $secondaryOwner;
|
||||
$this->setSecondaryOwners($this->secondaryOwners);
|
||||
}
|
||||
|
||||
public function delSecondaryOwner($secondaryOwner){
|
||||
$this->secondaryOwners = array_diff($this->secondaryOwners,array($secondaryOwner));
|
||||
$this->setSecondaryOwners($this->secondaryOwners);
|
||||
}
|
||||
|
||||
|
||||
//Project getters
|
||||
private static function projectGetterOutput($req){
|
||||
$out = array();
|
||||
while($rep = $req->fetch())
|
||||
$out[] = new Project($rep['ID']);
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFromName($name){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE name=?');
|
||||
$req->execute(array($name));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromOwner($owner){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE owner=?');
|
||||
$req->execute(array($owner->getID()));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromSecondaryOwner($secondaryOwner){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project');
|
||||
$req->execute();
|
||||
$out = array();
|
||||
while ($rep = $req->fetch()) {
|
||||
$projet = new Projet($rep['ID']);
|
||||
if ($projet->haveRights($secondaryOwner))
|
||||
$out[] = $projet;
|
||||
}
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromDateCreation($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE dateCreation=?');
|
||||
$req->execute(array($date));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedLaterThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE dateCreation>?');
|
||||
$req->execute(array($date));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedEarlierThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE dateCreation<?');
|
||||
$req->execute(array($date));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getWhichHeCanAccess($he){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project');
|
||||
$req->execute(array());
|
||||
$out = array();
|
||||
while ( $rep = $req->fetch()) {
|
||||
$disc = new Discussion($rep['ID']);
|
||||
if ($disc->canAccess($membre))
|
||||
$out[] = $disc;
|
||||
}
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
<?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;
|
||||
}
|
||||
|
||||
|
||||
//Useful getters
|
||||
public function haveRights($member){
|
||||
return $member->getID() == $owner->getID() or in_array($member,$this->secondaryOwners);
|
||||
}
|
||||
|
||||
//Setters
|
||||
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));
|
||||
}
|
||||
|
||||
public function addSecondaryOwner($secondaryOwner){
|
||||
$this->secondaryOwners[] = $secondaryOwner;
|
||||
$this->setSecondaryOwners($this->secondaryOwners);
|
||||
}
|
||||
|
||||
public function delSecondaryOwner($secondaryOwner){
|
||||
$this->secondaryOwners = array_diff($this->secondaryOwners,array($secondaryOwner));
|
||||
$this->setSecondaryOwners($this->secondaryOwners);
|
||||
}
|
||||
|
||||
|
||||
//Project getters
|
||||
private static function projectGetterOutput($req){
|
||||
$out = array();
|
||||
while($rep = $req->fetch())
|
||||
$out[] = new Project($rep['ID']);
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFromName($name){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE name=?');
|
||||
$req->execute(array($name));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromOwner($owner){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE owner=?');
|
||||
$req->execute(array($owner->getID()));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromSecondaryOwner($secondaryOwner){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project');
|
||||
$req->execute();
|
||||
$out = array();
|
||||
while ($rep = $req->fetch()) {
|
||||
$projet = new Projet($rep['ID']);
|
||||
if ($projet->haveRights($secondaryOwner))
|
||||
$out[] = $projet;
|
||||
}
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFromDateCreation($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE dateCreation=?');
|
||||
$req->execute(array($date));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedLaterThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE dateCreation>?');
|
||||
$req->execute(array($date));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedEarlierThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project 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->execute(array());
|
||||
$out = array();
|
||||
while ( $rep = $req->fetch()) {
|
||||
$projet = new Projet($rep['ID']);
|
||||
if ($projet->haveRights($membre))
|
||||
$out[] = $projet;
|
||||
}
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
class Version{
|
||||
|
||||
protected $ID;
|
||||
protected $name;
|
||||
protected $sendDate;
|
||||
protected $publicFiles;//String "jar xlsx javadoc" in bdd , stored as a string array
|
||||
protected $tags;//String "beta bugged" in bdd , stored as a string array
|
||||
protected $project;
|
||||
protected $language;
|
||||
|
||||
public function __construct($ID){
|
||||
$this->ID = $ID;
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE ID=?');
|
||||
$req->execute(array($ID));
|
||||
if($rep = $req->fetch()){
|
||||
$this->valid = TRUE;
|
||||
$this->name = $rem['name'];
|
||||
$this->sendDate = $rep['sendDate'];
|
||||
$this->publicFiles = explode(" ",$rep['publicFiles']);
|
||||
$this->tags = explode(" ",$rep['tags']);
|
||||
$this->project = new Project($rep['projectID']);
|
||||
$this->language = Langage::getFromID($rep['languageID']);
|
||||
}else{
|
||||
$this->valid = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
public function exists(){
|
||||
return $this->valid;
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
$out = 'Version\n';
|
||||
$out .= '\tID:' . $this->ID . '\n';
|
||||
$out .= '\tName:{' . $this->name . '}\n';
|
||||
$out .= '\tSend date:' . $this->sendDate . '\n';
|
||||
$out .= '\tPublic files:"' . implode(' ',$this->publicFiles) . '"}\n';
|
||||
$out .= '\tTags:"' . implode(' ',$this->tags) . '"}\n';
|
||||
$out .= '\tProject:' . substr(str_replace('\n\t',';',$this->project->__toString()),0,-1) . '\n';
|
||||
$out .= '\tLanguage:' . $this->language->getName() . '\n';
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
//Getters
|
||||
public function getID(){
|
||||
return $this->ID;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getSendDate(){
|
||||
return $this->sendDate;
|
||||
}
|
||||
|
||||
public function getPublicFiles(){
|
||||
//returns a string array
|
||||
return $this->publicFiles;
|
||||
}
|
||||
|
||||
public function getTags(){
|
||||
//returns a string array
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
public function getProject(){
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
public function getLanguage(){
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
//Useful Getters
|
||||
//TODO make all of the following 'is' functions using haveTag
|
||||
public function haveTag($tag){
|
||||
return in_array($tag,$this->tags);
|
||||
}
|
||||
|
||||
public function isJarPublic(){
|
||||
return in_array("jar",$this->publicFiles);
|
||||
}
|
||||
|
||||
public function isJavaPublic(){
|
||||
return in_array("java",$this->publicFiles);
|
||||
}
|
||||
|
||||
public function isJavadocPublic(){
|
||||
return in_array("javadoc",$this->publicFiles);
|
||||
}
|
||||
|
||||
public function isXlsmPublic(){
|
||||
return in_array("xlsm",$this->publicFiles);
|
||||
}
|
||||
|
||||
public function isVbPublic(){
|
||||
return in_array("vb",$this->publicFiles);
|
||||
}
|
||||
|
||||
public function isAlpha(){
|
||||
return in_array("alpha",$this->tags);
|
||||
}
|
||||
|
||||
public function isBeta(){
|
||||
return in_array("beta",$this->tags);
|
||||
}
|
||||
|
||||
public function isRelease(){
|
||||
return in_array("release",$this->tags);
|
||||
}
|
||||
|
||||
public function isTest(){
|
||||
return in_array("test",$this->tags);
|
||||
}
|
||||
|
||||
public function isBugged(){
|
||||
return in_array("bugged",$this->tags);
|
||||
}
|
||||
|
||||
//Setters
|
||||
public function storeTags(){
|
||||
$rep = $GLOBALS['bdd']->prepare('UPDATE versions SET tags=? WHERE ID=?');
|
||||
$rep->execute(array(implode(' ',$this->tags),$this->ID));
|
||||
}
|
||||
|
||||
public function addTag($tag,$store = TRUE){
|
||||
$this->deleteTag($tag,FALSE);
|
||||
$this->tags[] = $tag;
|
||||
if($store)$this->storeTags();
|
||||
}
|
||||
|
||||
public function deleteTag($tag,$store = TRUE){
|
||||
$this->tags = array_diff($this->tags,array($tag));
|
||||
if($store)$this->storeTags();
|
||||
}
|
||||
|
||||
public function setARelease(){
|
||||
$this->deleteTag('alpha',FALSE);
|
||||
$this->deleteTag('beta',FALSE);
|
||||
$this->addTag('release',FALSE);
|
||||
$this->storeTags();
|
||||
}
|
||||
|
||||
public function setAnAlpha(){
|
||||
$this->deleteTag('beta',FALSE);
|
||||
$this->deleteTag('release',FALSE);
|
||||
$this->addTag('alpha',FALSE);
|
||||
$this->storeTags();
|
||||
}
|
||||
|
||||
public function setABeta(){
|
||||
$this->deleteTag('alpha',FALSE);
|
||||
$this->deleteTag('release',FALSE);
|
||||
$this->addTag('beta',FALSE);
|
||||
$this->storeTags();
|
||||
}
|
||||
|
||||
public function setATest(){
|
||||
$this->addTag('test');
|
||||
}
|
||||
|
||||
public function setNotATest(){
|
||||
$this->delTag('test');
|
||||
}
|
||||
|
||||
public function setBugged(){
|
||||
$this->addTag('bugged');
|
||||
}
|
||||
|
||||
public function setNotBugged(){
|
||||
$this->delTag('bugged');
|
||||
}
|
||||
|
||||
public function storePublicFiles(){
|
||||
$rep = $GLOBALS['bdd']->prepare('UPDATE versions SET publicFiles=? WHERE ID=?');
|
||||
$rep->execute(array(implode(' ',$this->publicFiles),$this->ID));
|
||||
}
|
||||
|
||||
public function addPublicFile($file,$store = TRUE){
|
||||
$this->deletePublicFile($file,FALSE);
|
||||
$this->publicFiles[] = $file;
|
||||
if($store)$this->storePublicFiles();
|
||||
}
|
||||
|
||||
public function deletePublicFile($file,$store = TRUE){
|
||||
$this->publicFiles = array_diff($this->publicFiles,array($file));
|
||||
if($store)$this->storePublicFiles();
|
||||
}
|
||||
|
||||
public function setJarPublic(){
|
||||
$this->addPublicFile('jar');
|
||||
}
|
||||
|
||||
public function setJarNotPublic(){
|
||||
$this->deletePublicFile('jar');
|
||||
}
|
||||
|
||||
public function setJavaPublic(){
|
||||
$this->addPublicFile('java');
|
||||
}
|
||||
|
||||
public function setJavaNotPublic(){
|
||||
$this->deletePublicFile('java');
|
||||
}
|
||||
|
||||
public function setJavadocPublic(){
|
||||
$this->addPublicFile('javadoc');
|
||||
}
|
||||
|
||||
public function setJavadocNotPublic(){
|
||||
$this->deletePublicFile('javadoc');
|
||||
}
|
||||
|
||||
public function setXlsmPublic(){
|
||||
$this->addPublicFile('xlsm');
|
||||
}
|
||||
|
||||
public function setXlsmNotPublic(){
|
||||
$this->deletePublicFile('xlsm');
|
||||
}
|
||||
|
||||
public function setVbPublic(){
|
||||
$this->addPublicFile('vb');
|
||||
}
|
||||
|
||||
public function setVbNotPublic(){
|
||||
$this->deletePublicFile('vb');
|
||||
}
|
||||
|
||||
|
||||
//Version Getter
|
||||
private static function versionGetterOutput($req){
|
||||
$out = array();
|
||||
while($rep = $req->fetch())
|
||||
$out[] = new Version($rep['ID']);
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFromLanguage($language){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE languageID=?');
|
||||
$req->execute(array($language->getID()));
|
||||
return versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromProject($project){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE projectID=?');
|
||||
$req->execute(array($project->getID()));
|
||||
return versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromName($name){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE name=?');
|
||||
$req->execute(array($name));
|
||||
return versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromTag($tag){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions');
|
||||
$req->execute();
|
||||
$out = array();
|
||||
while ($rep = $req->fetch()) {
|
||||
$projet = new Version($rep['ID']);
|
||||
if ($projet->haveTag($tag))
|
||||
$out[] = $projet;
|
||||
}
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
|
||||
return projectGetterOutput($req);
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE languageID=?');
|
||||
$req->execute(array($language->getID()));
|
||||
return versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromSendDate($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE sendDate=?');
|
||||
$req->execute(array($date));
|
||||
return versionsGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getSendedLaterThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE sendDate>?');
|
||||
$req->execute(array($date));
|
||||
return versionsGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getSendedEarlierThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE sendDate<?');
|
||||
$req->execute(array($date));
|
||||
return versionsGetterOutput($req);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
try{
|
||||
$GLOBALS['bdd'] = new PDO('mysql:host=mysql.hostinger.fr;dbname=u890869027_bcom;charset=utf8', 'u890869027_bcom', '*******************');
|
||||
}catch(Exception $e){
|
||||
die ('Erreur : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
//TODO in the classes , do more test of exists in setters
|
||||
include_once 'clazz/Langage.class.php';
|
||||
include_once 'clazz/Membre.class.php';
|
||||
include_once 'clazz/Discussion.class.php';
|
||||
include_once 'clazz/Message.class.php';
|
||||
include_once 'clazz/Projet.class.php';
|
||||
//Use class's consts for file names
|
||||
include_once 'clazz/Version.class.php';
|
||||
Reference in New Issue
Block a user