本文整理汇总了PHP中RoleModel::find方法的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel::find方法的具体用法?PHP RoleModel::find怎么用?PHP RoleModel::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleModel
的用法示例。
在下文中一共展示了RoleModel::find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: auth
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);
}
示例2: testAnyAccess
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));
}
示例3: testDelete
public function testDelete()
{
$role = RoleModel::find(1);
$role->delete();
try {
$role = RoleModel::find(1);
} catch (Exception $e) {
return;
}
$this->fail('Fetching a deleted object should throw an exception.');
}
示例4: hasAccess
/**
* Determine whether or not this user has access to a permissible object (or has a global)
* permission
*
* @param string permission to check
* @param QFrame_Permissible (optional) permissible object to check
* @return boolean
*/
public function hasAccess($permission, QFrame_Permissible $permissible = null)
{
// if this user is an auto admin, return true
if ($this->admin) {
return true;
}
if ($this->roles === null) {
$this->loadRoles();
}
foreach ($this->roles as $role) {
$role = RoleModel::find($role['roleID']);
if ($role->hasAccess($permission)) {
return true;
} elseif ($permissible !== null && $role->hasAccess($permission, $permissible)) {
return true;
}
}
return false;
}
示例5: removeRoleAction
/**
* Remove role action. Removes the requested role from the current user.
*/
public function removeRoleAction()
{
$user = new DbUserModel(array('dbUserID' => $this->_getParam('id')));
$role = RoleModel::find($this->_getParam('role'));
$user->removeRole($role);
$this->_redirector->gotoRoute(array('action' => 'roles', 'id' => $user->dbUserID));
}
示例6: updatePermissions
/**
* Processes an update to permissions
*/
private function updatePermissions()
{
$globals = $this->_getParam('global');
$pages = $this->_getParam('page');
$role = RoleModel::find($this->_getParam('id'));
foreach ($globals as $permission => $value) {
if ($value) {
$role->grant($permission);
} else {
$role->deny($permission);
}
}
foreach ($pages as $id => $permissions) {
$page = $this->_instance->getPage($id);
foreach ($permissions as $permission => $value) {
if ($value) {
$role->grant($permission, $page);
} else {
$role->deny($permission, $page);
}
}
}
$role->save();
$this->flash('notice', 'Permissions updated successfully');
$this->_redirector->gotoRouteAndExit(array('action' => 'index', 'id' => null));
}