Question

In my projects there are about 5, 6 modules

Ex: Web - Public access, URL - www.abc.com
Admin - admin can access - admin.abc.com (Non Acl)
CP - Specific group can access - cp.abc.com (Non Acl)
pbo - Another group can access - pbo.abc.com (Acl based and implemented recently)

As given above, we recently added a module called PBO, based on ACL plugin,

each module has a specific Bootstrap file,

But after the implementation of new module, all the other modules are going through the ACL plugin and redirect to the default page of the PBO module.

This is how Privileges are set

$this->acl->allow('superAdmin', 'user', array('login','logout'));
$this->acl->allow('superAdmin', 'index', 'index');
$this->acl->allow('superAdmin', 'app', 'index');

$this->acl->allow('admin', 'user', array('index','login','logout','registered'));      
$this->acl->allow('admin', 'index', 'index');
$this->acl->allow('admin', 'app', array('index', 'do-feature', 'do-delete'));

Initialize ACL in the bootstrap file

public function _initAcl()
{
    //Omit the process in CLI mode
    if (php_sapi_name() != 'cli') 
    {        
        $helper = new Nexva_Controller_Action_Helper_AclPbo();
        $helper->setRoles();
        $helper->setResources();
        $helper->setPrivilages();
        $helper->setAcl();

        //Register the ACL plugin - Then it will be called automatically,whenever an     acion is called
        $frontController = Zend_Controller_Front::getInstance(); 
        $frontController->registerPlugin(new Nexva_Plugin_AclPbo());

    }
}

Is there any way to avoid calling ACL of PBO module in other modules ?

Was it helpful?

Solution

This is an issue with Zend Framework 1.

Bootstraps for all Modules are always called and executed for any given Module. This is how Zend Framework is designed.

Due to this issue, there is one really good article to read to help understand how Module Bootstrapping works in ZF and it's shortcomings. It's written by Matthew Weier O'Phinney:

http://mwop.net/blog/234-Module-Bootstraps-in-Zend-Framework-Dos-and-Donts.html

From there, this site has a tutorial that talks about a solution to how to setup a "new" Bootstrap like layer that's module specific. It also links to several sources they pulled from, most of which are worth reading (yes, there's a fair bit of reading).

http://offshootinc.com/blog/2011/02/11/modul-bootstrapping-in-zend-framework/

I hope that helps!

OTHER TIPS

One thing you can do is to check if the current module is PBO before registering the plugin

if($frontController->getRequest()->getModuleName() == 'PBO')
$frontController->registerPlugin(new Nexva_Plugin_AclPbo());

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top