2012-08-08 93 views
0

在我的项目大约有5,6个模块Zend的模块特定ACL

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) 

正如上面给出的,我们最近增加了一个名为PBO模块,基于ACL插件,

每个模块都有一个特定的自举文件,

但是新模块执行完毕后,所有其他模块都会通过ACL插件并重定向到PBO模块的默认页面。

这是如何来设置权限

$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')); 

初始化ACL在引导文件

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()); 

    } 
} 

有什么办法避免调用PBO模块的ACL中的其他模块?

回答

1

这是Zend框架的问题1.

白手起家所有模块总是调用,对于任何给定的模块执行。这就是Zend框架的设计。

由于这个问题,有一篇非常好的文章可以帮助理解模块引导在ZF中的工作原理和缺点。这是写由马修·维尔O'Phinney:

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

从那里,这个网站有关于解决会谈到如何设置一个“新”引导像层的模块特定的教程。它还链接到他们提供的几个来源,其中大部分都值得阅读(是的,这里有一点点阅读)。

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

我希望有帮助!

1

一两件事你可以做的是检查当前模块PBO注册插件

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