diff --git a/application/controllers/DocumentationController.php b/application/controllers/DocumentationController.php index c6458978..40ef1092 100644 --- a/application/controllers/DocumentationController.php +++ b/application/controllers/DocumentationController.php @@ -18,9 +18,9 @@ class DocumentationController extends Zend_Controller_Action public function indexAction() { $request = $this->getRequest(); - $ws = $request->getParam('ws','Entreprise'); - + $ws = $request->getParam('ws','Entreprise'); $auth = Zend_Auth::getInstance(); + //Si client possède un webservice particulier alors on redirige vers la doc clients $clients = new Zend_Config_Ini('WsScore/Clients/Clients.ini'); foreach( $clients->toArray() as $section => $params ){ @@ -37,22 +37,31 @@ class DocumentationController extends Zend_Controller_Action } else { - // Liste de webservice protégé - $protectedWs = array( - 'Interne' => array('mricois', 'ylenaour', 'dlasserre') - ); + // Liste des webservices + $services = new Zend_Config_Ini('WsScore/Services.ini'); + foreach( $services->toArray() as $section => $params ){ + if ($params['actif']) { + $wsServices[$section] = $params; + } + } // On vérifie que l'utilisateur peut accèder à la documentation - if ( array_key_exists($ws, $protectedWs) ) - { - $username = $auth->getIdentity()->username; - if ( !in_array($username, $protectedWs[$ws]) ) + $username = $auth->getIdentity()->username; + $idClient = $auth->getIdentity()->idClient; + if ( array_key_exists($ws, $wsServices) ) + { + if ( isset($wsServices['idClient']) && $idClient!=$wsServices['idClient'] ) + { + $this->renderScript('documentation/nodoc.phtml'); + exit; + } + if ( isset($wsServices['user']) && !in_array($username, $wsServices['user']) ) { $this->renderScript('documentation/nodoc.phtml'); exit; } } - + // Gestion des versions $configServiceVersions = new Zend_Config_Ini('WsScore/'.ucfirst($ws).'/Versions.ini'); foreach( $configServiceVersions->toArray() as $section => $params ){ diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index 84c5f132..3ed0ba32 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -64,8 +64,7 @@ class ServiceController extends Zend_Controller_Action exit; } - // Charger les classes et les types pour le service suivant la version - + // Charger les classes et les types pour le service suivant la version if (strtolower($serviceName) == 'clients') { $pathServiceClassIni = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.ini'; $pathServiceClassPhp = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.php';