├── README.MD ├── SrbacModule.php ├── common.css ├── config.php ├── controllers ├── DefaultController.php ├── RoleController.php └── SrbacController.php ├── helpers ├── Files.php └── Pinyin.php ├── screenshots ├── assign.png ├── assignuser.png ├── auth.png ├── child.png └── role.png └── views ├── bak ├── default │ ├── assign.php │ └── index.php └── role │ ├── child.php │ ├── role.php │ └── user.php ├── default ├── assign.php └── index.php └── role ├── child.php ├── role.php └── user.php /README.MD: -------------------------------------------------------------------------------- 1 | #srbac 2 | 3 | ## 功能描述 4 | 5 | 1.选择需要接受权限控制的功能。所以权限项已经自动生成 6 | 2.添加角色 7 | 3.为角色添加可操作的功能(在第一步中选择的功能中选择)。 8 | 4.为用户授权,在角色管理页面选择对应的角色行的"选择用户"。 9 | 10 | 11 | ## 使用说明 12 | 13 | 1. 确保yii2 rbac模块已经可以使用, 在backend配置文件main.php中加入如下代码 14 | ```php 15 | 'components' => [ 16 | 'authManager' => [//引入权限管理 17 | 'class' => 'yii\rbac\DbManager', 18 | ] 19 | ] 20 | ``` 21 | 2. 下载到 backend的modules目录,如没有,则新加 22 | 3. 在backend.php配置文件main.php中加引入此module 23 | ```php 24 | 'modules' => [ 25 | 'srbac' => [ //引入模块 26 | 'class' => 'backend\modules\srbac\SrbacModule', 27 | ] 28 | ] 29 | ``` 30 | 4. 如果想把其它应用比如frontend下的控制器也加入到权限控制中,则需要修改srbac下配置文件 31 | ```php 32 | 'srbacPath' => [ //其它 33 | 'frontend\controllers' 34 | ], 35 | ``` 36 | 5. 访问 /backend/web/index.php?r=srbac 37 | 38 | * 注意 1 要提前引入jquery 2.为角色选择用户页面,可能需要 common.css 即可 39 | 40 | ## 图例 41 | * 权限项添加 42 | ![image](https://github.com/cboy868/srbac/blob/master/screenshots/auth.png) 43 | * 角色管理 44 | ![image](https://github.com/cboy868/srbac/blob/master/screenshots/role.png) 45 | * 分配权限 46 | ![image](https://github.com/cboy868/srbac/blob/master/screenshots/assign.png) 47 | * 分配用户角色 48 | ![image](https://github.com/cboy868/srbac/blob/master/screenshots/assignuser.png) 49 | * 子角色 50 | ![image](https://github.com/cboy868/srbac/blob/master/screenshots/child.png) 51 | 52 | #### 联系方式 53 | 54 | cboy868@163.com 55 | -------------------------------------------------------------------------------- /SrbacModule.php: -------------------------------------------------------------------------------- 1 | params['foo'] = 'bar'; 16 | \Yii::configure($this, require(__DIR__ . '/config.php')); 17 | } 18 | } -------------------------------------------------------------------------------- /common.css: -------------------------------------------------------------------------------- 1 | .table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th { 2 | padding: 4px; 3 | } 4 | /* 5 | .breadcrumb>li+li:before { 6 | content: "\007c"; 7 | } 8 | */ 9 | .pagination li.page-info a { 10 | border: none; 11 | } 12 | .form-note{ 13 | height:34px; 14 | line-height:30px; 15 | } 16 | 17 | .form-actions { 18 | padding: 10px 20px 10px; 19 | } 20 | form .help-block, form .hint-block{ 21 | display: inline; 22 | } 23 | 24 | .checkbox+.checkbox, .radio+.radio{ 25 | margin-top: 10px; 26 | } 27 | input[type=checkbox].ace, input[type=radio].ace{ 28 | opacity:100; 29 | } 30 | input[type=checkbox], input[type=radio]{ 31 | margin: 0; 32 | } 33 | .checkbox, .radio{ 34 | margin-bottom: 0px; 35 | } 36 | .input-small{height: 20px;} 37 | div.search-outline { 38 | padding: 10px; 39 | border-radius: 4px; 40 | margin: 0px 0px 12px 0px; 41 | border: 1px solid #e1e1e1; 42 | background-color: #FAFAFA; 43 | -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.05); 44 | box-shadow: inset 0 1px 1px rgba(0,0,0,.05); 45 | } 46 | 47 | div.search-box input[type="text"], div.search-box select { 48 | padding: 2px; 49 | font-size: 12px; 50 | height: 24px; 51 | border-radius: 4px; 52 | } 53 | 54 | div.search-box .btn { 55 | padding: 1px 5px; 56 | font-size: 12px; 57 | line-height: 1.2; 58 | border-radius: 3px; 59 | } 60 | 61 | ul.u-list { 62 | margin: 0px; 63 | padding: 0px; 64 | list-style: none; 65 | font-size: 14px; 66 | padding: 2px 20px; 67 | border: 1px #ccc dashed; 68 | } 69 | 70 | ul.u-list li.selected { 71 | background-color: #E0DF95; 72 | } 73 | ul.u-list li { 74 | float: left; 75 | width: 6em; 76 | border: 1px solid white; 77 | margin: 5px; 78 | padding: 3px; 79 | cursor: pointer; 80 | } -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | [ 5 | // list of component configurations 6 | ], 7 | 'params' => [ 8 | // list of parameters 9 | 'srbacPath' => [ //其它 10 | // 'frontend\controllers' 11 | ], 12 | 'c' => 'd' 13 | ], 14 | ]; -------------------------------------------------------------------------------- /controllers/DefaultController.php: -------------------------------------------------------------------------------- 1 | _getBasePermission(); 23 | return $this->render('index', ['classes'=>$actions]); 24 | } 25 | 26 | /** 27 | * @title 分配权限 28 | */ 29 | public function actionAssign() 30 | { 31 | $auth = Yii::$app->authManager; 32 | $roles = $auth->getRoles(); 33 | return $this->render('assign', ['roles'=>$roles]); 34 | } 35 | 36 | /** 37 | * @title 配置角色权限 38 | */ 39 | public function actionAssignPermission() 40 | { 41 | $auth = Yii::$app->authManager; 42 | 43 | $request = Yii::$app->request; 44 | $role_name = $request->post('role', ''); 45 | $actions = $request->post('action', ''); 46 | $method = $request->post('method', 'add'); 47 | 48 | $role = $auth->getRole($role_name); 49 | 50 | $m = $method == 'add' ? 'addChild' : 'removeChild'; 51 | foreach ($actions as $v) { 52 | $permision = $auth->getPermission($v); 53 | $auth->$m($role, $permision); 54 | } 55 | $this->actionRolePermission($role_name[0]); 56 | } 57 | /** 58 | * @title 为某角色添加删除权限 59 | */ 60 | public function actionRolePermission($rolename='') 61 | { 62 | $auth = Yii::$app->authManager; 63 | $permisions = $auth->getPermissions(); 64 | $all = []; 65 | foreach ($permisions as $k => $v) { 66 | $all[] = $v->name; 67 | } 68 | $rolepermission = $auth->getPermissionsByRole($rolename); 69 | 70 | $assigned = []; 71 | $yet = $un = ''; 72 | $option = ' '; 73 | foreach ($rolepermission as $k => $v) { 74 | $assigned[] = $v->name; 75 | $yet .= sprintf($option, $v->name, $v->name); 76 | } 77 | 78 | $unassigned = array_diff($all, $assigned); 79 | foreach ($unassigned as $k =>$v) { 80 | $un .= sprintf($option, $v, $v); 81 | } 82 | $this->ajaxReturn(['yet'=>$yet, 'un'=>$un], null, 200); 83 | } 84 | 85 | /** 86 | * 创建许可 87 | * @title 创建许可 88 | */ 89 | public function actionCreatePermission() 90 | { 91 | if (Yii::$app->request->isAjax) { 92 | $request = Yii::$app->request; 93 | $permision = strtolower($request->get('permission')); 94 | $des = $request->get('des', ''); 95 | $check = $request->get('check'); 96 | if (empty($permision)) { 97 | return 0; 98 | } 99 | // p($check);die; 100 | $auth = Yii::$app->authManager; 101 | 102 | if ($check==='true') { 103 | $inDb = $auth->getPermission($permision); 104 | if ($inDb) { 105 | $inDb->description = $des; 106 | if ($auth->update($permision, $inDb)) { 107 | $this->ajaxReturn(null, null, 1); 108 | } 109 | } else { 110 | $createPermission = $auth->createPermission($permision); 111 | $createPermission->description = $des; 112 | if ($auth->add($createPermission)) { 113 | $this->ajaxReturn(null, null, 1); 114 | } 115 | } 116 | 117 | } else { 118 | $per = $auth->getPermission($permision); 119 | if ($auth->remove($per)) { 120 | $this->ajaxReturn(null, null, 1); 121 | } 122 | } 123 | } 124 | } 125 | /** 126 | * @title 取得权限 127 | */ 128 | private function _getBasePermission() 129 | { 130 | $methods = $this->_getMethods(); 131 | $permisions = []; 132 | foreach ($methods as $key => $val) { 133 | $name = str_replace('/', '_', str_replace('/modules/', '@', $key)); 134 | $arr = explode('_', $name); 135 | 136 | foreach ($val as $k => $v) { 137 | $permisions[$arr[0]][$arr[1]][$name.'_'.$k] = [ 138 | 'des' => $v, 139 | 'action' => $k 140 | ]; 141 | } 142 | } 143 | return $this->_isInDb($permisions); 144 | } 145 | 146 | /** 147 | * @title 取得方法 148 | */ 149 | private function _getMethods() 150 | { 151 | $module = \Yii::$app->controller->module; 152 | 153 | //在配置中添加的要接受控制的命名空间 154 | $namespaces = $module->params['srbacPath']; 155 | 156 | //不要接受控制的 module 157 | $sys_module = ['debug', 'gii']; 158 | 159 | $modules = Yii::$app->getModules(); 160 | foreach ($modules as $k => $v) { 161 | if (in_array($k, $sys_module)) { 162 | continue; 163 | } 164 | $mod = Yii::$app->getModule($k); 165 | $namespace = str_replace('/', '\\', $mod->controllerNamespace); 166 | array_push($namespaces, $namespace); 167 | } 168 | 169 | //当前所在命名空间的控制器 170 | $currentNamespace = str_replace('/', '\\', \Yii::$app->controllerNamespace); 171 | array_push($namespaces, $currentNamespace); 172 | 173 | //获取类方法 174 | $actions = Files::getAllMethods($namespaces); 175 | return $actions; 176 | } 177 | 178 | /** 179 | * 判断权限是否已经在库中 180 | */ 181 | private function _isInDb($control_actions) 182 | { 183 | $auth = Yii::$app->authManager; 184 | $model_actions = $auth->getPermissions(); 185 | 186 | $action_k_v = ArrayHelper::getColumn($model_actions, 'description'); 187 | foreach ($control_actions as $k => $value) { 188 | foreach ($value as $key => $val) { 189 | foreach ($val as $ac=>$v) { 190 | if (array_key_exists(strtolower($ac), $action_k_v) !== false) { 191 | $control_actions[$k][$key][$ac]['check']=true; 192 | !empty($action_k_v[$ac]) && 193 | $control_actions[$k][$key][$ac]['des'] = $action_k_v[$ac]; 194 | } 195 | } 196 | } 197 | } 198 | return $control_actions; 199 | } 200 | } -------------------------------------------------------------------------------- /controllers/RoleController.php: -------------------------------------------------------------------------------- 1 | auth = Yii::$app->authManager; 21 | } 22 | 23 | /** 24 | * @title 权限列表 25 | */ 26 | public function actionIndex() 27 | { 28 | $roles = $this->auth->getRoles(); 29 | $rules = $this->auth->getRules(); 30 | return $this->render('role', ['roles'=>$roles, 'rules'=>$rules]); 31 | } 32 | 33 | /** 34 | * @title 添加子角色 35 | */ 36 | public function actionChild() 37 | { 38 | $roles = $this->auth->getRoles(); 39 | return $this->render('child', ['roles'=>$roles]); 40 | } 41 | 42 | /** 43 | * @title 添加删除子角色 44 | */ 45 | public function actionRoleChild() 46 | { 47 | $request = Yii::$app->request; 48 | $role_name = $request->post('role', ''); 49 | $childs = $request->post('child'); 50 | $method = $request->post('method', 'add'); 51 | $role = $this->auth->getRole($role_name); 52 | 53 | $m = $method == 'add' ? 'addChild' : 'removeChild'; 54 | 55 | foreach ($childs as $v) { 56 | $child = $this->auth->getRole($v); 57 | $this->auth->$m($role, $child); 58 | 59 | } 60 | 61 | $this->actionGetChild($role_name); 62 | } 63 | 64 | /** 65 | * @title 取得一个角色的所有子角色 66 | */ 67 | public function actionGetChild($rolename) 68 | { 69 | 70 | if (!Yii::$app->request->isAjax) { 71 | echo 'wrong';die; 72 | } 73 | $roles = $this->auth->getRoles(); 74 | unset($roles[$rolename]); 75 | $all_roles = array_keys($roles); 76 | 77 | $option = ' '; 78 | 79 | $children = $this->auth->getChildren($rolename); 80 | $childs = []; 81 | $child = ''; 82 | foreach ($children as $k => $v) { 83 | if($v instanceof yii\rbac\Role) { 84 | array_push($childs, $v->name); 85 | $child .= sprintf($option, $v->name, $v->name); 86 | } 87 | } 88 | 89 | $no_child = array_diff($all_roles, $childs); 90 | 91 | $main_role = $this->auth->getRole($rolename); 92 | foreach ($no_child as $k => $v) { 93 | $role = $this->auth->getRole($v); 94 | if ($this->auth->hasChild($role, $main_role)) { 95 | unset($no_child[$k]); 96 | } 97 | } 98 | $other = ''; 99 | foreach ($no_child as $k => $v) { 100 | $other .= sprintf($option, $v, $v); 101 | } 102 | 103 | $this->ajaxReturn(['child'=>$child, 'other'=>$other], null, 1); 104 | } 105 | 106 | /** 107 | * @title 角色下的 所有用户 108 | */ 109 | public function actionUser($role_name) 110 | { 111 | 112 | $users = User::find()->where(['status' => 10]) 113 | ->andWhere('id>1') 114 | ->orderBy('username') 115 | ->all(); 116 | $users_info = []; 117 | foreach ($users as $k => $v) { 118 | $pin = strtoupper(substr(Pinyin::pinyin($v['username']), 0, 1)); 119 | $users_info[$pin][$v['id']] = [ 120 | 'username' => $v['username'], 121 | 'pinyin' => Pinyin::pinyin($v['username']), 122 | 'is_sel' => $this->auth->getAssignment($role_name, $v['id']) ? 1 : 0 123 | ]; 124 | } 125 | 126 | // p($users_info);die; 127 | return $this->render('user', ['user'=>$users_info]); 128 | } 129 | 130 | /** 131 | * @title 分配用户角色 132 | */ 133 | public function actionAssign() 134 | { 135 | $request = Yii::$app->request; 136 | $role_name = $request->post('role', ''); 137 | $user_id = $request->post('user_id', ''); 138 | $is_sel = $request->post('is_sel'); 139 | 140 | $role = $this->auth->getRole($role_name); 141 | 142 | if (is_array($user_id)) { 143 | foreach ($user_id as $k => $v) { 144 | $this->auth->assign($role, $v); 145 | } 146 | $this->ajaxReturn(null, null, 1); 147 | } 148 | 149 | if ($is_sel=='true') { //删除 删除 的方法 是啥 150 | if ($this->auth->revoke($role, $user_id)) { 151 | $this->ajaxReturn(null, null, 1); 152 | } 153 | } else { //增加 154 | if ($this->auth->assign($role, $user_id)) { 155 | $this->ajaxReturn(null, null, 1); 156 | } 157 | } 158 | } 159 | 160 | /** 161 | * @title 添加角色 162 | */ 163 | public function actionCreate() 164 | { 165 | 166 | $info = $_GET['role']; 167 | if (empty($info['name'])) { 168 | return 0; 169 | } 170 | 171 | $role = $this->auth->getRole($info['name']); 172 | $new = false; 173 | if (empty($role)) { 174 | $role = $this->auth->createRole($info['name']); 175 | $new = true; 176 | } 177 | !empty($info['description']) && $role->description = $info['description']; 178 | !empty($info['rule_name']) && $role->ruleName = $info['rule_name']; 179 | !empty($info['data']) && $role->data = $info['data']; 180 | 181 | if ($new) { 182 | if($this->auth->add($role)) 183 | { 184 | $this->ajaxReturn(null, null, 200); 185 | } 186 | } else { 187 | if ($this->auth->update($info['name'], $role)) { 188 | $this->ajaxReturn(null, null, 200); 189 | } 190 | } 191 | return 0; 192 | } 193 | 194 | /** 195 | * @title 删除角色 196 | */ 197 | public function actionDelete($role_name) 198 | { 199 | $role = $this->auth->getRole($role_name); 200 | if ($this->auth->remove($role)) { 201 | $this->ajaxReturn(null, null, 1); 202 | } 203 | $this->ajaxReturn(null, '删除失败,请重试', 0); 204 | } 205 | 206 | /** 207 | * @title 编辑角色 208 | */ 209 | public function actionEdit($role_name) 210 | { 211 | $role = $this->auth->getRole($role_name); 212 | if ($role) { 213 | $this->ajaxReturn($role, null, 1); 214 | } else { 215 | $this->ajaxReturn(null, '角色不存在', 0); 216 | } 217 | 218 | } 219 | } -------------------------------------------------------------------------------- /controllers/SrbacController.php: -------------------------------------------------------------------------------- 1 | user->isGuest) 20 | $this->redirect(Url::toRoute('/site/login')); 21 | } 22 | 23 | public function ajaxReturn($data = null, $info = '', $success = true) { 24 | header('Content-type: application/json'); 25 | $all = [ 26 | 'status' => $success, 27 | 'info' => $info, 28 | 'data' => $data, 29 | 'csrf' => Yii::$app->request->getCsrfToken() 30 | ]; 31 | echo json_encode($all); 32 | exit; 33 | } 34 | /** 35 | * @title 权限验证 36 | */ 37 | public function beforeAction($action) 38 | { 39 | if (parent::beforeAction($action)) { 40 | $ac = $this->getFullAction($action); 41 | $auth = Yii::$app->authManager; 42 | 43 | //判断是否是普通用户,如果是,跳到前台 44 | $role = $auth->getRolesByUser(Yii::$app->user->getId()); 45 | $customer_role = $auth->getRole('customer'); 46 | if (isset($role['customer']) && $role['customer'] == $customer_role) { 47 | Yii::$app->getSession()->setFlash('error', '非法操作'); 48 | $this->redirect('/'); 49 | } 50 | 51 | if (($auth->getPermission($ac) && !\Yii::$app->user->can($ac)) && \Yii::$app->user->id!=1) { 52 | throw new BadRequestHttpException(Yii::t('yii', '您无权进行此操作')); 53 | } 54 | return true; 55 | } else { 56 | return false; 57 | } 58 | } 59 | /** 60 | * @title 取得权限全名 61 | */ 62 | private function getFullAction($action) 63 | { 64 | $namespace = str_replace('\controllers', '', \Yii::$app->controllerNamespace); 65 | $mod = \Yii::$app->controller->module !== null ? '@'.\Yii::$app->controller->module->id : ""; 66 | $controller = \Yii::$app->controller->id; 67 | $ac = $action->id; 68 | return $namespace.$mod.'-'.$controller.'-'.$ac; 69 | } 70 | } -------------------------------------------------------------------------------- /helpers/Files.php: -------------------------------------------------------------------------------- 1 | $v) { 17 | if (!is_array($v)) { 18 | continue; 19 | } 20 | $namespace = $k.'\\controllers'; 21 | 22 | $pre = strpos($k, '/') ? $k.self::$separate : $k.'/'; 23 | foreach ($v as $key => $val) { 24 | $controller_namespace = $namespace .'\\'.$val.'Controller'; 25 | $val = self::uper2lower($val); 26 | $actions[$pre.$val] = self::getClassMethods($controller_namespace); 27 | } 28 | } 29 | return $actions; 30 | } 31 | 32 | /** 33 | * @title 取得某命名空间下的所有类 34 | */ 35 | public static function getClasses($namespaces) 36 | { 37 | foreach ($namespaces as $k=>$v) { 38 | $namespace = str_replace('\\', '/', $v); 39 | $dir = Yii::getAlias('@'.$namespace); 40 | $key = str_replace('/controllers', '', $namespace); 41 | $classes[$key] = self::scan($dir); 42 | } 43 | return $classes; 44 | } 45 | 46 | /** 47 | * @title 取得一个类的所有公共方法 48 | */ 49 | public static function getClassMethods($controller) 50 | { 51 | 52 | $actions = []; 53 | $controller = str_replace('/', '\\', $controller); 54 | $class = new \ReflectionClass($controller);//建立反射类 55 | $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC); 56 | $filter = ['actions', 'behaviors']; 57 | foreach ($methods as $method) { 58 | if ($method->class ==$controller && !in_array($method->name, $filter)) { 59 | preg_match('/\* @title(.*)/', $method->getDocComment(), $matches); 60 | $key = substr($method->name, 0, 6) == 'action' ? substr($method->name,6) : $method->name; 61 | $key = self::uper2lower($key); 62 | $actions[$key] = isset($matches[1]) ? trim($matches[1]) : ''; 63 | } 64 | } 65 | return $actions; 66 | } 67 | 68 | /** 69 | * @title 扫描目录文件 70 | */ 71 | public static function scan($dir) 72 | { 73 | $classes = array_diff(\scandir($dir), ['.','..']); 74 | foreach ($classes as $k => &$v) { 75 | if (substr($v, -14) != 'Controller.php') { 76 | unset($classes[$k]); 77 | } 78 | $v = substr($v, 0, -14); 79 | }unset($v); 80 | return $classes; 81 | } 82 | 83 | public static function uper2lower($action_id) 84 | { 85 | return ltrim(strtolower(preg_replace('/([A-Z])/', '-${1}', $action_id)),'-'); 86 | } 87 | } -------------------------------------------------------------------------------- /helpers/Pinyin.php: -------------------------------------------------------------------------------- 1 | 160) { 70 | $q = ord(substr($str, ++$i, 1)); 71 | $p = $p*256 + $q - 65536; 72 | } 73 | $res .= self::pin($p, $data); 74 | } 75 | return $res; 76 | } 77 | 78 | public static function pin($num, $data) 79 | { 80 | if ($num>0 && $num<160 ) { 81 | return chr($num); 82 | } elseif ($num<-20319 || $num>-10247) { 83 | return ''; 84 | } else { 85 | foreach($data as $k=>$v){ if($v<=$num) break; } 86 | return $k; 87 | } 88 | } 89 | public static function utf8_gb($c) 90 | { 91 | $str = ''; 92 | if($c < 0x80) { 93 | $str .= $c; 94 | } elseif($c < 0x800) { 95 | $str .= chr(0xC0 | $c>>6); 96 | $str .= chr(0x80 | $c & 0x3F); 97 | } elseif($c < 0x10000) { 98 | $str .= chr(0xE0 | $c>>12); 99 | $str .= chr(0x80 | $c>>6 & 0x3F); 100 | $str .= chr(0x80 | $c & 0x3F); 101 | } elseif($c < 0x200000) { 102 | $str .= chr(0xF0 | $c>>18); 103 | $str .= chr(0x80 | $c>>12 & 0x3F); 104 | $str .= chr(0x80 | $c>>6 & 0x3F); 105 | $str .= chr(0x80 | $c & 0x3F); 106 | } 107 | return iconv('UTF-8', 'GB2312', $str); 108 | } 109 | public static function arrayCombine() 110 | { 111 | 112 | $key = explode('|', self::trimspace(self::KEY)); 113 | $value = explode('|', self::trimspace(self::VALUE)); 114 | if(PHP_VERSION>='5.0') return array_combine($key, $value); 115 | 116 | for($i=0; $ititle = '权限管理'; 12 | ?> 13 | 14 | 28 | 29 |
30 | 31 |
32 | 41 |
42 |

