Avec factorisation de la permission pour plus tard
This commit is contained in:
parent
57a15f7abe
commit
cdbc134d2e
@ -4,6 +4,7 @@ require_once __DIR__ . '/Types.php';
|
||||
|
||||
class Credit extends Scores_Ws_Server
|
||||
{
|
||||
protected $libdroits = 'searchent';
|
||||
/**
|
||||
* Retourne le nombre de crédit disponible à un utilisateur
|
||||
* @return int
|
||||
@ -11,7 +12,7 @@ class Credit extends Scores_Ws_Server
|
||||
public function getCredit()
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('searchent');
|
||||
$this->permission($this->libdroits);
|
||||
|
||||
$idUser = $this->User->id;
|
||||
|
||||
@ -43,7 +44,7 @@ class Credit extends Scores_Ws_Server
|
||||
{
|
||||
$info=new infoCredit();
|
||||
$this->authenticate();
|
||||
//$this->permission('credit');
|
||||
$this->permission($this->libdroits);
|
||||
|
||||
$idUser = $this->User->id;
|
||||
if(intval($idUser)==0){
|
||||
@ -90,8 +91,9 @@ class Credit extends Scores_Ws_Server
|
||||
* @param string ligneCredit
|
||||
* @return PayCredit
|
||||
*/
|
||||
public function payCredit($ligneCredit='toto')
|
||||
public function payCredit($ligneCredit='')
|
||||
{
|
||||
$this->permission($this->libdroits);
|
||||
$PayCreditResult=new PayCredit();
|
||||
$this->authenticate();
|
||||
$ir=(array)json_decode($ligneCredit);
|
||||
@ -99,6 +101,7 @@ class Credit extends Scores_Ws_Server
|
||||
$verifid=$tab[0];
|
||||
$idUser = $this->User->id;
|
||||
if($idUser!=$verifid){
|
||||
throw(new SoapFault('MSG', 'Erreur à l\'enregistrement de votre achat'));
|
||||
$PayCreditResult->message='Bad data format';
|
||||
$PayCreditResult->result=false;
|
||||
return $PayCreditResult;
|
||||
@ -106,6 +109,7 @@ class Credit extends Scores_Ws_Server
|
||||
$PayCreditResult->ligneCredit=$ligneCredit;
|
||||
$PayCreditResult->message='';
|
||||
if(empty($ir) || !isset($ir['idCmd'])){
|
||||
throw(new SoapFault('MSG', 'Erreur à l\'enregistrement de votre commande'));
|
||||
$PayCreditResult->message='Bad data format';
|
||||
$PayCreditResult->result=false;
|
||||
return $PayCreditResult;
|
||||
@ -165,6 +169,19 @@ class Credit extends Scores_Ws_Server
|
||||
return $PayCreditResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie le droit de consommer une page
|
||||
* @param $idLog
|
||||
* @return canUse
|
||||
*/
|
||||
public function canUse($idLog)
|
||||
{
|
||||
$canUse=new canUse();
|
||||
$canUse->idLog=$idLog;
|
||||
$canUse->typecredit=1;
|
||||
$canUse->result=true;
|
||||
return 1;
|
||||
}
|
||||
/**
|
||||
* Ajoute des crédits supplémentaires à un utilisateur
|
||||
* @param $nbCredit
|
||||
|
Loading…
Reference in New Issue
Block a user