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


PHP RoleModel::get_role方法代码示例

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


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

示例1: priv

 /**
  * ription 给角色设置操作权限
  *
  * @author
  *
  * @final
  *
  * @param int $id
  *            角色id
  * @param array $priv
  *            权限节点
  * @param int $r_action_type
  *            读操作
  * @param int $w_action_type
  *            写操作
  */
 public function priv($id = 0)
 {
     if (!$this->check_power('cpuser_role')) {
         return;
     }
     $id = intval($id);
     $id && ($role = RoleModel::get_role($id));
     if (!$role) {
         message('角色不存在');
         return;
     }
     $sql = "select class_id, class_name from {pre}question_class";
     $res = $this->db->query($sql)->result_array();
     $new_q_type = array();
     foreach ($res as $row) {
         $new_q_type[$row['class_id']] = $row['class_name'];
     }
     if ($this->input->post('dosubmit')) {
         $privs = $this->input->post('priv');
         if (empty($privs)) {
             $privs = array();
         }
         $subject_id_arr = array();
         $grade_id_arr = array();
         $q_type_id_arr = array();
         $arr = array();
         // pr($privs,1);
         $subject_id_count = 0;
         // 学科为空,过滤掉group_question,group_exam_paper
         if (empty($privs['group_subject'])) {
             unset($privs['group_question']);
             unset($privs['group_exam_paper']);
         }
         foreach ($privs as $key => $val) {
             // 单独区分出学科管理
             if ($key == 'group_subject') {
                 $subject_id_arr[] = count((array) $val) == count(C('subject')) ? '-1' : implode(',', (array) $val);
             } elseif ($key == 'group_grade') {
                 $grade_id_arr[] = count((array) $val) == count(C('grades')) ? '-1' : implode(',', (array) $val);
             } elseif ($key == 'group_q_type') {
                 $q_type_id_arr[] = count((array) $val) == count($new_q_type) ? '-1' : implode(',', (array) $val);
             } else {
                 $arr[] = implode(',', (array) $val);
             }
         }
         // 题库读写权限
         $r_action_type = intval($this->input->post('r_action_type'));
         $w_action_type = intval($this->input->post('w_action_type'));
         $r_action_type = $r_action_type < 1 || $r_action_type > 3 ? 1 : $r_action_type;
         $w_action_type = $w_action_type < 1 || $w_action_type > 3 ? 1 : $w_action_type;
         $action_type = array('question' => array('r' => $r_action_type, 'w' => $w_action_type));
         $this->db->update('role', array('subject_id' => implode(',', $subject_id_arr), 'grade_id' => implode(',', $grade_id_arr), 'q_type_id' => implode(',', $q_type_id_arr), 'action_list' => implode(',', $arr), 'action_type' => serialize($action_type)), array('role_id' => $id));
         admin_log('edit', 'role_priv', $id);
         message('权限设置成功', 'admin/role/priv/' . $id);
     } else {
         // 读写权限
         $data['action_type'] = array('1' => '自己创建', '2' => '所在学科', '3' => '所有学科');
         // 所有学科
         $data['subject'] = C('subject');
         $data['grade'] = C('grades');
         $data['q_type'] = $new_q_type;
         // $role['privs_subject'] = explode(',', $role['subject_id']);
         $role['privs_subject'] = $role['subject_id'] == '-1' ? array_keys($data['subject']) : explode(',', $role['subject_id']);
         $role['privs_grade'] = $role['grade_id'] == '-1' ? array_keys($data['grade']) : explode(',', $role['grade_id']);
         $role['privs_q_type'] = $role['q_type_id'] == '-1' ? array_keys($data['q_type']) : explode(',', $role['q_type_id']);
         $role['privs'] = explode(',', $role['action_list']);
         $data['roles'] = C('roles', 'app/admin/roles');
         $action_type = @unserialize($role['action_type']);
         $role['action_type'] = is_array($action_type) ? $action_type : array();
         $data['user'] = $role;
         // 模版
         $this->load->view('role/priv', $data);
     }
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:90,代码来源:role.php


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