SRBAC使用分为几步:

43 |

1.选择需要接受权限控制的功能。 go!

44 |

2.添加角色。 go!

45 |

3.为角色添加可操作的功能(在第一步中选择的功能中选择)。

46 |

4.为用户授权,在角色管理页面选择对应的角色行的"选择用户"。 go!

47 |
48 | 49 |
50 | 51 |
52 |
53 |
54 |
角色
55 |
56 | 57 |
58 | 63 |
64 |
65 |
66 | 67 |
68 |
69 |
70 |
分配权限
71 |
72 | 添加<<>>删除 73 |
74 |
75 | 76 |
77 |
78 |
79 | 80 |
81 |
82 |
83 | 84 | 85 |
86 |
87 |
88 | 89 |
90 |
91 |
92 |
93 |
94 | 95 | 96 |
97 |
98 |
99 | 100 | 105 | -------------------------------------------------------------------------------- /views/bak/default/index.php: -------------------------------------------------------------------------------- 1 | title = '权限管理'; 12 | ?> 13 | 14 | 28 | 29 |
30 | 31 |
32 | 42 |
43 |

SRBAC使用分为几步:

44 |

1.选择需要接受权限控制的功能。

45 |

2.添加角色。 go!

46 |

3.为角色添加可操作的功能(在第一步中选择的功能中选择)。 go!

