views:

70

answers:

1

how should i implement Zend_Acl_Resources? do i have something like:

$acl->isAllowed()

in controller actions? i somehow think there maybe a better way ... but cant think of it.

+1  A: 

You can set this in preDispatch in plugin or in preDispatch of Controller base class. There you have your request and you can check sth like this:

if($acl->isAllowed('resource'.$request->getControllerName().$request->getActionName())){
    return;
} else {
   //redirect to 403
}

You can also extend resourceControllerAction from resourceController to ensure the rights are always inherited. And that way you can simplify the ACL rules generation...

Tomáš Fejfar
oh yes something like that will be more "dynamic". ... except maybe for some controller actions, i may need to include exceptions. eg. show some parts of a page but not others.
iceangel89
Other parts should be added via view helpers and they can be easily connected with ACL and return html block od '' if not allowed.
Tomáš Fejfar