Merge branch 'wip-gestion' into develop
This commit is contained in:
commit
ea1cc53e85
@ -192,12 +192,9 @@ class ServiceController extends Zend_Controller_Action
|
||||
// --- Pour débuggage ultime
|
||||
$debug = false;
|
||||
$debugUser = '';
|
||||
if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser)
|
||||
{
|
||||
if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser) {
|
||||
file_put_contents(APPLICATION_PATH . '/../debugcall.log',
|
||||
"FichierWSDL : ".$fichierWsdl."\n".
|
||||
"Hostname : ".$hostName."\n"
|
||||
);
|
||||
"FichierWSDL : ".$fichierWsdl."\n"."Hostname : ".$hostName."\n");
|
||||
$request = $server->getLastRequest();
|
||||
file_put_contents(APPLICATION_PATH . '/../debugcall.log', $request . "\n", FILE_APPEND);
|
||||
$response = $server->getLastResponse();
|
||||
|
17
library/WsScore/Account/v0.1/Config.php
Normal file
17
library/WsScore/Account/v0.1/Config.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
return array(
|
||||
'Client' => 'Client',
|
||||
'ClientServices' => 'ClientServices',
|
||||
'ClientServicesList' => 'ClientServicesList',
|
||||
'ServiceList' => 'ServiceList',
|
||||
'Service' => 'Service',
|
||||
'UserList' => 'UserList',
|
||||
'User' => 'User',
|
||||
'Acces' => 'Acces',
|
||||
'AccesCategory' => 'AccesCategory',
|
||||
'AuthParam' => 'AuthParam',
|
||||
'AuthLog' => 'AuthLog',
|
||||
'AuthLogItem' => 'AuthLogItem',
|
||||
'UserLog' => 'UserLog',
|
||||
'UserLogItem' => 'UserLogItem',
|
||||
);
|
1434
library/WsScore/Account/v0.1/Service.php
Normal file
1434
library/WsScore/Account/v0.1/Service.php
Normal file
File diff suppressed because it is too large
Load Diff
292
library/WsScore/Account/v0.1/Types.php
Normal file
292
library/WsScore/Account/v0.1/Types.php
Normal file
@ -0,0 +1,292 @@
|
||||
<?php
|
||||
class Client
|
||||
{
|
||||
/** @var string */
|
||||
public $Nom;
|
||||
|
||||
/** @var string */
|
||||
public $Siren;
|
||||
|
||||
/** @var string */
|
||||
public $Nic;
|
||||
|
||||
/** @var int */
|
||||
public $Actif;
|
||||
|
||||
/** @var int */
|
||||
public $Test;
|
||||
}
|
||||
|
||||
class ClientServices
|
||||
{
|
||||
/** @var string */
|
||||
public $Nom;
|
||||
|
||||
/** @var string */
|
||||
public $Siren;
|
||||
|
||||
/** @var string */
|
||||
public $Nic;
|
||||
|
||||
/** @var int */
|
||||
public $Actif;
|
||||
|
||||
/** @var int */
|
||||
public $Test;
|
||||
|
||||
/** @var ClientServicesList[] */
|
||||
public $Services;
|
||||
}
|
||||
|
||||
class ClientServicesList
|
||||
{
|
||||
/** @var int */
|
||||
public $id;
|
||||
|
||||
/** @var string */
|
||||
public $Code;
|
||||
|
||||
/** @var string */
|
||||
public $Label;
|
||||
|
||||
/** @var string */
|
||||
public $Editable;
|
||||
|
||||
/** @var string */
|
||||
public $Active;
|
||||
}
|
||||
|
||||
class ServiceList
|
||||
{
|
||||
/** @var int */
|
||||
public $id;
|
||||
|
||||
/** @var int */
|
||||
public $IdClient;
|
||||
|
||||
/** @var string */
|
||||
public $Code;
|
||||
|
||||
/** @var string */
|
||||
public $Label;
|
||||
|
||||
/** @var string */
|
||||
public $TypeCompte;
|
||||
|
||||
/** @var string */
|
||||
public $TypeAcces;
|
||||
|
||||
/** @var string */
|
||||
public $TypeScore;
|
||||
|
||||
/** @var string */
|
||||
public $Timeout;
|
||||
|
||||
/** @var string */
|
||||
public $Editable;
|
||||
|
||||
/** @var string */
|
||||
public $Active;
|
||||
|
||||
/** @var string */
|
||||
public $DateInsert;
|
||||
|
||||
/** @var string */
|
||||
public $DateUpdate;
|
||||
}
|
||||
|
||||
class Service
|
||||
{
|
||||
/** @var int */
|
||||
public $id;
|
||||
|
||||
/** @var int */
|
||||
public $IdClient;
|
||||
|
||||
/** @var string */
|
||||
public $Code;
|
||||
|
||||
/** @var string */
|
||||
public $Label;
|
||||
|
||||
/** @var string */
|
||||
public $TypeCompte;
|
||||
|
||||
/** @var string */
|
||||
public $TypeAcces;
|
||||
|
||||
/** @var string */
|
||||
public $TypeScore;
|
||||
|
||||
/** @var string */
|
||||
public $Timeout;
|
||||
|
||||
/** @var string */
|
||||
public $Editable;
|
||||
|
||||
/** @var string */
|
||||
public $Active;
|
||||
|
||||
/** @var string */
|
||||
public $DateInsert;
|
||||
|
||||
/** @var string */
|
||||
public $DateUpdate;
|
||||
|
||||
/** @var Acces[] */
|
||||
public $Acces;
|
||||
|
||||
/** @var string[] */
|
||||
public $IP;
|
||||
}
|
||||
|
||||
|
||||
class UserList
|
||||
{
|
||||
/** @var int */
|
||||
public $id;
|
||||
|
||||
/** @var int */
|
||||
public $IdClient;
|
||||
|
||||
/** @var string */
|
||||
public $ServiceCode;
|
||||
|
||||
/** @var string */
|
||||
public $ServiceLabel;
|
||||
|
||||
/** @var string */
|
||||
public $Login;
|
||||
|
||||
/** @var string */
|
||||
public $Email;
|
||||
|
||||
/** @var string */
|
||||
public $Civilite;
|
||||
|
||||
/** @var string */
|
||||
public $Nom;
|
||||
|
||||
/** @var string */
|
||||
public $Prenom;
|
||||
|
||||
/** @var string */
|
||||
public $Enable;
|
||||
|
||||
/** @var string */
|
||||
public $Delete;
|
||||
}
|
||||
|
||||
class User
|
||||
{
|
||||
/** @var int */
|
||||
public $id;
|
||||
|
||||
/** @var int */
|
||||
public $IdClient;
|
||||
|
||||
/** @var string */
|
||||
public $ServiceCode;
|
||||
|
||||
/** @var string */
|
||||
public $ServiceLabel;
|
||||
|
||||
/** @var string */
|
||||
public $Login;
|
||||
|
||||
/** @var string */
|
||||
public $Email;
|
||||
|
||||
/** @var string */
|
||||
public $Civilite;
|
||||
|
||||
/** @var string */
|
||||
public $Nom;
|
||||
|
||||
/** @var string */
|
||||
public $Prenom;
|
||||
|
||||
/** @var string */
|
||||
public $Enable;
|
||||
|
||||
/** @var string */
|
||||
public $Delete;
|
||||
|
||||
/** @var Acces[] */
|
||||
public $Acces;
|
||||
|
||||
/** @var string[] */
|
||||
public $IP;
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Acces
|
||||
{
|
||||
/** @var string */
|
||||
public $Code;
|
||||
|
||||
/** @var string */
|
||||
public $Label;
|
||||
}
|
||||
|
||||
|
||||
class AccesCategory
|
||||
{
|
||||
/** @var string */
|
||||
public $Code;
|
||||
|
||||
/** @var string */
|
||||
public $Label;
|
||||
|
||||
/** @var string[] */
|
||||
public $Acces;
|
||||
}
|
||||
|
||||
class AuthParam
|
||||
{
|
||||
/** @var string */
|
||||
public $label;
|
||||
|
||||
/** @var string */
|
||||
public $value;
|
||||
}
|
||||
|
||||
class AuthLog
|
||||
{
|
||||
/** @var int */
|
||||
public $Total;
|
||||
|
||||
/** @var AuthLogItem[] */
|
||||
public $List;
|
||||
}
|
||||
|
||||
class AuthLogItem
|
||||
{
|
||||
/** @var string */
|
||||
public $IP;
|
||||
|
||||
/** @var string */
|
||||
public $Date;
|
||||
}
|
||||
|
||||
class UserLog
|
||||
{
|
||||
/** @var int */
|
||||
public $Total;
|
||||
|
||||
/** @var UserLogItem[] */
|
||||
public $List;
|
||||
}
|
||||
|
||||
class UserLogItem
|
||||
{
|
||||
/** @var string */
|
||||
public $CompanyId;
|
||||
|
||||
/** @var string */
|
||||
public $CompanyName;
|
||||
|
||||
/** @var string */
|
||||
public $Date;
|
||||
}
|
@ -33,7 +33,6 @@ class Gestion extends Scores_Ws_Server
|
||||
$this->authenticate();
|
||||
|
||||
// --- Enregistrement authentification OK
|
||||
// @todo : Ajout userAgent
|
||||
try {
|
||||
$authLogM = new Application_Model_Sdv1UtilisateursAuthLog();
|
||||
$authLogM->insert(array(
|
||||
@ -45,28 +44,31 @@ class Gestion extends Scores_Ws_Server
|
||||
} catch (Zend_Db_Exception $e) {}
|
||||
|
||||
|
||||
//Check App authorization - Find Service parameters
|
||||
// --- Check App authorization - Find Service parameters
|
||||
$serviceM = new Application_Model_Sdv1ClientsServices();
|
||||
$sql = $serviceM->select()
|
||||
->where('IdClient=?', $this->User->idClient)
|
||||
->where('Code=?', $this->User->serviceCode);
|
||||
$serviceParams = $serviceM->fetchRow($sql);
|
||||
|
||||
//Save information in database
|
||||
//id, clientId, userId, login, ip, userAgent, dateLogin
|
||||
//Enregistrement informations navigateur uniquement si bien identifié
|
||||
// --- Enregistrement informations navigateur uniquement si bien identifié
|
||||
if ($browser !== null) {
|
||||
try {
|
||||
$browserLogM = new Application_Model_Sdv1UtilisateursBrowserLog();
|
||||
$browserLogM->insert(array(
|
||||
'idClient' => $this->User->idClient,
|
||||
'idUser' => $this->User->id,
|
||||
'clientId' => $this->User->idClient,
|
||||
'userId' => $this->User->id,
|
||||
'service' => $this->User->serviceCode,
|
||||
'login' => $this->User->login,
|
||||
'authenticate' => 'OK',
|
||||
'ip' => $ip,
|
||||
'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
|
||||
@ -349,7 +351,7 @@ class Gestion extends Scores_Ws_Server
|
||||
return $client;
|
||||
}
|
||||
|
||||
protected function getContrats()
|
||||
protected function getContratList()
|
||||
{
|
||||
//Liste des contrats, par service résumé
|
||||
|
||||
@ -377,7 +379,7 @@ class Gestion extends Scores_Ws_Server
|
||||
* Id client
|
||||
* @return ServiceList[]
|
||||
*/
|
||||
public function getServices($client = null)
|
||||
public function getServiceList($client = null)
|
||||
{
|
||||
//Liste des services
|
||||
$this->authenticate();
|
||||
@ -387,20 +389,24 @@ class Gestion extends Scores_Ws_Server
|
||||
}
|
||||
|
||||
// Uniquement si l'utilisateur est administrateur et dans le service DEFAULT
|
||||
if ( $this->User->profil != 'Administrateur' ) {
|
||||
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;
|
||||
@ -424,11 +430,11 @@ class Gestion extends Scores_Ws_Server
|
||||
|
||||
/**
|
||||
* Détail d'un service
|
||||
* @param int $id
|
||||
* @param string $code
|
||||
* @throws SoapFault
|
||||
* @return Service
|
||||
*/
|
||||
public function getService($id)
|
||||
public function getService($code)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
@ -436,11 +442,16 @@ class Gestion extends Scores_Ws_Server
|
||||
|
||||
// Détail d'un service
|
||||
$serviceM = new Application_Model_Sdv1ClientsServices();
|
||||
$sql = $serviceM->select()
|
||||
->where('IdClient=?', $client)
|
||||
->where('Deleted=?', 0)
|
||||
->where('id=?', $id);
|
||||
try {
|
||||
$sql = $serviceM->select()->where('IdClient=?', $client)->where('Deleted=?', 0)->where('Code=?', $code);
|
||||
$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.');
|
||||
@ -448,10 +459,11 @@ class Gestion extends Scores_Ws_Server
|
||||
|
||||
$output = new Service();
|
||||
$output->id = $result->id;
|
||||
$output->IdClient = $client;
|
||||
$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;
|
||||
@ -459,13 +471,21 @@ class Gestion extends Scores_Ws_Server
|
||||
$output->DateInsert = $result->DateInsert;
|
||||
$output->DateUpdate = $result->DateUpdate;
|
||||
|
||||
$serviceCode = $result->Code;
|
||||
|
||||
// Droits
|
||||
$output->Acces = array();
|
||||
$serviceDroitsM = new Application_Model_Sdv1ClientsServicesDroits();
|
||||
$sql = $serviceDroitsM->select()
|
||||
->where('IdClient=?', $client)
|
||||
->where('Service=?', $serviceCode);
|
||||
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();
|
||||
@ -478,10 +498,16 @@ class Gestion extends Scores_Ws_Server
|
||||
// IP
|
||||
$output->IP = array();
|
||||
$serviceIPM = new Application_Model_Sdv1ClientsServicesIP();
|
||||
$sql = $serviceIPM->select()
|
||||
->where('IdClient=?', $client)
|
||||
->where('Service=?', $serviceCode);
|
||||
$result = $serviceDroitsM->fetchAll($sql);
|
||||
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;
|
||||
@ -631,7 +657,7 @@ class Gestion extends Scores_Ws_Server
|
||||
* @param string $client Id du client
|
||||
* @return UserList[]
|
||||
*/
|
||||
public function getUsers($actif = null, $service = null, $client = null)
|
||||
public function getUserList($actif = null, $service = null, $client = null)
|
||||
{
|
||||
// Liste des utilisateurs - filtre au service
|
||||
$this->authenticate();
|
||||
@ -665,11 +691,10 @@ class Gestion extends Scores_Ws_Server
|
||||
$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);
|
||||
$sql->where('(s.Service IS NULL) OR (s.Service="DEFAULT" AND sd.idClient='.$client.')');
|
||||
} else {
|
||||
$sql->where('sd.Code=?', $service);
|
||||
}
|
||||
|
||||
$result = $userM->fetchAll($sql);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
@ -703,7 +728,7 @@ class Gestion extends Scores_Ws_Server
|
||||
return $users;
|
||||
}
|
||||
|
||||
protected function getUsersByFile($actif = null, $service = null, $client = null)
|
||||
protected function getUsersFile($actif = null, $service = null, $client = null)
|
||||
{
|
||||
|
||||
}
|
||||
@ -785,8 +810,8 @@ class Gestion extends Scores_Ws_Server
|
||||
if ( count($droits) > 0 ) {
|
||||
foreach ($droits as $item) {
|
||||
$acces = new Acces();
|
||||
$acces->Code = $item->Acces;
|
||||
$acces->Label = $this->listeDroits[$item->Acces];
|
||||
$acces->Code = strtoupper($item->Acces);
|
||||
$acces->Label = $this->listeDroits[strtoupper($item->Acces)];
|
||||
$output->Acces[] = $acces;
|
||||
}
|
||||
}
|
||||
@ -802,7 +827,6 @@ class Gestion extends Scores_Ws_Server
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Service - IP
|
||||
try {
|
||||
$ipM = new Application_Model_Sdv1ClientsServicesIP();
|
||||
@ -869,10 +893,160 @@ class Gestion extends Scores_Ws_Server
|
||||
return $emails;
|
||||
}
|
||||
|
||||
protected function getUserLogByFile($id){}
|
||||
/**
|
||||
* Log des consultations
|
||||
* @param string $month AAAAMM
|
||||
* @param string $item
|
||||
* Code de l'élément
|
||||
* @param integer $p
|
||||
* @param integer $limit
|
||||
*/
|
||||
public function getUserLog($month, $item, $p=0, $limit=50)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
$selectedYear = date('Y');
|
||||
$selectedMonth = date('m');
|
||||
|
||||
$item = 'identite';
|
||||
|
||||
// --- Generate SQL
|
||||
$logM = new Application_Model_Sdv1Logs();
|
||||
$logSql = $logM->select()
|
||||
->where('login=?', $this->User->login)
|
||||
->where('page=?', $item)
|
||||
->where('dateHeure BETWEEN "'.$selectedYear.'-'.$selectedMonth.'-00 00:00:00" AND "'.
|
||||
$selectedYear.'-'.$selectedMonth.'-31 23:59:59"');
|
||||
|
||||
// --- Get total
|
||||
$cols = new Zend_Db_Expr("COUNT(*) AS NB");
|
||||
$logSql->columns($cols);
|
||||
$totalResult = $logM->fetchRow($logSql);
|
||||
|
||||
$output = new UserLog();
|
||||
$output->Total = $totalResult->NB;
|
||||
$output->List = array();
|
||||
|
||||
if ($totalResult->NB > 0) {
|
||||
// --- Get Row
|
||||
$logSql->columns(array('LPAD(siren,9,0) AS siren', 'LPAD(nic,5,0) AS nic', 'raisonSociale'));
|
||||
$logSql->order('dateHeure DESC')->limitPage($p, $limit);
|
||||
$logResult = $logM->fetchAll($logSql);
|
||||
foreach ($logResult as $l) {
|
||||
$struct = new UserLogItem();
|
||||
$companyId = $l->siren;
|
||||
if (intval($l->nic) > 0) {
|
||||
$companyId.= $l->nic;
|
||||
}
|
||||
$struct->CompanyId = $companyId;
|
||||
$struct->CompanyType = 'SIREN';
|
||||
$struct->CompanyName = $l->raisonSociale;
|
||||
$struct->Date = $l->dateHeure;
|
||||
$output->List[] = $struct;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function getUserLogFile($id){}
|
||||
|
||||
/**
|
||||
* Définition d'un utilisateur
|
||||
* Company User History (10 last)
|
||||
* @param int $id
|
||||
* @param int $limit
|
||||
* @return UserLogItem[]
|
||||
*/
|
||||
public function getUserHistory($id=null, $limit=10)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
$selectedYear = date('Y');
|
||||
$selectedMonth = date('m');
|
||||
|
||||
$output = array();
|
||||
|
||||
// --- Generate SQL
|
||||
try {
|
||||
$logSubquery = "SELECT siren, MAX(dateHeure) AS MaxDateHeure FROM logs WHERE login='".$this->User->login."' AND page='identite' GROUP BY siren";
|
||||
$logSql = "SELECT LPAD(x.siren,9,0) AS siren, LPAD(x.nic,5,0) AS nic, x.raisonSociale, x.dateHeure FROM logs x ".
|
||||
"JOIN (".$logSubquery.") y ON y.siren = x.siren AND y.MaxDateHeure = x.dateHeure ".
|
||||
"ORDER BY x.dateHeure DESC LIMIT 0,".$limit;
|
||||
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
|
||||
$db->setFetchMode(Zend_Db::FETCH_OBJ);
|
||||
$logResult = $db->fetchAll($logSql);
|
||||
foreach ($logResult as $l) {
|
||||
$struct = new UserLogItem();
|
||||
$companyId = $l->siren;
|
||||
if (intval($l->nic) > 0) {
|
||||
$companyId.= $l->nic;
|
||||
}
|
||||
$struct->CompanyId = $companyId;
|
||||
$struct->CompanyType = 'SIREN';
|
||||
$struct->CompanyName = $l->raisonSociale;
|
||||
$struct->Date = $l->dateHeure;
|
||||
$output[] = $struct;
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', 'Application Error.');
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log d'authentification
|
||||
* @param string $month Date (AAAAMM)
|
||||
* @param string $type (OK, KO)
|
||||
* @param integer $p
|
||||
* @param integer $limit
|
||||
*/
|
||||
public function getAuthLog($month, $type, $p=0, $limit=20)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
$selectedYear = date('Y');
|
||||
$selectedMonth = date('m');
|
||||
|
||||
// --- Generate SQL
|
||||
$logM = new Application_Model_Sdv1UtilisateursAuthLog();
|
||||
$logSql = $logM->select()
|
||||
->where('login=?', $this->User->login)
|
||||
->where('authenticate=?', 'OK')
|
||||
->where('dateInsert BETWEEN "'.$selectedYear.'-'.$selectedMonth.'-00 00:00:00" AND "'.
|
||||
$selectedYear.'-'.$selectedMonth.'-31 23:59:59"');
|
||||
|
||||
// --- Get total
|
||||
$cols = new Zend_Db_Expr("COUNT(*) AS NB");
|
||||
$logSql->columns($cols);
|
||||
$totalResult = $logM->fetchRow($logSql);
|
||||
|
||||
$output = new AuthLog();
|
||||
$output->Total = $totalResult->NB;
|
||||
$output->List = array();
|
||||
|
||||
if ($totalResult->NB > 0) {
|
||||
// --- Get Row
|
||||
$logSql->columns(array('IP', 'dateInsert AS Date'));
|
||||
$logsSql->order('dateInsert DESC')->limitPage($p, $limit);
|
||||
$logResult = $logM->fetchAll($logSql);
|
||||
foreach ($logResult as $item) {
|
||||
$struct = new AuthLogItem();
|
||||
$struct->IP = $item->IP;
|
||||
$struct->Date = $item->Date;
|
||||
$output->List[] = $struct;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paramétrage d'un utilisateur
|
||||
* @param string $data
|
||||
* @param int $id
|
||||
* @throws SoapFault
|
||||
@ -882,75 +1056,52 @@ class Gestion extends Scores_Ws_Server
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
//Vérification des droits de création d'utilisateur
|
||||
// --- Vérification des droits de création d'utilisateur
|
||||
if ( $this->User->id != $id || !in_array($this->User->profil, array('SuperAdministrateur', 'Administrateur')) ) {
|
||||
throw new SoapFault('ERR', 'Accès non authorisé');
|
||||
}
|
||||
|
||||
$infos = json_decode($data);
|
||||
$values = json_decode($data);
|
||||
|
||||
$userM = new Application_Model_Sdv1Utilisateurs();
|
||||
|
||||
$userData = array(
|
||||
'idClient',
|
||||
'login',
|
||||
'email',
|
||||
'idClient' => $values['idClient'],
|
||||
'login' => trim($values['login']),
|
||||
'email' => strtolower(trim($values['email'])),
|
||||
'password' => '',
|
||||
'actif' => 0,
|
||||
'actif' => 1,
|
||||
'deleted' => 0,
|
||||
'typeCompte' => 'PROD',
|
||||
'filtre_ip' => '',
|
||||
'civilite' => 'M',
|
||||
'nom' => '',
|
||||
'prenom' => '',
|
||||
'raisonSociale' => '',
|
||||
'siret' => '000000000',
|
||||
'adrNum' => null,
|
||||
'adrIndRep' => null,
|
||||
'adrTypeVoie' => null,
|
||||
'adrLibVoie' => '',
|
||||
'adrCp' => null,
|
||||
`adrVille` => null,
|
||||
`adrComp` => '',
|
||||
'tel' => '',
|
||||
'fax' => null,
|
||||
'mobile' => null,
|
||||
'pref' => '',
|
||||
'civilite' => $values['civilite'],
|
||||
'nom' => trim($values['nom']),
|
||||
'prenom' => trim($values['prenom']),
|
||||
'profil' => 'Utilisateur',
|
||||
'dateInscription' => '0000-00-00 00:00:00',
|
||||
'dateValidation' => '0000-00-00 00:00:00',
|
||||
'nombreConnexions' => '0',
|
||||
'dateDerniereConnexion' => '0000-00-00 00:00:00',
|
||||
'droits' => '',
|
||||
'referenceParDefaut' => '',
|
||||
'nbReponses' => '020',
|
||||
'lang' => null,
|
||||
'formatMail' => 'txt1',
|
||||
'nbReponses' => 10,
|
||||
'lang' => 'fr',
|
||||
'formatMail' => 'txt2',
|
||||
'lienExtranetMail' => 0,
|
||||
'lienSurvFic' => 0,
|
||||
'idSurvFic' => '',
|
||||
'loginCptSurvFic' => '',
|
||||
'listeEven' => '',
|
||||
'dateDebutCompte' => null,
|
||||
'dateFinCompte' => null,
|
||||
'maxFicheId' => null,
|
||||
'accesWS' => '0',
|
||||
'rechRefType' => 'UTI',
|
||||
'acceptationCGU' => null,
|
||||
);
|
||||
|
||||
// --- Création
|
||||
if ( $id === null ) {
|
||||
|
||||
$sql = $userM->select()->where('login=?', $infos->login);
|
||||
$sql = $userM->select()->where('login=?', $values['login']);
|
||||
$row = $userM->fetchRow($sql);
|
||||
//Utilisateur existant
|
||||
// --- Utilisateur existant
|
||||
if ( null !== $row ) {
|
||||
throw new SoapFault('ERR', "User exist");
|
||||
}
|
||||
//Prepare data to insert
|
||||
foreach ($infos as $key => $value) {
|
||||
// --- Prepare data to insert
|
||||
foreach ($values as $key => $value) {
|
||||
if (array_key_exists($key, $userData)) {
|
||||
$userData[$key] = $value;
|
||||
$userData[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
$userData['dateInsert'] = date('YmdHis');
|
||||
@ -975,22 +1126,24 @@ class Gestion extends Scores_Ws_Server
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
}
|
||||
// --- Modification
|
||||
else {
|
||||
|
||||
$sql = $userM->select()->where('id=?', $id);
|
||||
$row = $userM->fetchRow($sql);
|
||||
if ( null === $row ) {
|
||||
throw new SoapFault('ERR', "User doesn't exist");
|
||||
}
|
||||
//Prepare data to update
|
||||
// --- Prepare data to update
|
||||
foreach ($row as $key => $value) {
|
||||
if (array_key_exists($key, $userData)) {
|
||||
$userData[$key] = $value;
|
||||
$userData[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
foreach ($infos as $key => $value) {
|
||||
foreach ($values as $key => $value) {
|
||||
if (array_key_exists($key, $userData)) {
|
||||
$userData[$key] = $value;
|
||||
$userData[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1151,6 +1304,10 @@ class Gestion extends Scores_Ws_Server
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Catégorie et Accès
|
||||
* @return AccesCategory[]
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
$output = array();
|
||||
@ -1164,9 +1321,22 @@ class Gestion extends Scores_Ws_Server
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function getAccess()
|
||||
/**
|
||||
* Liste des acces
|
||||
* @return Acces[]
|
||||
*/
|
||||
public function getAccess()
|
||||
{
|
||||
//Liste des accès - Code, Label, Category, Description,
|
||||
$droits = $this->listeDroits;
|
||||
$list = array();
|
||||
foreach ($droits as $k => $v) {
|
||||
$acces = new Acces();
|
||||
$acces->Code = $k;
|
||||
$acces->Label = $v;
|
||||
$list[] = $acces;
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected function getPref()
|
||||
|
@ -251,3 +251,42 @@ class AuthParam
|
||||
/** @var string */
|
||||
public $value;
|
||||
}
|
||||
|
||||
class AuthLog
|
||||
{
|
||||
/** @var int */
|
||||
public $Total;
|
||||
|
||||
/** @var AuthLogItem[] */
|
||||
public $List;
|
||||
}
|
||||
|
||||
class AuthLogItem
|
||||
{
|
||||
/** @var string */
|
||||
public $IP;
|
||||
|
||||
/** @var string */
|
||||
public $Date;
|
||||
}
|
||||
|
||||
class UserLog
|
||||
{
|
||||
/** @var int */
|
||||
public $Total;
|
||||
|
||||
/** @var UserLogItem[] */
|
||||
public $List;
|
||||
}
|
||||
|
||||
class UserLogItem
|
||||
{
|
||||
/** @var string */
|
||||
public $CompanyId;
|
||||
|
||||
/** @var string */
|
||||
public $CompanyName;
|
||||
|
||||
/** @var string */
|
||||
public $Date;
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
return array(
|
||||
'account' => array(
|
||||
'actif' => true,
|
||||
'versions' => array(
|
||||
'0.1' => array( 'actif' => true, 'defaut' => true ),
|
||||
),
|
||||
'idClient' => array(1),
|
||||
),
|
||||
'catalog' => array(
|
||||
'actif' => true,
|
||||
'versions' => array(
|
||||
|
Loading…
Reference in New Issue
Block a user