i have this in one of the controllers in my AuthController.php
// set access controlls
// -------------------------------------
$acl = new Zend_Acl();
//define resources
$acl->add(new Zend_Acl_Resource('admin_pages'));
$acl->add(new Zend_Acl_Resource('claim'));
$acl->add(new Zend_Acl_Resource('views'));
$acl->add(new Zend_Acl_Resource('reports'));
$acl->add(new Zend_Acl_Resource('research'));
$roles = explode(' ',$data['group_names']);
foreach ($roles as $role) {
$myrole = new Zend_Acl_Role($role);
$acl->addRole($myrole);
if ($role == 'admin') {
$acl->allow($myrole, 'admin_pages', array('admin_access'));
} elseif ($role == 'xxx') {
$acl->allow($myrole, array('claim', 'views', 'reports'),
array('create_claim', 'save_claim', 'close_claim', 'view'));
} elseif ($role == 'yyy') {
$acl->allow($myrole, array('research', 'views', 'reports'),
array('research_open', 'view'));
}
//echo $acl->isAllowed($role, null, 'research_open') ? "$role:
allowed<br />" : "$role: denied<br />";
}
// -------------------------------------
BUT, i can't access the ACL in another FooController.php
Zend_Loader::loadClass('Zend_Acl');
Zend_Loader::loadClass('Zend_Acl_Role');
Zend_Loader::loadClass('Zend_Acl_Resource');
$acl = new Zend_Acl;
$acl->isAllowed('xxx', 'claim', 'create_claim') ? "myrole: allowed<br />" :
"myrole: denied<br />";
i get an error that says:
Fatal error: Uncaught exception 'Zend_Acl_Role_Registry_Exception' with
message 'Role 'xxx' not found'
how would i access the stuff i created in my AuthController.php from in
other controllers/actions?
so that I can do this:
$acl->isAllowed('xxx', 'claim', 'create_claim') ? "myrole: allowed<br />" :
"myrole: denied<br />";
in any part of my application?
any reply will be appreciated :)
thanks
--
View this message in context:
http://www.nabble.com/Zend_Acl%3A-Role-not-found-in-other-controllers-tf3905692s16154.html#a11073474
Sent from the Zend Framework mailing list archive at Nabble.com.