Gestion des erreurs SQL
This commit is contained in:
parent
c29a6f3906
commit
6f0de74424
@ -62,7 +62,13 @@ class Gestion extends Scores_Ws_Server
|
||||
'login' => $this->User->login,
|
||||
'userAgent' => $browser,
|
||||
));
|
||||
} catch (Zend_Db_Exception $e) {}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Retourne un minimum d'information pour les applications
|
||||
@ -382,21 +388,25 @@ class Gestion extends Scores_Ws_Server
|
||||
$client = $this->User->idClient;
|
||||
}
|
||||
|
||||
//Uniquement si l'utilisateur est administrateur et dans le service DEFAULT
|
||||
if ( $this->User->profil != 'Administrateur' ) {
|
||||
// Uniquement si l'utilisateur est administrateur et dans le service DEFAULT
|
||||
if ( !in_array($this->User->profil, array('Administrateur', 'SuperAdministrateur')) ) {
|
||||
throw new SoapFault('ERR', 'Accès non authorisé');
|
||||
}
|
||||
|
||||
$serviceM = new Application_Model_Sdv1ClientsServices();
|
||||
$sql = $serviceM->select()
|
||||
->where('IdClient=?', $client)
|
||||
->where('Deleted=0');
|
||||
|
||||
$result = $serviceM->fetchAll($sql);
|
||||
|
||||
try {
|
||||
$serviceSql = $serviceM->select()->where('IdClient=?', $client) ->where('Deleted=?', 0);
|
||||
$serviceResult = $serviceM->fetchAll($serviceSql);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
$services = array();
|
||||
if ( count($result) > 0 ) {
|
||||
foreach ( $result as $item ) {
|
||||
if ( count($serviceResult) > 0 ) {
|
||||
foreach ($serviceResult as $item) {
|
||||
$service = new ServiceList();
|
||||
$service->id = $item->id;
|
||||
$service->IdClient = $item->IdClient;
|
||||
@ -430,13 +440,18 @@ class Gestion extends Scores_Ws_Server
|
||||
|
||||
$client = $this->User->idClient;
|
||||
|
||||
//Détail d'un service
|
||||
// Détail d'un service
|
||||
$serviceM = new Application_Model_Sdv1ClientsServices();
|
||||
$sql = $serviceM->select()
|
||||
->where('IdClient=?', $client)
|
||||
->where('Deleted=?', 0)
|
||||
->where('id=?', $id);
|
||||
$result = $serviceM->fetchRow($sql);
|
||||
try {
|
||||
$sql = $serviceM->select()->where('IdClient=?', $client)->where('Deleted=?', 0)->where('id=?', $id);
|
||||
$result = $serviceM->fetchRow($sql);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
if ( $result === null ) {
|
||||
throw new SoapFault('ERR', 'Service introuvable.');
|
||||
@ -447,7 +462,7 @@ class Gestion extends Scores_Ws_Server
|
||||
$output->Code = $result->Code;
|
||||
$output->Label = $result->Label;
|
||||
$output->TypeCompte = $result->TypeCompte;
|
||||
$output->TypeAcess = $result->TypeAcess;
|
||||
$output->TypeAcces = $result->TypeAcces;
|
||||
$output->TypeScore = $result->TypeScore;
|
||||
$output->Timeout = $result->Timeout;
|
||||
$output->Editable = $result->Editable;
|
||||
@ -455,14 +470,22 @@ class Gestion extends Scores_Ws_Server
|
||||
$output->DateInsert = $result->DateInsert;
|
||||
$output->DateUpdate = $result->DateUpdate;
|
||||
|
||||
//Droits
|
||||
$serviceCode = $result->Code;
|
||||
|
||||
// Droits
|
||||
$output->Acces = array();
|
||||
$serviceDroitsM = new Application_Model_Sdv1ClientsServicesDroits();
|
||||
$sql = $serviceDroitsM->select()
|
||||
->where('IdClient=?', $client)
|
||||
->where('Service=?', $serviceCode);
|
||||
$result = $serviceDroitsM->fetchAll($sql);
|
||||
if ( count($result)>0 ) {
|
||||
$serviceDroitsM = new Application_Model_Sdv1ClientsServicesDroits();
|
||||
try {
|
||||
$sql = $serviceDroitsM->select()->where('IdClient=?', $client)->where('Service=?', $serviceCode);
|
||||
$result = $serviceDroitsM->fetchAll($sql);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
if (count($result) > 0) {
|
||||
foreach ( $result as $item ) {
|
||||
$acces = new AccesDetails();
|
||||
$acces->Code = $item->Acces;
|
||||
@ -471,15 +494,21 @@ class Gestion extends Scores_Ws_Server
|
||||
}
|
||||
}
|
||||
|
||||
//IP
|
||||
// IP
|
||||
$output->IP = array();
|
||||
$serviceIPM = new Application_Model_Sdv1ClientsServicesIP();
|
||||
$sql = $serviceIPM->select()
|
||||
->where('IdClient=?', $client)
|
||||
->where('Service=?', $serviceCode);
|
||||
$result = $serviceDroitsM->fetchAll($sql);
|
||||
if ( count($result)>0 ) {
|
||||
foreach ( $result as $item ) {
|
||||
try {
|
||||
$sql = $serviceIPM->select()->where('IdClient=?', $client)->where('Service=?', $serviceCode);
|
||||
$result = $serviceIPM->fetchAll($sql);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $item) {
|
||||
$output->IP[] = $item->IP;
|
||||
}
|
||||
}
|
||||
@ -629,19 +658,19 @@ class Gestion extends Scores_Ws_Server
|
||||
*/
|
||||
public function getUserList($actif = null, $service = null, $client = null)
|
||||
{
|
||||
//Liste des utilisateurs - filtre au service
|
||||
// Liste des utilisateurs - filtre au service
|
||||
$this->authenticate();
|
||||
|
||||
if ( $client === null ) {
|
||||
$client = $this->User->idClient;
|
||||
}
|
||||
|
||||
//Administrateur
|
||||
// Administrateur
|
||||
if ( !in_array($this->User->profil, array('Administrateur', 'SuperAdministrateur')) ) {
|
||||
throw new SoapFault('ERR', 'Accès non authorisé');
|
||||
}
|
||||
|
||||
//Administrateur d'un service
|
||||
// Administrateur d'un service
|
||||
if ( $this->User->Service != '' && $this->User->Service !== null && $this->User->Service !== 'DEFAULT' ) {
|
||||
$service = $this->User->Service;
|
||||
}
|
||||
@ -653,17 +682,17 @@ class Gestion extends Scores_Ws_Server
|
||||
->from(array('u'=>'sdv1.utilisateurs'), array('id','idClient','login','email','civilite','nom','prenom','actif','deleted'))
|
||||
->joinLeft(array('s'=>'sdv1.utilisateurs_service'), 'u.login=s.login', array('Service'))
|
||||
->joinLeft(array('sd'=>'sdv1.clients_services'), 'sd.Code=s.Service', array('Label'))
|
||||
->where('u.idClient=?',$client);
|
||||
->where('u.idClient=?', $client);
|
||||
|
||||
if ( $actif !== null && in_array($actif, array(0,1)) ) {
|
||||
$sql->where('u.actif=?', $actif);
|
||||
}
|
||||
$sql->where('u.deleted=?',0);
|
||||
$sql->where('u.deleted=?', 0);
|
||||
|
||||
if ($service == 'DEFAULT') {
|
||||
$sql->where('(s.Service IS NULL AND u.idClient='.$client.') OR (s.Service IS NOT NULL AND u.idClient='.$client.' AND u.idClient='.$client.' AND sd.idClient='.$client.') OR sd.Code="'.$service.'"');
|
||||
} else if ( $service !== null ) {
|
||||
$sql->where('s.Service=?', $service);
|
||||
if ($service->Code == 'DEFAULT') {
|
||||
$sql->where('(s.Service IS NULL) OR (s.Service="DEFAULT" AND sd.idClient='.$client.') OR sd.Code='.$service);
|
||||
} else {
|
||||
$sql->where('sd.Code=?', $service);
|
||||
}
|
||||
|
||||
$result = $userM->fetchAll($sql);
|
||||
|
Loading…
Reference in New Issue
Block a user