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


PHP Role::findById方法代码示例

本文整理汇总了PHP中Role::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::findById方法的具体用法?PHP Role::findById怎么用?PHP Role::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Role的用法示例。


在下文中一共展示了Role::findById方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: editAction

 public function editAction()
 {
     if ($this->isAjax()) {
         $data = $this->request->getPost();
         if (empty($data)) {
             $this->pageError('param');
         }
         $modelForm = new RoleForm('edit');
         if ($result = $modelForm->validate($data)) {
             if ($modelForm->edit()) {
                 $this->success('操作成功');
             } else {
                 $this->error('操作失败');
             }
         }
         $this->error($result);
     }
     $rid = $this->dispatcher->getParams()[0];
     if (empty($rid)) {
         $this->pageError('param');
     }
     $role = Role::findById($rid);
     $form = new RoleForm('edit', $operator);
     $this->view->setVars(['page' => ['title' => '编辑角色'], 'formparams' => ['event' => 'edit', 'action' => \Func\url('/role/edit')], 'data' => $role]);
     $this->view->pick('role/add');
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:26,代码来源:RoleController.php

示例2: allotAction

 /**
  * 给角色分配权限
  */
 public function allotAction()
 {
     if ($this->isAjax()) {
         $data = $this->request->getPost();
         $data['auth'] = serialize(self::toArray($data['auth']));
         switch ($data['type']) {
             case 'role':
                 $modelForm = new RoleForm('auth');
                 $data['rid'] = $data['id'];
                 unset($data['id']);
                 break;
             case 'operator':
                 $data['oid'] = $data['id'];
                 unset($data['id']);
                 $modelForm = new OperatorForm('auth');
                 break;
             default:
                 $this->error('参数错误');
                 break;
         }
         if ($result = $modelForm->validate($data)) {
             if ($modelForm->allot()) {
                 $this->success('操作成功');
             } else {
                 $this->success('操作失败');
             }
         }
         $this->error('操作失败');
     }
     $params = $this->dispatcher->getParams();
     $type = $params[0];
     $id = $params[1];
     if (empty($type) || empty($id)) {
         $this->pageError('param');
     }
     switch ($type) {
         case 'role':
             $info = Role::findById($id);
             $modelForm = new RoleForm('auth', $info);
             break;
         case 'operator':
             $info = Operator::findById($id);
             $modelForm = new OperatorForm('auth', $info);
             break;
     }
     $this->view->setVars(['info' => $info, 'form' => $modelForm, 'authorities' => self::allAuthorities(), 'formparams' => ['action' => \Func\url('/authority/allot/role/'), 'type' => $type, 'id' => $id]]);
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:50,代码来源:AuthorityController.php

示例3: getAuthByRid

 public static function getAuthByRid($rid)
 {
     $role = Role::findById($rid);
     return unserialize($role['auth']);
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:5,代码来源:Operator.php

示例4: findByUserId

 public static function findByUserId($id)
 {
     $userroles = UserRole::findAllFrom('UserRole', 'user_id=?', array((int) $id));
     if (count($userroles) <= 0) {
         return false;
     }
     $roles = array();
     foreach ($userroles as $role) {
         $roles[] = Role::findById($role->role_id);
     }
     return $roles;
 }
开发者ID:sindotnet,项目名称:hotelyan,代码行数:12,代码来源:Role.php

示例5: findByUserId

 public static function findByUserId($id)
 {
     $userroles = UserRole::find(array('where' => 'user_id = :user_id', 'values' => array(':user_id' => (int) $id)));
     if (count($userroles) <= 0) {
         return false;
     }
     $roles = array();
     foreach ($userroles as $role) {
         $roles[] = Role::findById($role->role_id);
     }
     return $roles;
 }
开发者ID:ariksavage,项目名称:superior-optical-eyewear,代码行数:12,代码来源:Role.php

示例6: delete

 public function delete($id)
 {
     $role = Role::findById($id);
     if ($role->delete()) {
         Flash::set('success', __('The ' . $name . ' user group has been deleted.'));
         redirect(get_url('plugin/registered_users/groups'));
     } else {
         Flash::set('success', __('Unable to delete the ' . $name . ' user group!'));
         redirect(get_url('plugin/registered_users/groups'));
     }
 }
开发者ID:blr21560,项目名称:registered_users,代码行数:11,代码来源:RegisteredUsersController.php


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