Enregistrement des requetes webservice dans le cache

This commit is contained in:
Michael RICOIS 2011-04-28 10:26:36 +00:00
parent ab49b9c1e3
commit df4d7671e1
2 changed files with 41 additions and 9 deletions

View File

@ -9,6 +9,22 @@ class Utilisateur
$this->identity = $auth->getIdentity();
}
/**
* Retourne le login de l'utiliateur
*/
public function getLogin()
{
return $this->identity->username;
}
/**
* Retourne le password de l'utilisateur
*/
public function getPassword()
{
return $this->identity->password;
}
/**
* Retourne l'email de l'utilisateur
*/
@ -37,7 +53,10 @@ class Utilisateur
return $this->identity->nbRep;
}
/**
* Vérifie que l'utiliasteur a le mode edition
* @return boolean
*/
public function checkModeEdition()
{
//On vérfie le mode edition dans les permissions

View File

@ -1,10 +1,14 @@
<?php
require_once realpath(dirname(__FILE__)).'/Cache.php';
require_once realpath(dirname(__FILE__)).'/Utilisateur.php';
class WsScores
{
protected $webservices = array();
protected $login = '';
protected $password = '';
protected $nbReponses = 20;
protected $toNotCache = false;
public function __construct($login = '', $password = '')
{
@ -16,10 +20,13 @@ class WsScores
$this->login = $login;
$this->password = $password;
} else {
$auth = Zend_Auth::getInstance();
$this->login = $auth->getIdentity()->username;
$this->password = md5($this->login.'|'.$auth->getIdentity()->password);
$this->nbReponses = $auth->getIdentity()->nbReponses;
$user = new Utilisateur();
$this->login = $user->getLogin();
$this->password = md5($user->getLogin().'|'.$user->getPassword());
$this->nbReponses = $user->getNbRep();
if ( $user->checkModeEdition() ) {
$this->toNotCache = true;
}
}
}
@ -46,7 +53,8 @@ class WsScores
* @param integer $position
* @param integer $nbAffichage
*/
public function getPortefeuille($filtre, $position = 0, $nbAffichage = 100) {
public function getPortefeuille($filtre, $position = 0, $nbAffichage = 100)
{
$params = new StdClass;
$params->filtre = $filtre;
$params->deb = $position;
@ -198,7 +206,6 @@ class WsScores
}
}
/**
* getIdentite
* @param string $siret
@ -210,9 +217,15 @@ class WsScores
$params = new StdClass();
$params->siret = $siret;
$params->id = $id;
$cache = new Cache('identite-'.$siret.'-'.$id);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('identite');
}
$client = $this->loadClient('entreprise');
try {
$reponse = $client->getIdentite($params);
$cache->deletefile();
$cache->setBlock('identite', $reponse->getIdentiteResult);
return $reponse->getIdentiteResult;
} catch (SoapFault $fault) {
return false;
@ -352,8 +365,8 @@ class WsScores
/**
* getInfosLogin
* @param unknown_type $login
* @param unknown_type $ipUtilisateur
* @param string $login
* @param string $ipUtilisateur
*/
public function getInfosLogin($login, $ipUtilisateur = '')
{