Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- application/models/Acl.php ---
- <?php
- class Application_Model_Acl extends Zend_Acl
- {
- public function __construct()
- {
- $this->addRole('reader');
- $this->addRole('editor', 'reader');
- $this->addRole('copywriter', 'editor');
- $this->addResource('stories');
- $this->addResource('edit-stories');
- $this->addResource('publish-stories');
- $this->allow('reader', 'stories', 'read');
- $this->allow('editor', 'edit-stories', array ('create','update'));
- $this->allow('copywriter', 'publish-stories', array ('publish'));
- }
- }
- --- application/controllers/TestController.php ---
- public function aclAction()
- {
- $acl = new Application_Model_Acl();
- $this->view->acl = $acl;
- }
- --- application/views/scripts/test/acl.phtml ---
- <?php echo $this->htmlList(array (
- 'reader is allowed to read stories: ' . ($this->acl->isAllowed('reader', 'stories', 'read') ? 'true' : 'false'),
- 'reader is allowed to edit stories: ' . ($this->acl->isAllowed('reader', 'stories', 'edit') ? 'true' : 'false'),
- 'reader is allowed to create stories: ' . ($this->acl->isAllowed('reader', 'stories', 'create') ? 'true' : 'false'),
- 'reader is allowed to publish stories: ' . ($this->acl->isAllowed('reader', 'stories', 'publish') ? 'true' : 'false'),
- 'editor is allowed to read stories: ' . ($this->acl->isAllowed('editor', 'stories', 'read') ? 'true' : 'false'),
- 'editor is allowed to edit stories: ' . ($this->acl->isAllowed('editor', 'stories', 'edit') ? 'true' : 'false'),
- 'editor is allowed to create stories: ' . ($this->acl->isAllowed('editor', 'stories', 'create') ? 'true' : 'false'),
- 'editor is allowed to publish stories: ' . ($this->acl->isAllowed('editor', 'stories', 'publish') ? 'true' : 'false'),
- 'copywriter is allowed to read stories: ' . ($this->acl->isAllowed('copywriter', 'stories', 'read') ? 'true' : 'false'),
- 'copywriter is allowed to edit stories: ' . ($this->acl->isAllowed('copywriter', 'stories', 'edit') ? 'true' : 'false'),
- 'copywriter is allowed to create stories: ' . ($this->acl->isAllowed('copywriter', 'stories', 'create') ? 'true' : 'false'),
- 'copywriter is allowed to publish stories: ' . ($this->acl->isAllowed('copywriter', 'stories', 'publish') ? 'true' : 'false'),
- ))?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement