extranet/library/Scores/WsScores.php
2011-04-01 12:14:40 +00:00

86 lines
2.3 KiB
PHP

<?php
class WsScores
{
protected $webservices = array();
protected $login = '';
protected $password = '';
public function __construct($login = '', $password = '') {
$config = new Zend_Config_Ini(APPLICATION_PATH .
'/configs/webservices.ini', APPLICATION_ENV);
$this->webservices = $config->webservices->toArray();
if ( !empty($login) && !empty($password) ){
$this->login = $login;
$this->password = $password;
} else {
$auth = Zend_Auth::getInstance();
$this->login = $auth->getIdentity()->username;
$this->password = md5($this->login.'|'.$auth->getIdentity()->password);
}
}
public function getInfosLogin($login, $ipUtilisateur = '') {
$params = new stdClass();
$params->login = $login;
$params->ipUtilisateur = $ipUtilisateur;
try {
$client = $this->loadClient('interne');
$reponse = $client->getInfosLogin($params);
return $reponse->getInfosLoginResult;
} catch (SoapFault $fault) {
//Placer exception pour affichage message
return false;
}
}
public function getNextLogin($login) {
$params = new stdClass();
$params->login = $login;
try {
$client = $this->loadClient('interne');
$reponse = $client->getNextLogin($params);
return $reponse->getNextLoginResult;
} catch (SoapFault $fault) {
//Placer exception pour affichage message
return false;
}
}
public function getListePrefs(){
try {
$client = $this->loadClient('interne');
$reponse = $client->getListePrefs();
return $reponse->getListePrefsResult;
} catch (SoapFault $fault) {
//Placer exception pour affichage message
return false;
}
}
public function getListeDroits() {
try {
$client = $this->loadClient('interne');
$reponse = $client->getListeDroits();
return $reponse->getListeDroitsResult;
} catch (SoapFault $fault) {
//Placer exception pour affichage message
return false;
}
}
protected function loadClient($webservice) {
$wsdl = $this->webservices[$webservice]['wsdl'];
$options = $this->webservices[$webservice]['options'];
$options['login'] = $this->login;
$options['password'] = $this->password;
if (APPLICATION_ENV != 'production'){
$options['cache_wsdl'] = WSDL_CACHE_NONE;
}
$options['encoding'] = 'utf-8';
$client = new SoapClient($wsdl, $options);
return $client;
}
}