47 |

4.为用户授权,在角色管理页面选择对应的角色行的"选择用户"。 go!

48 |
49 | 50 |
51 | $value):?> 52 |
53 |
54 |
55 |

56 |
57 | 58 | 59 | 60 |
61 |
62 |
63 |
64 | $val):?> 65 |
66 |
67 | 70 | $v):?> 71 |
72 | 78 |
79 | 80 |
81 | 82 |
83 |
84 |
85 |
86 | 87 |
88 |
89 |
90 | 91 | 94 | -------------------------------------------------------------------------------- /views/bak/role/child.php: -------------------------------------------------------------------------------- 1 | title = '添加子角色'; 12 | ?> 13 | 14 | 28 | 29 |
30 | 31 |
32 | 41 | 42 | 43 |
44 |
45 |
46 |
47 |
角色
48 |
49 | 50 |
51 | 56 |
57 |
58 |
59 | 60 |
61 |
62 |
63 |
添加子角色
64 |
65 | 子角色<<>>基它角色 66 |
67 |
68 | 69 |
70 |
71 |
72 | 75 |
76 |
77 |
78 | 79 | 80 |
81 |
82 |
83 | 86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 | 95 | 96 | 97 | 102 | -------------------------------------------------------------------------------- /views/bak/role/role.php: -------------------------------------------------------------------------------- 1 | title = '角色管理'; 12 | ?> 13 | 14 | 31 |
32 | 33 |
34 | 43 |
44 |

