issue #0000930 : Add method to override paramateres on user account

This commit is contained in:
Michael RICOIS 2013-03-20 17:57:51 +00:00
parent 4a6a785230
commit e0cf086458

View File

@ -1820,6 +1820,64 @@ class Gestion extends WsScore
return $output;
}
/**
* Override user params
* @param string $element
* @param int $idClient
* @param string $service
* @param string $login
* @throws SoapFault
* @return boolean
*/
protected function setParam($element, $idClient, $service, $login=null)
{
$element = strtoupper($element);
if ( !in_array($element, array('IP', 'ACCESS')) ) {
throw new SoapFault('ERR', 'Invalid parameters');
}
switch ($element) {
case 'IP':
break;
case 'ACCESS':
$logins = $this->_serviceLogins($idClient, $service);
if ( $login !== null ) {
if ( !in_array($login,$logins) ) {
throw new SoapFault('ERR', "Login not found");
} else {
$logins = array($login);
}
}
if ( count($logins)>0 ) {
//Get access
if ($service == 'DEFAULT') {
$clientM = new Application_Model_Sdv1Clients();
$sql = $clientM->select()->where('idClient=?', $idClient);
$row = $clientM->fetchRow($sql);
$droits = $row->droits;
} else {
$serviceM = new Application_Model_Sdv1ClientsServices();
$sql = $serviceM->select()->where('code=?', $service);
$row = $serviceM->fetchRow($sql);
$droits = $row->droits;
}
//Override access
$userM = new Application_Model_Sdv1Utilisateurs();
$result = $userM->update(array('droits'=>$droits), 'login IN ('.join(',',$logins).')');
}
break;
}
if (empty($result)) {
return false;
}
return true;
}
/**
* Remove access to the children
* @param array $toDelete