Started with some acl
This commit is contained in:
parent
770a4055a0
commit
5d3a29e681
1 changed files with 53 additions and 0 deletions
53
library/Fiktiv/Acl.php
Normal file
53
library/Fiktiv/Acl.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
class Fiktiv_Acl extends Zend_Acl
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// Add roles
|
||||
$this->loadRoles();
|
||||
|
||||
// Add resources
|
||||
$this->loadResources();
|
||||
|
||||
// Set accessrights
|
||||
$this->loadAccess();
|
||||
}
|
||||
|
||||
|
||||
protected function loadRoles()
|
||||
{
|
||||
// "Public" roles
|
||||
$this->addRole(new Zend_Acl_Role('visitor'));
|
||||
$this->addRole(new Zend_Acl_Role('member'), 'visitor');
|
||||
|
||||
// Blog roles
|
||||
$this->addRole(new Zend_Acl_Role('blogWriter'), 'member');
|
||||
$this->addRole(new Zend_Acl_Role('blogManager'), 'blogWriter');
|
||||
|
||||
// "Projects" roles (for future use)
|
||||
$this->addRole(new Zend_Acl_Role('projectUser'), 'member');
|
||||
$this->addRole(new Zend_Acl_Role('projectManager'), 'projectUser');
|
||||
|
||||
// ...
|
||||
$this->addRole(new Zend_Acl_Role('team'), array('blogManager', 'projectManager'));
|
||||
}
|
||||
|
||||
|
||||
protected function loadResources()
|
||||
{
|
||||
$this->add(new Zend_Acl_Resource('blog'));
|
||||
}
|
||||
|
||||
|
||||
protected function loadAccess()
|
||||
{
|
||||
// Blog
|
||||
$this->allow('visitor', 'blog', 'readBlog');
|
||||
$this->allow('visitor', 'blog', 'readComment');
|
||||
|
||||
$this->allow('blogWriter', 'blog', 'writeBlog');
|
||||
$this->allow('member', 'blog', 'writeComment');
|
||||
|
||||
}
|
||||
}
|
||||
Reference in a new issue