97 lines
3.3 KiB
PHP
97 lines
3.3 KiB
PHP
<?php
|
|
class Projet{
|
|
|
|
public static function getAuthorizedProjectsForPresentation($sid,$mdp){
|
|
|
|
$GLOBALS['bdd']->exec('CREATE TEMPORARY TABLE projects (projectID INT,projectName VARCHAR(255),versionID INT,versionName VARCHAR(255))');
|
|
//$rep = $GLOBALS['bdd']->exec('INSERT @t');
|
|
$req = $GLOBALS['bdd']->prepare('CALL `GetAuthorizedProjectsForPresentation`(:sid, :mdp, @o)');
|
|
$req->bindValue(':sid', $sid);
|
|
$req->bindValue(':mdp', $mdp);
|
|
$req->execute();
|
|
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode')->fetch();
|
|
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
|
|
$req = $GLOBALS['bdd']->query('SELECT * FROM projects');
|
|
|
|
$out = array();
|
|
while($rep = $req->fetch()){
|
|
$pout = array();
|
|
$pout['projectID'] = $rep['projectID'];
|
|
$pout['projectName'] = $rep['projectName'];
|
|
$pout['versionID'] = $rep['versionID'];
|
|
$pout['versionName'] = $rep['versionName'];
|
|
$out[] = $pout;
|
|
}
|
|
return $out;
|
|
|
|
}
|
|
|
|
public static function getPublicProjectsForPresentation($sid,$mdp){
|
|
|
|
$GLOBALS['bdd']->exec('CREATE TEMPORARY TABLE projects (projectID INT,projectName VARCHAR(255),versionID INT,versionName VARCHAR(255))');
|
|
//$rep = $GLOBALS['bdd']->exec('INSERT @t');
|
|
$req = $GLOBALS['bdd']->prepare('CALL `GetPublicProjectsForPresentation`(:sid, :mdp, @o)');
|
|
$req->bindValue(':sid', $sid);
|
|
$req->bindValue(':mdp', $mdp);
|
|
$req->execute();
|
|
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode')->fetch();
|
|
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
|
|
$req = $GLOBALS['bdd']->query('SELECT * FROM projects');
|
|
|
|
$out = array();
|
|
while($rep = $req->fetch()){
|
|
$pout = array();
|
|
$pout['projectID'] = $rep['projectID'];
|
|
$pout['projectName'] = $rep['projectName'];
|
|
$pout['versionID'] = $rep['versionID'];
|
|
$pout['versionName'] = $rep['versionName'];
|
|
$out[] = $pout;
|
|
}
|
|
return $out;
|
|
|
|
}
|
|
|
|
public static function showProject($sid,$mdp,$pid){
|
|
|
|
$GLOBALS['bdd']->exec('CREATE TEMPORARY TABLE verzions (language INT,ID INT,name VARCHAR(255));
|
|
CREATE TEMPORARY TABLE sowners (pseudo VARCHAR(255));');
|
|
$req = $GLOBALS['bdd']->prepare('CALL `PresentProject`(:sid, :mdp, :pid, @o, @public, @name, @ownerID, @ownerPseudo)');
|
|
$req->bindValue(':sid', $sid);
|
|
$req->bindValue(':mdp', $mdp);
|
|
$req->bindValue(':pid', $pid);
|
|
$req->execute();
|
|
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode,@public AS public,@name AS name,@ownerPseudo AS ownerPseudo,@ownerID AS ownerID')->fetch();
|
|
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
|
|
|
|
//Output
|
|
$out = array();
|
|
$out['public'] = $rep['public'] == 1;
|
|
$out['name'] = $rep['name'];
|
|
$out['ownerID'] = $rep['ownerID'];
|
|
$out['ownerPseudo'] = $rep['ownerPseudo'];
|
|
|
|
$req = $GLOBALS['bdd']->query('SELECT * FROM sowners');
|
|
$out['sowners'] = array();
|
|
while($rep = $req->fetch()){
|
|
$sowner = array();
|
|
$sowner['pseudo'] = $rep['pseudo'];
|
|
$out['sowners'][] = $sowner;
|
|
}
|
|
|
|
$req = $GLOBALS['bdd']->query('SELECT * FROM verzions');
|
|
$out['versions'] = array();
|
|
while($rep = $req->fetch()){
|
|
$version = array();
|
|
$version['language'] = $rep['language'];
|
|
$version['ID'] = $rep['ID'];
|
|
$version['name'] = $rep['name'];
|
|
$out['versions'][] = $version;
|
|
}
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
}
|