views:

267

answers:

3

Hello,

I created a MVC with Zend by reading http://framework.zend.com/manual/en/zend.controller.modular.html.

The problem is that I can't find a way to use Zend_ACL with modular structure. Zend_Acl simply does not have a method to add modules. It only allows me to add controller and action.

How do I use Zend_Acl with modular structrue? Is it even possible with current version of Zend Framework?

+1  A: 

It absolutely is. That's what we do in our project. We authenticate URI paths ($request->getPathInfo()), like: /admin/user/edit. Here "admin" is a module, "user" is a controller, and "edit" is an action. And we have an access plugin:

class Our_Application_Plugin_Access extends Zend_Controller_Plugin_Abstract {
    public function preDispatch(Zend_Controller_Request_Abstract $request) {
        foreach (self::current_roles() as $role) {
            if (
                Zend_Registry::get('bootstrap')->siteacl->isAllowed(
                    $role,
                    $request->getPathInfo()
                )
            ) return;
        }

        $this->not_allowed($request);
    }

   ...
}

Registered in application.ini:

resources.frontController.plugins.access = "Our_Application_Plugin_Access"
Ivan Krechetov
+1  A: 

Other option to Ivan's is to set resources insetead of just "controller" to sth. like "module-Controller".

Tomáš Fejfar
A: 

Ivan Krechetov, Priviet ;) I'm interested in your aproach... How it's suposed you created the what roles can access resources, within the application.ini config file and the ACL object read from it ? May you paste an example ?

TYSM - Thank you so much

Jesús Flores
Oh Jesús!......
takeshin