我正在尝试绕过 Zend_Acl 但到目前为止没有成功。我需要帮助,因为我真的陷入困境。我的情况是这样的:
我有两个模块
和两个角色
我设置了一个 Zend_Auth ,其登录名可以访问成员模块的成员角色和管理员角色。两者都可以在这里执行一些操作,但管理员角色还可以访问“管理员”模块,在其中可以执行更多管理员操作。
我设置了一个 Acl,如下所示:
$acl = new Zend_Acl();
$acl->addRole(new Zend_Acl_Role('member'));
$acl->addRole(new Zend_Acl_Role('admin'), 'member');
$acl->add(new Zend_Acl_Resource('members'));
$acl->add(new Zend_Acl_Resource('administrators'), 'members');
$acl->allow('member', 'members');
$acl->allow('admin', 'administrators');
$registry = Zend_Registry::getInstance();
$registry->set('acl', $acl);
我已保存此文件,并在 index.php 页面中调用它。
假设我到目前为止所做的都是正确的,我的问题是下一步该怎么做?这是我第一次处理 Acl,老实说我对 all think 的工作有点困惑。你能帮忙吗?预先非常感谢。
I am trying to get around Zend_Acl but had no success so far. I need help as I am really stuck. My situation is this:
I have two modules
and two roles
I set up an Zend_Auth with a login that gets to the members module both the member and admin role. Both can do some stuff here but the admin role can also have access to the 'administrators' module where can do more administrator stuff.
I set up an Acl as follow:
$acl = new Zend_Acl();
$acl->addRole(new Zend_Acl_Role('member'));
$acl->addRole(new Zend_Acl_Role('admin'), 'member');
$acl->add(new Zend_Acl_Resource('members'));
$acl->add(new Zend_Acl_Resource('administrators'), 'members');
$acl->allow('member', 'members');
$acl->allow('admin', 'administrators');
$registry = Zend_Registry::getInstance();
$registry->set('acl', $acl);
I have saved this file and I am calling it in the index.php page.
Assuming the what I have done so far is correct, my problem is what to do next? It is the first time I deal with Acl and honestly I am a bit confused about the all think works. Could you please help? Thank very much in advance.
发布评论
评论(1)
您已经构造了 ACL 对象。您现在就需要使用它,每次您需要检查当前用户是否有权访问其中一项资源时。
为此,您需要从注册表中检索 ACL 对象:
然后查询它:
您可以在 Zend_Acl 文档。
希望有帮助,
You have constructed the ACL object. You need to use it now, every time you need to check whether the current user has access to one of the resources.
To do so, you need to retrieve your ACL object from the registry:
And then query it:
You can see more details in the Zend_Acl documentation.
Hope that helps,