English 中文(简体)
Zend - 控制者/行动
原标题:Zend - controller/action ACL

在我的行政模块中,我有一个叫作电子邮件的控制员,我希望大多数行动只能通过在行政管理用户中设置空白才能进入。 然而,我想让任何人都能采取行动。 (它拥有通过URL远程发射的电子邮件功能。) 此时此刻,用Zentd_Auth和Zentd_Acl一样:

if ($request->getModuleName() ==  admin ) {
    // access resources (controllers)
    $acl->addResource( index );
    $acl->addResource( reports );
    $acl->addResource( email );
    $acl->addResource( error );

    // access roles
    $acl->addRole(new Zend_Acl_Role( visitor ));
    $acl->addRole(new Zend_Acl_Role( user ));
    $acl->addRole(new Zend_Acl_Role( admin ));

    // access rules
    $acl->deny( visitor );
    $acl->deny( user );
    $acl->allow( admin );

    $resouce = $request->getControllerName();
    $action = $request->getActionName();
    $identity = $auth->getStorage()->read();
    if (is_object($identity)) {
        $role = $identity->role;
    } else {
        $role =  visitor ;
    }

    if (!$acl->isAllowed($role, $resouce, $action)) {
        $request->setModuleName( default )
                ->setControllerName( auth )
                ->setActionName( login );
    }
}

我如何改变上述准则,使来访者能够参加/管理/电子邮件/处理行动?

最佳回答

This should do the trick:

$oAcl->allow( visitor , email , functionname );
//or if you want to do both visitor and user
$oAcl->allow(array( visitor , user ), email , functionname );

在你已经写出的查阅规则之后,规定这一守则。

问题回答

您可以以<条码>Zend_Acl确立一种作用等级,使您能够发挥最低限度的作用,排出一页,任何具有X或以上作用的人都可以查阅。

$acl->addRole(new Zend_Acl_Role( visitor ));
$acl->addRole(new Zend_Acl_Role( user ),  visitor );
$acl->addRole(new Zend_Acl_Role( admin ),  user );

This way, anyone with an admin role can have access to anything a visitor and a user has access.

You can also pass an arrayas parameter instead of a string.

欲了解更多情况,请在http://framework.zend.com/manual/en/zend.acl.introduction.html”上查阅Zentd framework official doc。





相关问题
Zend 邮件问题,涉及外国char子+ com子

泽斯德邮局在名称被定为具有外国性质(如“保”)和 com(”)的物品时,就放弃了一种例外(因为邮局(邮局)退回假)。 重新提出以下守则。

PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

Link to a specific step in onepage checkout

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it? I m working on a payment module and have a sort of "cancel" action that i would ...

Tagging with Zend Framework

I m trying to create the same solutions as below, but using a simple MySQL query (instead of the static version used below where the words/tags are implemented in the code). The name of the MySQL ...

dynamicaly adding textboxes to zend_form

I hope that this is a quick question to answer. I am developing a form using Zend_Form, I have a number of Zend_Dojo_Form_Element_Textboxs to add to this form dynamically. These are added from rows ...

热门标签