|
|||
|
I am not sure what you mean. A Resource is an object to which access is controlled. A Role is an object that may request access to a Resource. You can have as many roles and resources as you like on one ACL. You don't need to make seperate lists.
If you save the ACL as a variable in Zend_Registry, it can be accessed ANYWHERE on your site. This is from my bootstrap file: Code:
// setup Access Control List
$acl = new Zend_Acl();
$roleGuest = new Zend_Acl_Role('guest');
$acl->addRole($roleGuest);
$acl->addRole(new Zend_Acl_Role('staff'), $roleGuest);
$acl->addRole(new Zend_Acl_Role('editor'), 'staff');
$acl->addRole(new Zend_Acl_Role('administrator'));
$acl->allow('guest', null, 'view');
$acl->allow('staff', null, array('edit', 'submit', 'revise'));
$acl->allow('editor', null, array('publish', 'archive', 'delete'));
$acl->allow('administrator');
Zend_Registry::set('acl', $acl);
To get this variable from the registry: Code:
$registry = Zend_Registry::getInstance(); $this->acl = $registry['acl']; Last edited by notrub225 : 02-27-2008 at 05:37 AM. |
|
|||
|
for example
in a php file Code:
echo (part A-only be viewed by role A);//i want to define this part as resource A echo (part B-only be viewed by role B);//i want to define this part as resource B and how i do this? |
|
|||
|
Quote:
Code:
if($acl->isAllowed('roleA', null, 'resourceA')) {
echo $outputAllowedForRoleA;
}
if($acl->isAllowed('roleB', null, 'resourceB')) {
echo $outputAllowedForRoleB;
}
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|