dongmi0760 2012-08-08 12:35
浏览 36
已采纳

Zend模块特定的ACL

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 ?

  • 写回答

2条回答 默认 最新

  • dqudtskm49788 2012-08-08 14:31
    关注

    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!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值