当前位置: 首页>>代码示例>>PHP>>正文


PHP RoleModel::find方法代码示例

本文整理汇总了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);
 }
开发者ID:humansky,项目名称:qframe,代码行数:17,代码来源:ModelModelTest.php

示例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));
 }
开发者ID:humansky,项目名称:qframe,代码行数:11,代码来源:DbUserModelTest.php

示例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.');
 }
开发者ID:humansky,项目名称:qframe,代码行数:11,代码来源:RoleModelTest.php

示例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;
 }
开发者ID:humansky,项目名称:qframe,代码行数:27,代码来源:DbUserModel.php

示例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));
 }
开发者ID:humansky,项目名称:qframe,代码行数:10,代码来源:UserController.php

示例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));
 }
开发者ID:humansky,项目名称:qframe,代码行数:29,代码来源:RoleController.php


注:本文中的RoleModel::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。