59 lines
2.4 KiB
PHP
59 lines
2.4 KiB
PHP
<?php
|
|
class Version{
|
|
|
|
public static function editVersion ($sid,$mdp,$v,$name,$langage,$tags,$insertIndex){
|
|
$sid = intval($sid);
|
|
$mdp = $GLOBALS['bdd']->quote(strval($mdp));
|
|
$v = intval($v);
|
|
$name = $name?$GLOBALS['bdd']->quote(strval($name)):'NULL';
|
|
$langage = $langage?intval($langage):'NULL';
|
|
$tags = $tags?$GLOBALS['bdd']->quote($tags):'NULL';
|
|
$insertIndex = $insertIndex?intval($insertIndex):'NULL';
|
|
|
|
$rep = $GLOBALS['bdd']->exec('CALL `EditVersion`('.$sid.','.$mdp.','.$v.','.$name.','.$langage.','.$tags.','.$insertIndex.', @p8); SELECT ID AS outputCode , errorMessage AS message , htmlErrorMessage AS htmlMessage FROM errorReturns WHERE ID = @p8;')->fetch();
|
|
|
|
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode'],$rep['message'],$rep['htmlMessage']);
|
|
}
|
|
|
|
public static function showVersion($sid,$mdp,$vid){
|
|
|
|
$GLOBALS['bdd']->exec('CREATE TEMPORARY TABLE verzions (language INT,ID INT,name VARCHAR(255));');
|
|
$req = $GLOBALS['bdd']->prepare('CALL `PresentVersion`(:sid, :mdp, :vid, @o, @su,@ssu,@langageID,@projectName,@name,@fileAccessibility,@projectID,@tags)');
|
|
$req->bindValue(':sid', $sid);
|
|
$req->bindValue(':mdp', $mdp);
|
|
$req->bindValue(':vid', $vid);
|
|
$req->execute();
|
|
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode,@su AS su,@ssu AS ssu,@langageID AS langage,@projectName AS projectName,@name AS name,@fileAccessibility AS fileAccessibility,@projectID AS projectID,@tags AS tags')->fetch();
|
|
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
|
|
|
|
//Output
|
|
$out = array();
|
|
$out['su'] = $rep['su'] == 1;
|
|
$out['ssu'] = $rep['ssu'] == 1;
|
|
$out['langage'] = $rep['langage'];
|
|
$out['projectName'] = $rep['projectName'];
|
|
$out['name'] = $rep['name'];
|
|
$out['ID'] = $vid;
|
|
$out['fileAccessibility'] = $rep['fileAccessibility'];
|
|
$out['projectID'] = $rep['projectID'];
|
|
$out['alpha'] = ($rep['tags'] >> 0) % 2 === 1;
|
|
$out['beta'] = ($rep['tags'] >> 1) % 2 === 1;
|
|
$out['release'] = ($rep['tags'] >> 2) % 2 === 1;
|
|
$out['bugged'] = ($rep['tags'] >> 3) % 2 === 1;
|
|
|
|
$req = $GLOBALS['bdd']->query('SELECT * FROM verzions');
|
|
$out['brothers'] = array();
|
|
while($rep = $req->fetch()){
|
|
$version = array();
|
|
$version['language'] = $rep['language'];
|
|
$version['ID'] = $rep['ID'];
|
|
$version['name'] = $rep['name'];
|
|
$out['brothers'][] = $version;
|
|
}
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
}
|