diff --git a/application/configs/application.ini b/application/configs/application.ini index 47c72773..13e7e762 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -13,7 +13,6 @@ resources.session.cookie_lifetime = 86400 resources.session.remember_me_seconds = 86400 resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.plugins.Auth = "Application_Controller_Plugin_Auth" -resources.frontController.plugins.Auth = "Application_Controller_Plugin_Params" resources.frontController.plugins.Comptage = "Application_Controller_Plugin_Comptage" resources.frontController.params.displayExceptions = 0 resources.layout.layout = "main" diff --git a/library/Application/Controller/Plugin/Auth.php b/library/Application/Controller/Plugin/Auth.php index 78429e6e..3d90f701 100644 --- a/library/Application/Controller/Plugin/Auth.php +++ b/library/Application/Controller/Plugin/Auth.php @@ -77,6 +77,50 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract $identity = $auth->getIdentity(); $identity->time = time() + $identity->timeout; + + $layout = Zend_Layout::getMVCInstance(); + + if ($layout->isEnabled()) { + ///Get customer's params + $paramsM = new Application_Model_CustomerParams(); + $sql = $paramsM->select() + ->where('idClient = ?', $identity->idClient) + ->order('dateContrat DESC')->limit(1); + + $params = $paramsM->fetchAll($sql)->toArray(); + if (count($params)>0) { + $identity->filterRNCS = $params[0]['filterRNCS']; + $identity->licenceINSEE = $params[0]['licenceINSEE']; + $identity->limitLines = $params[0]['limitLines']; + $identity->limitFiles = $params[0]['limitFiles']; + //@todo : Check dateContrat and calculate end of contrat + } + + //If no params is detected, display a message to contact support + if (count($params)==0) { + $request->setModuleName('default') + ->setControllerName('aide') + ->setActionName('message') + ->setParam('typeMsg', 'support'); + } + + //Get user's preference + $prefsM = new Application_Model_Prefs(); + $pref = $prefsM->find($identity->username)->current(); + if ($pref) { + $identity->preferences = json_decode($pref->json, true); + } + + //Add a global value to assemble filterRNCS and preferences RNCS + if ($identity->filterRNCS) { + $identity->globalRNCS = 1; + } + + if (isset($identity->preferences['filter']['rncs']) && $identity->preferences['filter']['rncs']==1) { + $identity->globalRNCS = 1; + } + } + $auth->getStorage()->write($identity); if ( $identity->profil=="SuperAdministrateur" ) { diff --git a/library/Application/Controller/Plugin/Params.php b/library/Application/Controller/Plugin/Params.php deleted file mode 100644 index f5394a8f..00000000 --- a/library/Application/Controller/Plugin/Params.php +++ /dev/null @@ -1,62 +0,0 @@ -isEnabled() - && $request->getControllerName()!='user' - && !in_array($request->getActionName(), array('login', 'logout'))) - { - - $auth = Zend_Auth::getInstance(); - if ($auth->hasIdentity()) { - $identity = $auth->getIdentity(); - - ///Get customer's params - $paramsM = new Application_Model_CustomerParams(); - $sql = $paramsM->select() - ->where('idClient = ?', $identity->idClient) - ->order('dateContrat DESC')->limit(1); - - $params = $paramsM->fetchAll($sql)->toArray(); - if (count($params)>0) { - $identity->filterRNCS = $params[0]['filterRNCS']; - $identity->licenceINSEE = $params[0]['licenceINSEE']; - $identity->limitLines = $params[0]['limitLines']; - $identity->limitFiles = $params[0]['limitFiles']; - //@todo : Check dateContrat and calculate end of contrat - } - - //If no params is detected, display a message to contact support - if (count($params)==0) { - $request->setModuleName('default') - ->setControllerName('aide') - ->setActionName('message') - ->setParam('typeMsg', 'support'); - } - - //Get user's preference - $prefsM = new Application_Model_Prefs(); - $pref = $prefsM->find($identity->username)->current(); - if ($pref) { - $identity->preferences = json_decode($pref->json, true); - } - - //Add a global value to assemble filterRNCS and preferences RNCS - if ($identity->filterRNCS) { - $identity->globalRNCS = 1; - } - - if (isset($identity->preferences['filter']['rncs']) && $identity->preferences['filter']['rncs']==1) { - $identity->globalRNCS = 1; - } - - - //Save information in session - $auth->getStorage()->write($identity); - } - } - } -} \ No newline at end of file