SRBAC使用分为几步:

45 |

1.选择需要接受权限控制的功能。 go!

46 |

2.添加角色,点击顶端红色"添加角色"按扭

47 |

3.为角色添加可操作的功能(在第一步中选择的功能中选择)。 go!

48 |

4.为用户授权,点对应角色的"选择用户"按扭

49 |
50 |
51 |
52 | 53 |
54 |
55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 77 | 78 | 79 | 80 | 81 | 84 | 85 | 98 | 99 | 100 | 101 |
角色名描述规则名 63 | 64 | 数据 65 | 添加时间
75 | name?> 76 | description?>ruleName?> 82 | data?> 83 | createdAt)?> 86 | 97 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | 175 | 176 | 242 | 243 | 246 | -------------------------------------------------------------------------------- /views/bak/role/user.php: -------------------------------------------------------------------------------- 1 | title = '用户角色管理'; 12 | ?> 13 | 14 | 28 |
29 | 30 |
31 | 40 | 41 |
42 |
43 | $v): ?> 44 |

45 |
    46 | $val): ?> 47 |
  • 48 | 49 |
  • 50 | 51 |
    52 |
53 | 54 | 55 | 56 |
57 |
58 | 59 | 83 |
84 |
85 | 86 | 89 | 90 | -------------------------------------------------------------------------------- /views/default/assign.php: -------------------------------------------------------------------------------- 1 | title = '权限管理'; 12 | ?> 13 | 14 | 26 | 27 |
28 | 29 |
30 | 39 | 40 | 45 |
46 | 47 |
SRBAC使用分为几步:
48 |

