Esempio n. 1
0
 protected function prepareData()
 {
     $this->auth->insertRule(new AuthorRule());
     $this->auth->createOperation('createPost', 'create a post');
     $this->auth->createOperation('readPost', 'read a post');
     $this->auth->createOperation('updatePost', 'update a post');
     $this->auth->createOperation('deletePost', 'delete a post');
     $task = $this->auth->createTask('updateOwnPost', 'update a post by author himself', 'isAuthor');
     $task->addChild('updatePost');
     $role = $this->auth->createRole('reader');
     $role->addChild('readPost');
     $role = $this->auth->createRole('author');
     $role->addChild('reader');
     $role->addChild('createPost');
     $role->addChild('updateOwnPost');
     $role = $this->auth->createRole('editor');
     $role->addChild('reader');
     $role->addChild('updatePost');
     $role = $this->auth->createRole('admin');
     $role->addChild('editor');
     $role->addChild('author');
     $role->addChild('deletePost');
     $this->auth->assign('reader A', 'reader');
     $this->auth->assign('author B', 'author');
     $this->auth->assign('editor C', 'editor');
     $this->auth->assign('admin D', 'admin');
     $this->auth->assign('reader E', 'reader');
 }