-- maxarbos <[EMAIL PROTECTED]> wrote
(on Thursday, 10 July 2008, 11:58 AM -0700):
> I feel like I understand but dont seem o get thsi to work.
>
> Here is my main page:
>
> require_once 'Zend/Acl.php';
> $acl=new Zend_Acl();
>
> require_once 'Test.php';
> $test = new Test($acl);
>
> require_once('Zend/Acl/Role.php');
> $acl->addRole(new Zend_Acl_Role('guest'))
> ->addRole(new Zend_Acl_Role('member'));
>
> require_once('Zend/Acl/Resource.php');
> $acl->add(new Zend_Acl_Resource('test'));
Resources, roles, and rights are case sensitive. Change your resource
name to 'Test' instead of 'test'.
> $acl->deny('guest', 'test');
> $acl->allow('member', 'test');
>
> echo $acl->isAllowed('guest', 'test') ? 'allowed' : 'denied';
>
> echo $test->echoHello();
>
>
> I am trying to deny the echoHello from happening.
>
> Here is my Test.php class
>
> require_once 'Zend/Acl/Resource/Interface.php';
> class Test implements Zend_Acl_Resource_Interface
> {
>
> public function __construct(Zend_Acl $acl) {
> $this->_acl = $acl;
> }
>
>
> public function getResourceId()
> {
> return 'test';
> }
>
> public function echoHello(){
>
> if (!$this->_acl->isAllowed('guest', __CLASS__, __FUNCTION__)) {
> throw new Exception('ACCESS DENIED!');
> }
>
> return 'hello';
> }
>
> }
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/