33 lines
954 B
PHP

<?php
class Application_Controller_Plugin_Menu extends Zend_Controller_Plugin_Abstract
{
/**
* Créer le menu en fonction des besoins et des paramètres en entrée
* @param Zend_Controller_Request_Abstract $request
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$layout = Zend_Layout::getMVCInstance();
$controller = $request->getControllerName();
$action = $request->getActionName();
if ( $layout->isEnabled() && $controller!='user' )
{
$view = $layout->getView();
$config = include APPLICATION_PATH . '/configs/menu.config.php';
$container = new Zend_Navigation($config);
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
if ($user->idClient != 1) {
$gestionPage = $container->findBy('controller', 'gestion');
$container->removePage($gestionPage, true);
}
$view->navigation($container);
}
}
}