1.选择需要接受权限控制的功能。 go!

49 |

2.添加角色。 go!

50 |

3.为角色添加可操作的功能(在第一步中选择的功能中选择)

51 |

4.为用户授权,在角色管理页面选择对应的角色行的"选择用户"。 go!

52 |
53 | 54 |
55 |
56 |
57 |
58 |

角色

59 |
60 |
61 | 66 |
67 |
68 |
69 |
70 |
71 |
72 |

分配权限 73 |
74 | 添加<<>>删除 75 |
76 |

77 |
78 |
79 |
80 | 81 |
82 |
83 |
84 | 85 | 86 |
87 |
88 |
89 | 90 |
91 |
92 |
93 |
94 | 95 |
96 |
97 |
98 | 99 | 104 | -------------------------------------------------------------------------------- /views/default/index.php: -------------------------------------------------------------------------------- 1 | title = '权限管理'; 7 | ?> 8 | 9 | 20 | 21 |
22 | 23 |
24 | 34 | 35 | 40 |
41 | 42 |
SRBAC使用分为几步:
43 |

1.选择需要接受权限控制的功能。

44 |

2.添加角色。 go!

45 |

3.为角色添加可操作的功能(在第一步中选择的功能中选择)。 go!

46 |

4.为用户授权,在角色管理页面选择对应的角色行的"选择用户"。 go!

