/** * 编辑用户 */ 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); }
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']; }