Este es mi archivo xml de navigation donde esta los permisos y los roles
Código XML:
Ver original
<?xml version="1.0" encoding="UTF-8"?> <config> <nav> <root> <label>Root</label> <uri>/</uri> <pages> <saga> <label>Saga</label> <uri>#</uri> </saga> <admin> <label>Administración</label> <class>dont-clobber-me</class> <uri>#dropdown</uri> <resource>default:index</resource> <privilege>admin</privilege> <pages> <halfway> <label>Intermedia</label> <module>default</module> <controller>index</controller> <action>halfway1</action> <resource>default:index</resource> <privilege>halfway</privilege> </halfway> </pages> </admin> <docente> <label>Ingreso Materia</label> <class>dont-clobber-me</class> <uri>#dropdown</uri> <resource>default:index</resource> <privilege>docente</privilege> <pages> <insert> <label>Insert</label> <module>default</module> <controller>index</controller> <action>insert</action> <resource>default:index</resource> <privilege>insert</privilege> </insert> </pages> </docente> <logout> <label>Cerrar Sessión</label> <module>default</module> <controller>index</controller> <action>logout</action> <resource>default:index</resource> <privilege>logout</privilege> </logout> </pages> </root> </nav> </config>
Otra con la configuracion de mi ACL
Código PHP:
<?php
class App_Acl{
public $acl;
public function __construct()
{
$this->acl = new Zend_Acl();
}
public function setRoles()
{
$this->acl->addRole(new Zend_Acl_Role('admin'));
$this->acl->addRole(new Zend_Acl_Role('docente'));
$this->acl->addRole(new Zend_Acl_Role('familia'));
$this->acl->addRole(new Zend_Acl_Role('admon'));
}
public function setResources()
{
$this->acl->add(new Zend_Acl_Resource('default:index'));
$this->acl->add(new Zend_Acl_Resource('default:error'));
}
public function setPrivilages()
{
$this->acl->allow('admin', 'default:index', array('halfway','logout','admin'));
$this->acl->allow('docente', 'default:index', array('docente','insert','logout'));
}
public function setAcl()
{
Zend_Registry::set('Zend_Acl', $this->acl);
}
}
Código PHP:
/**
* init Zend_ACL
*/
protected function _initACL()
{
if(App_Usuario::isLogged())
{
$acl = new App_Acl();
$acl->setRoles();
$acl->setResources();
$acl->setPrivilages();
$acl->setAcl();
}
}
protected function _initView ()
{
$view = new Zend_View();
$view->setEncoding('UTF-8');
$view->doctype('HTML5');
$view->headMeta()
->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$view->headTitle('')
->setSeparator(' - ');
$view->headTitle("SAGA");
if(App_Usuario::isLogged())
{
$view->registerHelper(new App_View_Helper_Menu(), 'menu');
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH. '/configs/navigation.xml', 'nav');
$navContainer = new Zend_Navigation($navContainerConfig);
$view->navigation($navContainer)
->menu()
->setMinDepth(1)
->setUlClass('nav nav-pills')
->setAcl(Zend_Registry::get('Zend_Acl'))
->setRole('admin');
}
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);
return $view;
}
Código PHP:
$view->navigation($navContainer)
->menu()
->setMinDepth(1)
->setUlClass('nav nav-pills')
->setAcl(Zend_Registry::get('Zend_Acl'))
->setRole('admin');
Código PHP:
$view->navigation($navContainer)
->menu()
->setMinDepth(1)
->setUlClass('nav nav-pills')
->setAcl(Zend_Registry::get('Zend_Acl'))
->setRole('admin','docente');