Пример #1
0
 public function actionDel()
 {
     $id = $this->helpGparam('id');
     $ret = Func::deleteFuncById($id);
     if ($ret > 0) {
         echo Json::encode(array('code' => 200, 'message' => '权限项已删除', 'data' => $ret));
     } else {
         echo Json::encode(array('code' => 500, 'message' => '权限项删除失败', 'data' => $ret));
     }
 }
Пример #2
0
 private function initFuncsData()
 {
     $funcList = Func::getByParentId(0, array(1), array('order_by' => SORT_ASC));
     $iconList = $this->loadModuleIcon();
     foreach ($funcList as $k => $func) {
         $func_id = $func['id'];
         $funcList[$k]['bigicon'] = isset($iconList[$func_id]['big']) ? $iconList[$func_id]['big'] : '';
         $funcList[$k]['smallicon'] = isset($iconList[$func_id]['small']) ? $iconList[$func_id]['small'] : '';
         $funcList[$k]['child'] = Func::getByParentId($func_id, array(1), array('order_by' => SORT_ASC));
     }
     $this->funclist = $funcList;
 }
Пример #3
0
 /**
  * 编辑用户
  */
 public function actionEdit()
 {
     $uid = $uid = $this->helpGparam('uid');
     $userinfo = Users::getById($uid);
     //加载所有角色
     $roleList = Roles::getByUsergroupId($this->user_group_id);
     $user_role_ids = User_Role_Relate::getByUid($uid);
     //加载所有功能
     $funcList = Func::getByParentId(0);
     $funcData = array();
     foreach ($funcList as $k => $func) {
         $data = array('id' => $func['id'], 'name' => $func['caption'], 'isParent' => true, 'open' => true);
         $childList = Func::getByParentId($func['id']);
         $data['children'] = array();
         foreach ($childList as $cf) {
             $data['children'][] = array('id' => $cf['id'], 'name' => $cf['caption'], 'pId' => $func['id'], 'isParent' => false);
         }
         $funcData[] = $data;
     }
     $data = ['userinfo' => $userinfo, 'funcData' => $funcData, 'uid' => $uid, 'roleList' => $roleList, 'user_role_ids' => $user_role_ids];
     return $this->render('edit', $data);
 }
Пример #4
0
 private function getFuncsData()
 {
     $funcList = Func::getByParentId(0);
     $funcData = array();
     foreach ($funcList as $k => $func) {
         $data = array('id' => $func['id'], 'name' => $func['caption'], 'fatherid' => 0, 'isparent' => true);
         $childList = Func::getByParentId($func['id']);
         $data['children'] = array();
         foreach ($childList as $cf) {
             $data['children'][] = array('id' => $cf['id'], 'name' => $cf['caption'], 'fatherid' => $func['id'], 'isparent' => false);
         }
         $funcData[] = $data;
     }
     return $funcData;
 }
Пример #5
0
 public function getMyFunc()
 {
     $user_id = $this->getId();
     $myFunc = array();
     //获取角色权限
     $func_ids = [];
     $myRoles = User_Role_Relate::getByUid($user_id);
     if (!empty($myRoles)) {
         foreach ($myRoles as $role) {
             $rolePurviews = Role_Purview::getByRoleId($role['role_id']);
             foreach ($rolePurviews as $rolePurview) {
                 $func_ids[] = $rolePurview['func_id'];
             }
         }
     }
     //获取用户权限
     $userPurviews = User_Purview::getByUid($user_id);
     if (!empty($userPurviews)) {
         foreach ($userPurviews as $purview) {
             $func_ids[] = $purview['func_id'];
         }
     }
     $condition = ['id' => $func_ids];
     $myFunc = Func::search($condition, 0, 0, array('id' => SORT_ASC), false, 'id');
     return $myFunc['list'];
 }