47 |
48 | 49 |
50 | 51 |
52 | $value):?> 53 |
54 |
55 |

56 |
57 |
58 | $val):?> 59 |
60 |
61 | $v):?> 62 |
63 | 69 |
70 | 71 |
72 |
73 | 74 |
75 |
76 | 77 |
78 |
79 |
80 |
81 | 82 | 85 | -------------------------------------------------------------------------------- /views/role/child.php: -------------------------------------------------------------------------------- 1 | title = '添加子角色'; 6 | ?> 7 | 8 | 23 | 24 |
25 | 26 |
27 | 36 | 37 | 38 |
39 | 40 |
41 |
42 |
43 |

角色

44 |
45 |
46 | 51 |
52 |
53 |
54 | 55 |
56 |
57 |
58 |

分配权限 59 |
60 | 添加<<>>删除 61 |
62 |

63 |
64 |
65 |
66 | 69 |
70 |
71 |
72 | 73 | 74 |
75 |
76 |
77 | 80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | 88 | 89 | 90 | 95 | -------------------------------------------------------------------------------- /views/role/role.php: -------------------------------------------------------------------------------- 1 | title = '角色管理'; 12 | ?> 13 | 14 | 27 |
28 | 29 |
30 | 39 | 40 | 45 |
46 |
SRBAC使用分为几步:
47 |

1.选择需要接受权限控制的功能。 go!

48 |

2.添加角色。 go!

49 |

3.为角色添加可操作的功能(在第一步中选择的功能中选择)。 go!

50 |

4.为用户授权,在角色管理页面选择对应的角色行的"选择用户"。

51 |
52 | 53 |
54 |
55 | 56 |
57 |
58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 80 | 81 | 82 | 83 | 84 | 87 | 88 | 101 | 102 | 103 | 104 |
角色名描述规则名 66 | 67 | 数据 68 | 添加时间
78 | name?> 79 | description?>ruleName?> 85 | data?> 86 | createdAt)?> 89 | 100 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 | 178 | 179 | 245 | 246 | 249 | -------------------------------------------------------------------------------- /views/role/user.php: -------------------------------------------------------------------------------- 1 | title = '用户角色管理'; 12 | ?> 13 | 14 | 28 |
29 | 30 |
31 | 40 | 41 |
42 |
43 | $v): ?> 44 |
45 |
    46 | $val): ?> 47 |
  • 48 | 49 |
  • 50 | 51 |
    52 |
53 | 54 | 55 | 56 |
57 |
58 | 59 | 83 |
84 |
85 | 86 | 89 | 90 | --------------------------------------------------------------------------------