71 lines
2.0 KiB
PHP

<?php
class Application_Controller_Plugin_Services extends Zend_Controller_Plugin_Abstract
{
/**
* Vérifie les autorisations
* Utilise _request et _response hérités et injectés par le FC
*
* @param Zend_Controller_Request_Abstract $request : non utilisé, mais demandé par l'héritage
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controller = $request->getControllerName();
$action = $request->getActionName();
if ( $controller === 'service' ) {
} else {
$auth = Zend_Auth::getInstance();
$username = $auth->getIdentity()->username;
$idClient = $auth->getIdentity()->idClient;
$wsServices = array();
//Get all webservice client
$clients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
foreach( $clients as $section => $params ) {
if ( $params['actif']
&& (isset($params['idClient']) && in_array($idClient,$params['idClient'])) ) {
$params['name'] = $section;
$params['type'] = 'client';
if ( $idClient == 1 ) {
$params['name'] = 'Client - '.ucfirst($section);
}
$wsServices[$section] = $params;
}
}
//Standard service
if ( count($wsServices)==0 || $idClient==1 ) {
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
foreach( $services as $section => $params )
{
if ( $params['actif'] ) {
$params['name'] = ucfirst($section);
$params['type'] = 'sd';
if ( isset($params['idClient']) && in_array($idClient,$params['idClient']) ) {
if ( $idClient == 1 ) {
$params['name'] = 'SD - '.ucfirst($section);
}
$wsServices[$section] = $params;
}
elseif ( !isset($params['idClient']) ) {
if ( $idClient == 1 ) {
$params['name'] = 'SD - '.ucfirst($section);
}
$wsServices[$section] = $params;
}
}
}
}
$layout = Zend_Layout::getMVCInstance();
$view = $layout->getView();
$view->WsServices = $wsServices;
}
}
}