Q:

Zend_Acl registry

I am working on creating an ACL for my application. But i cannot seem to find where the error is. Since it is a simple ACL i don't think it could be that hard to find the issue here. I get the following error:
Fatal error: Zend_Acl_Role_Registry_Exception: Role 'secretaria' not found in /usr/local/zend/share/ZendFramework/library/Zend/View/Helper/Navigation/HelperAbstract.php on line 522
and here it  is my code(below). If some could help me to  find where error i would eally appreciate.
<?php

class Plugins_acl extends Zend_Controller_Plugin_Abstract{

    //NOME DOS RESOURCES
    //private $modules = array();
    //private $perfils = array();

    public function preDispatch(Zend_Controller_Request_Abstract $request)
       {
        $acl = new Zend_Acl();

                //create the user roles
                //1-ADMINISTRADOR
                //2-MEDICO
                //3- ASSISTENTE
                //4- SECREATRIA
                $acl->addRole(new Zend_Acl_Role('administrador'));
                $acl->addRole(new Zend_Acl_Role('medico'));
                $acl->addRole(new Zend_Acl_Role('assistente'));
                $acl->addRole(new Zend_Acl_Role('secretaria'));
                $acl->addRole(new Zend_Acl_Role('guest'));

                //create the resources
                $acl->addResource(new Zend_Acl_Resource('index'));
                $acl->addResource(new Zend_Acl_Resource('error'));
                $acl->addResource(new Zend_Acl_Resource('dashboard'));
                $acl->addResource(new Zend_Acl_Resource('login'));
                $acl->addResource(new Zend_Acl_Resource('default'));

                $acl->allow(null,'index');
                $acl->allow('secretaria','dashboard');
                $acl->allow('secretaria','index');
                $acl->allow('secretaria','default');
                $acl->allow('guest','login');

                $auth = Zend_Auth::getInstance();
                if($auth->hasIdentity())
                    {
                        $identity = $auth->getIdentity();
                        $role = strtolower($identity['role']);
                    }
                    else
                        {
                            $role = 'guest';
                    }

                        $controller = $request->controller;
                        $action = $request->action;
                        $module= $request->module;

                        if(!$acl->isAllowed($role, $module))
                            {
                                if('guest' == $role)
                                    {
                                            $request->setModuleName('auth');
                                            $request->setControllerName('login');
                                            $request->setActionName('index'); 
                                    }
                                    else
                                        {
                                            $request->setModuleName('error');
                                            $request->setControllerName('error');
                                            $request->setActionName('notauthorized');                                       }
                                    }       

    }
}

Here my code for navigation
public function _initNavigation ()
{
    $this->acl = Zend_Registry::get('acl');
    $this->bootstrap('layout');
    $this->role = Zend_Auth::getInstance()->getStorage()->read();
    $layout = $this->getResource('layout');
    $view =  $layout->getView();
    $navConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
    $navigation= new Zend_Navigation($navConfig);
    $view->navigation($navigation)->setAcl($this->acl)->setRole($this->role['Role']);
}

the problem at this point is that the registry is not found for acl;therefore when loading the navigation it does not know about the roles, etc...
<?php

class Plugins_acl extends Zend_Controller_Plugin_Abstract{
//NOME DOS RESOURCES
//private $modules = array();
//private $perfils = array();

public function preDispatch(Zend_Controller_Request_Abstract $request)
   {
            $acl =new Zend_Acl();       
            //create the user roles
            //1-ADMINISTRADOR
            //2-MEDICO
            //3- ASSISTENTE
            //4- SECREATRIA
            $acl->addRole(new Zend_Acl_Role('administrador'));
            $acl->addRole(new Zend_Acl_Role('medico'));
            $acl->addRole(new Zend_Acl_Role('assistente'));
            $acl->addRole(new Zend_Acl_Role('secretaria'));
            $acl->addRole(new Zend_Acl_Role('guest'));

            //create the resources
            $acl->addResource(new Zend_Acl_Resource('index'));
            $acl->addResource(new Zend_Acl_Resource('error'));
            $acl->addResource(new Zend_Acl_Resource('dashboard'));
            $acl->addResource(new Zend_Acl_Resource('login'));
            $acl->addResource(new Zend_Acl_Resource('default'));

            $acl->allow(null,'index','index');
            $acl->allow('secretaria','dashboard');
            $acl->allow('secretaria','index');
            $acl->allow('secretaria','default');
            $acl->allow('guest','login');

            Zend_Registry::set('Zend_Acl', $acl);

            $auth = Zend_Auth::getInstance();
            $roleUser = Zend_Auth::getInstance()->getStorage()->read();

            Zend_Registry::set('Zend_Acl_Role', $roleUser['Role']);
            if($auth->hasIdentity())
                {
                    $identity = $auth->getIdentity($roleUser['Role']);
                    $role = strtolower($identity['Role']);
                }
                else
                    {
                        $role = 'guest';
                }

                    $controller = $request->controller;
                    $action = $request->action;
                    $module= $request->module;

                    if(!$acl->isAllowed($role, $module))
                        {
                            if('guest' == $role)
                                {
                                        $request->setModuleName('auth');
                                        $request->setControllerName('login');
                                        $request->setActionName('index'); 
                                }
                                else
                                    {
                                        $request->setModuleName('error');
                                        $request->setControllerName('error');
                                        $request->setActionName('notauthorized');                                       }
                                }       
    /*
    $this->modules = $aclNs->resources['modules'];
    $this->perfils = $aclNs->resources['perfils'];
    $this->modules[]= 'default';
    $this->modules[]= 'logout';
    $this->modules[]= 'login';
    $this->modules[]= 'error';
    $this->modules[]= 'index';
    $this->modules[]= 'gerenciar';
    */
}

}

A:

After you setup the acl you have to save it in the Registry so that you can use it in the layout/view:
...
$acl->allow('guest','login');

Zend_Registry::set('Zend_Acl', $acl);

...
else
{
    $role = 'guest';
}
Zend_Registry::set('Zend_Acl_Role', $role);

EDIT:
I think I missed the layout/view file where navigation is used:
// set acl, role
$this->navigation()->setAcl(Zend_Registry::get('Zend_Acl'));
$this->navigation()->setRole(Zend_Registry::get('Zend_Acl_Role'));

// your renderMenu call
<?php echo $this->navigation()->menu()->renderMenu() ?>

In Bootstrap only this:
$this->bootstrap('layout');    
$layout = $this->getResource('layout');
$view = $layout->getView();
$navConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$navigation = new Zend_Navigation($navConfig);
$view->navigation($navigation);

