extranet/library/Scores/WsScores.php
2011-02-16 14:41:54 +00:00

51 lines
1.4 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;
}
}
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;
}
}