webservice/application/controllers/IndexController.php

112 lines
3.2 KiB
PHP

<?php
class IndexController extends Zend_Controller_Action
{
protected $serviceList = array(
'Entreprise' => array(
'titre' => 'WebService Entreprise',
'protect' => array(),
),
'Interne' => array(
'titre' => 'WebService Interne',
'protect' => array('mricois', 'ylenaour', 'dlasserre')
),
);
protected $serviceClientList = array(
'Afnic' => array(
'titre' => 'WebService Client Afnic',
'protect' => array('mricois', 'ylenaour'),
),
);
public function init()
{
$auth = Zend_Auth::getInstance();
//Gestion des versions pour les webservices clients - ne pas afficher les autres services
$clients = new Zend_Config_Ini('WsScore/Clients/Clients.ini');
foreach( $clients->toArray() as $section => $params ){
if ($params['actif']) {
$wsClients[$params['idClient']] = $section;
}
}
if (!array_key_exists($auth->getIdentity()->idClient, $wsClients)){
//Gestion des versions pour les webservices standard
foreach($this->serviceList as $serviceName => $serviceInfo)
{
$configServiceVersions = new Zend_Config_Ini('WsScore/'.$serviceName.'/Versions.ini', null);
$serviceVersions = array();
foreach( $configServiceVersions->toArray() as $section => $params )
{
$serviceVersions[$section] = $params;
$this->serviceList[$serviceName]['version'] = $serviceVersions;
}
}
}
if (array_key_exists($auth->getIdentity()->idClient, $wsClients)){
$this->serviceList = array();
$serviceName = ucfirst($section);
$configServiceVersions = new Zend_Config_Ini('WsScore/Clients/'.strtolower($serviceName).'/Versions.ini', null);
$serviceVersions = array();
foreach( $configServiceVersions->toArray() as $section => $params )
{
$serviceVersions[$section] = $params;
$this->serviceClientList[$serviceName]['version'] = $serviceVersions;
}
}
}
public function preDispatch()
{
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()){
$this->_redirect('/user/login');
} else {
$bootstrap = $this->getInvokeArg('bootstrap');
$this->appConfig = $bootstrap->getOptions();
}
}
public function indexAction()
{
$username = Zend_Auth::getInstance()->getIdentity()->username;
$displayWs = array();
//Traitement des webservices standard
if (count($this->serviceList)>0){
foreach($this->serviceList as $key => $ws)
{
if ( count($ws['protect'])==0 || in_array($username, $ws['protect']) )
{
$displayWs[$key] = $ws;
}
}
}
//Traitement des webservice clients
if (count($this->serviceClientList)>0){
foreach($this->serviceClientList as $key => $ws)
{
$displayWs[$key] = $ws;
$displayWs[$key]['type'] = 'client';
}
}
$this->view->assign('ws', $displayWs);
}
public function testAction()
{
//Connexion au service - Faire comme ci on charger le WSDL de l'extérieur
//getFunctions / getTypes
//Pour chaque Function, identifier les Types puis proposer les champs associés
//Valider les formulaires pour executer la requête du service
//Utiliser le jeux de tests disponible
}
}