diff --git a/TODELETE b/TODELETE new file mode 100644 index 000000000..152c9f2d4 --- /dev/null +++ b/TODELETE @@ -0,0 +1,40 @@ +table => actes_files +library\Application\Model\ActesFiles.php + +table commandes +table commandes_erreur +table commandes_kbis +table commandes_pieces +table commandes_statut +table commandes_tarifs => Needed dans GenCourrier + + + +filesGreffes.php +getActes.php +greffeCmdMois.php +greffeCmdTelechargement + + +Controller/Dashboard + +Dashboard +Client => Gestion client, forcer l'ADV a utiliser le nouveau backoffice + +Actes et Bilans + +Kbis +GenCourrier => dans backoffice + + + +table aide + + + + +Cron OK +============= +sendBilanClient +getAltiScore + diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 4c65b8f27..f9484468a 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -23,22 +23,31 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $this->bootstrap('frontController'); $front = $this->getResource('frontController'); $router = $front->getRouter(); + $localauthRoute = new Zend_Controller_Router_Route('localauth/', array( 'controller' => 'user', 'action' => 'login' )); + $router->addRoute('localauth', $localauthRoute); + $fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array( 'controller' => 'fichier', 'fichier' => '', )); + $router->addRoute('fichier', $fichierRoute); + $printRoute = new Zend_Controller_Router_Route('editer/:action/:fichier', array( 'controller' => 'print', 'fichier' => '', )); - - $router->addRoute('localauth', $localauthRoute); - $router->addRoute('fichier', $fichierRoute); $router->addRoute('print', $printRoute); + + $ssoRoute = new Zend_Controller_Router_Route('sso/:partner', array( + 'controller' => 'auth', + 'action' => 'index', + )); + $router->addRoute('sso', $ssoRoute); + return $router; } diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php new file mode 100644 index 000000000..a0910d541 --- /dev/null +++ b/application/controllers/AuthController.php @@ -0,0 +1,118 @@ + array( + 'clientId' => 0, + 'serviceCode' => 'SSO', + 'authType' => 'userSSO', + 'login' => 'MAIL', + 'token' => 'token', + ) + ); + + /** + * Point d'entrée pour les connexions partenaires. + * L'utilisateur s'identifie sur son portail habituel. + */ + public function indexAction() + { + //Désactiver le layout + $this->_helper->layout()->disableLayout(); + + $request = $this->getRequest(); + + /** + * Get partner name - see route in bootstrap + */ + $partner = $request->getParam('partner'); + if ( array_key_exists($partner, $partnerConfig) ) { + $config = $partnerConfig[$partner]; + $params = $request->getParams(); + $objectParams = array(); + foreach ($params as $label => $value) { + $object = new stdClass(); + $object->label = $label; + $object->value = $value; + $objectParams[] = $object; + } + $login = $params[$partnerConfig['login']]; + $part = strstr($login, '@', true); + if ($part !== false) { + $login = $part; + } + $token = $params[$partnerConfig['token']]; + $ws = new Scores_Ws_Client('gestion', '0.4'); + try { + $hash = $ws->ssoAuthenticate($config['clientId'], $login, $token, $objectParams); + //Utilisateur inexistant + if ($hash === false ) { + $this->view->NoUser = true; + //Set form value + $this->view->FormIdentifiant = $login; + $this->view->FormCourriel = $request->getParam('MAIL'); + $this->view->FormSiret = $request->getParam('SIRET'); + $this->view->FormNom = $request->getParam('LASTNAME'); + $this->view->FormPrenom = $request->getParam('FIRSTNAME'); + } + //Redirection + else { + $auth = Zend_Auth::getInstance(); + //First set partial identity + $identity = new stdClass(); + $identity->username = $login; + $identity->password = $hash; + $auth->getStorage()->write($identity); + $adressIp = $_SERVER['REMOTE_ADDR']; + $ws = new Scores_Ws_Client('gestion', '0.3'); + $InfosLogin = $ws->getInfosLogin($login, $adressIp); + if ( is_string($InfosLogin) || $InfosLogin->error->errnum != 0 ) { + $this->view->Error = true; + } else { + $identity = $user->updateProfil($InfosLogin); + $auth->getStorage()->write($identity); + //Redirect + $this->redirect('/'); + } + } + } catch ( Exception $e ) { + switch ( $e->getCode() ) { + case 'MSG': + $this->view->Message = $e->getMessage(); + break; + default: + $this->view->Error = true; + break; + } + } + } else { + $this->view->Message = "Erreur dans les paramètres."; + } + } + + public function userssocreateAction() + { + $this->_helper->layout()->disableLayout(); + + } + + /** + * Lien de validation depuis email + * Paramètres + * - login ou email + * - key + * L'action renvoi sur un affichage spécifique suivant le type de client + */ + public function validateAction() + { + $request = $this->getRequest(); + + //Validation en erreur + + //Validation invalide + + //Validation Ok => Comment afficher les particularités + + } + +} \ No newline at end of file diff --git a/application/views/default/scripts/auth/index.phtml b/application/views/default/scripts/auth/index.phtml new file mode 100644 index 000000000..368436d18 --- /dev/null +++ b/application/views/default/scripts/auth/index.phtml @@ -0,0 +1,68 @@ +doctype(); ?> + + + headMeta(); ?> + headTitle(); ?> + headStyle(); ?> + headLink(); ?> + headScript(); ?> + + + + +
+ +
+ + Error) {?> +

Une erreur est survenue

+ Message) {?> +

Message?>

+ NoUSer) {?> +

Votre compte n'existe pas encore. Compléter le formulaire puis valider pour créer votre compte.

+ +
+ +
FormIdentifiant?>
+ + +
FormCourriel?>
+ + +
FormSiret?>
+ + +
FormNom?>
+ + +
FormPrenom?>
+ + + +
+ + +
+ +
+ + + + inlineScript(); ?> + + + diff --git a/application/views/default/scripts/auth/validate.phtml b/application/views/default/scripts/auth/validate.phtml new file mode 100644 index 000000000..b3d9bbc7f --- /dev/null +++ b/application/views/default/scripts/auth/validate.phtml @@ -0,0 +1 @@ +getControllerName()=='auth') { + $checkAuth = false; + } + if ($request->getControllerName()=='fichier' && $request->getClientIp(false)=='78.31.45.206') { $checkAuth = false; diff --git a/library/Application/Controller/Plugin/Theme.php b/library/Application/Controller/Plugin/Theme.php index 6f98be33c..796a1e38f 100644 --- a/library/Application/Controller/Plugin/Theme.php +++ b/library/Application/Controller/Plugin/Theme.php @@ -72,6 +72,10 @@ class Application_Controller_Plugin_Theme extends Zend_Controller_Plugin_Abstrac $UserLogin = true; } + if ( $controller == 'auth' ) { + $UserLogin = true; + } + /** * Detect IE */ diff --git a/library/Scores/Ws/Client.php b/library/Scores/Ws/Client.php new file mode 100644 index 000000000..6a75f5d03 --- /dev/null +++ b/library/Scores/Ws/Client.php @@ -0,0 +1,221 @@ + firebug, file, email + * error [ + * code error => return (message, false), stop (true, false) + * ] + * arguments + * name => null, defaultvalue + * + * + * Interface qui déclare les méthodes d'appel + * + * Méthodes protégés pour les opérations webservice + * Paramètres de l'opération + * Paramètres spécifique - Mise en cache + * Gestion des erreurs + */ + +class Scores_Ws_Client extends Zend_Soap_Client +{ + /** + * Configuration des méthodes du service + * @var array + */ + protected $config; + + /** + * WebService Url - Add a configuration key in application.ini + * @var string + */ + protected $url = null; + + protected $cache; + + /** + * Créer l'environnement nécessaire pour le chargement du webservice + * @param string $name + * Nom du service + * @param string $version + * Représente la version du service + * @param string $user + * @throws Exception + */ + public function __construct($name, $version, $user = null) + { + //Configuration de l'application + if (Zend_Registry::isRegistered('config')) { + $c = Zend_Registry::get('config'); + $this->url = $c->profil->webservice->url; + } else { + $c = new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini'); + $this->url = $c->profil->webservice->url; + } + + //Configuration du service + $config = include __DIR__ . '/Client/' . ucfirst($name) . '.php'; + if ($config === false) { + throw new Exception('Impossible de charger la configuration du service'); + } + + if (!array_key_exists($version, $config)) { + throw new Exception('Version du service inexistante'); + } + + $this->config = $config[$version]; + + // Create WSDL url + $wsdl = $this->url . '/' . $name . '/v' . $version; + if (APPLICATION_ENV == 'development') { + $wsdl.= '?wsdl-auto'; + $this->setWsdlCache(WSDL_CACHE_NONE); + } else { + $wsdl.= '?wsdl'; + } + $this->setWsdl($wsdl); + + if (PHP_SAPI != 'cli' && $user == null) { + $user = new Scores_Utilisateur(); + } + + if ($user !== null) { + $this->setHttpLogin($user->getLogin()); + $this->setHttpPassword($user->getPassword()); + } + + //Add default options + $options = array( + 'features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS, + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE, + //'trace' => true, + 'encoding' => 'utf-8', + ); + $this->setOptions($options); + + // Create Cache + $frontend = array( + 'lifetime' => 28800, + 'automatic_seralization' => true + ); + $backend = array( + 'cache_dir' => APPLICATION_PATH . '/../data/cache', + ); + $this->cache = Zend_Cache::factory('Core', 'File', $frontend, $backend); + } + + /** + * (non-PHPdoc) + * @see Zend_Soap_Client::__call() + */ + public function __call($name, $arguments) + { + if ( !array_key_exists($name, $this->config) ) { + throw new Exception("Method $name not exist"); + } + + //@todo : gestion des paramètres envoyés sous forme d'array + if( is_array($arguments) ) { + + } + + $methodConfig = $this->config[$name]; + + //Cache + $cacheEnable = false; + if ( array_key_exists('cache', $methodConfig) ) { + if ( $methodConfig['cache'] === true ) { + $cacheEnable = true; + $cacheId = $name; + if ( count($arguments) > 0 ){ + foreach ($arguments as $item) { + $cacheId.= $item; + } + } + } + } + + //Cache + if ( $cacheEnable === true ) { + $response = $this->cache->load($cacheId); + if ( $response !== false ) { + return $response; + } + } + + //Debug + if ( array_key_exists('debug', $methodConfig) ) { + Zend_Registry::get('firebug')->info(__CLASS__.'->'.$name); + } + + try { + + $response = parent::__call($name, $arguments); + + //Debug + if ( array_key_exists('debug', $methodConfig) ) { + Zend_Registry::get('firebug')->info($response); + } + + //Cache + if ( $cacheEnable === true ) { + $this->cache->save($response->{$name.'Result'}, $cacheId); + } + + return $response->{$name.'Result'}; + + } catch ( SoapFault $fault ) { + + //Debug + if ( array_key_exists('debug', $methodConfig) ) { + Zend_Registry::get('firebug')->info($fault->faultcode.' - '.$fault->faultstring); + } + + //Gestion des SOAP fault + if ( array_key_exists('errorMsg', $methodConfig) ) { + if ( array_key_exists($fault->getCode(), $methodConfig['error']) ) { + throw new Exception($fault->getMessage(), 'MSG'); + } + } + + //Logging + if ( array_key_exists('log', $methodConfig) ) { + + } + + return false; + } + } + + /** + * + * @param unknown $url + */ + protected function setUrl($url) + { + $this->url = $url; + } + +} \ No newline at end of file diff --git a/library/Scores/Ws/Client/Gestion.php b/library/Scores/Ws/Client/Gestion.php new file mode 100644 index 000000000..09efd5bbe --- /dev/null +++ b/library/Scores/Ws/Client/Gestion.php @@ -0,0 +1,56 @@ + array( + 'getCategory' => null, + 'getClientTarif' => null, + 'getClientTarifs' => null, + 'getEmail' => null, + 'getInfosLogin' => null, + 'getListeClients' => null, + 'getListeDroits' => null, + 'getListePrefs' => null, + 'getListeUtilisateurs' => null, + 'getLogs' => null, + 'getLogsClients' => null, + 'getNextLogin' => null, + 'getPrestation' => null, + 'getPrestations' => null, + 'getService' => null, + 'getServiceUsers' => null, + 'getServices' => null, + 'getUser' => null, + 'searchLogin' => null, + 'setCGU' => null, + 'setClient' => null, + 'setClientTarif' => null, + 'setEmail' => null, + 'setInfosLogin' => null, + 'setParam' => null, + 'setPrestation' => null, + 'setService' => null, + 'setSurveillancesMail' => null, + 'setUserService' => null, + ), + '0.4' => array( + 'getCategory' => null, + 'getClient' => null, + 'getClientServices' => null, + 'getClients' => null, + 'getService' => null, + 'getServices' => null, + 'getUser' => null, + 'getUserEmail' => null, + 'getUsers' => null, + 'loginAuthenticate' => null, + 'setCGU' => null, + 'setService' => null, + 'setServiceParam' => null, + 'setUser' => null, + 'setUserEmail' => null, + 'setUserPassword' => null, + 'setUserSSO' => null, + 'ssoAuthenticate' => array( + 'errorMsg' => array('SSO'), + ), + ), +); \ No newline at end of file