Params for user is now define in Auth plugin
This commit is contained in:
parent
967b1dd9d2
commit
45eba61cd9
@ -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"
|
||||
|
@ -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" ) {
|
||||
|
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
class Application_Controller_Plugin_Params extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
public function preDispatch(Zend_Controller_Request_Abstract $request)
|
||||
{
|
||||
$layout = Zend_Layout::getMVCInstance();
|
||||
|
||||
if ($layout->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user