Ejemplo n.º 1
0
 private function auth()
 {
     // perform mock authentication
     $auth_adapter = new QFrame_Auth_Adapter('sample1', 'password');
     $auth = Zend_Auth::getInstance();
     $auth->authenticate($auth_adapter);
     // authorize the sample1 user with the admin role and give the admin role
     // all possible global rights
     $adminRole = RoleModel::find(4);
     $adminRole->grant('view');
     $adminRole->grant('edit');
     $adminRole->grant('approve');
     $adminRole->grant('administer');
     $adminRole->save();
     $user = new DbUserModel(array('dbUserID' => 1));
     $user->addRole($adminRole);
 }
Ejemplo n.º 2
0
 public function testAnyAccess()
 {
     $user = new DbUserModel(array('dbUserID' => 1));
     $page = new PageModel(array('pageID' => 1, 'depth' => 'page'));
     $this->assertFalse($user->hasAnyAccess($page));
     $role = RoleModel::find('first');
     $role->grant('view', $page);
     $role->save();
     $user->addRole($role);
     $this->assertTrue($user->hasAnyAccess($page));
 }
Ejemplo n.º 3
0
 /**
  * Add role action.  Adds the requested role to the current user.
  */
 public function addRoleAction()
 {
     $user = new DbUserModel(array('dbUserID' => $this->_getParam('id')));
     $role = RoleModel::find($this->_getParam('role'));
     $user->addRole($role);
     $this->_redirector->gotoRoute(array('action' => 'roles', 'id' => $user->dbUserID));
 }