Zend_Navigation + ACL

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Zend_Navigation + ACL

facingwest
This post has NOT been accepted by the mailing list yet.
I'm hoping somebody can point me at what i'm missing here, I'm using Zend_Navigation and Zend_ACL. I've been looking around and can't find anything that fits my needs or has been able to point me in the right direction.

Here's a mock up of the xml structure that i'm using,
<config>
 <linkgroups>
  <label>links</label>
  <uri>#</uri>
  <pages>
    <linka>
      <label>link A</label>
      <module>linkgroups</module>
      <controller>viewA</controller>
      <action>index</action>
      <privilege>agentportal:linkgroups:viewA</privilege>
    </linka>
    <linkb>
      <label>link B</label>
      <module>linkgroups</module>
      <controller>viewB</controller>
      <action>index</action>
      <privilege>agentportal:linkgroups:viewB</privilege>
    </linka>
  </pages>
</config>

Now i have extended Zend_Acl to handle my roles, rules and resources. All resources are added in a <application>:<module>:<controller> fashion. This was due to a need to have multiple 'applications' in one installation (something that was done well before my time with the company).

So all resources are simple strings as listed above in the xml example. I then extended the Zend_Controller_Plugin_Abstract to handle all my auth checks using the preDispatch method. Where i go through and basically construct the resource string using the three params (application, module, controller) do a simple isAllowed and all works great.

But now i'm having to add this process to Zend_Navigation and i'm not sure where the check is made, the example above i have a user role that has the privilege to view for example "agentportal:linkgroups:viewA" but for some reason the link still doesn't show up.

Here's the init method in the bootstrap file.
    protected function _initNavigation ()
    {
        $profile = new Zend_Session_Namespace('AgentProfile');
        $agent = $profile->data;
        $role = $agent['office'][trim($agent['OFFICEID'])]['OFFICEROLE'];
        $this->bootstrap('layout');
        $layout = $this->getResource('layout');
        $view = $layout->getView();
        $config = new Zend_Config_Xml(
            APPLICATION_PATH . '/configs/nav.xml'
        );
        $container = new Zend_Navigation($config);
        $view->navigation($container);
        $acl = Wellington_Registry::getAcl();
        $view->navigation()->setAcl($acl)->setRole($role);
    }

now i'm able to confirm that the user has access to the given resource by stepping through as i add resources. But i'm not sure why the navigation isn't working. i'm thinking it's going through something other then the plugin that i've written which is fine but i can't find where it's going through to try and figure out a fix.

Any advice or direction would be very greatly appreciated.