作者 Karson

更新权限管理语言包

@@ -84,12 +84,13 @@ class Group extends Backend @@ -84,12 +84,13 @@ class Group extends Backend
84 if (!in_array($params['pid'], $this->childrenIds)) 84 if (!in_array($params['pid'], $this->childrenIds))
85 { 85 {
86 $this->code = -1; 86 $this->code = -1;
  87 + $this->msg = __('');
87 return; 88 return;
88 } 89 }
89 $parentmodel = model("AuthGroup")->get($params['pid']); 90 $parentmodel = model("AuthGroup")->get($params['pid']);
90 if (!$parentmodel) 91 if (!$parentmodel)
91 { 92 {
92 - $this->code = -1; 93 + $this->msg = __('The parent group can not found');
93 return; 94 return;
94 } 95 }
95 // 父级别的规则节点 96 // 父级别的规则节点
@@ -126,10 +127,10 @@ class Group extends Backend @@ -126,10 +127,10 @@ class Group extends Backend
126 { 127 {
127 $this->code = -1; 128 $this->code = -1;
128 $params = $this->request->post("row/a"); 129 $params = $this->request->post("row/a");
129 - // 节点不能是它自身的子节点 130 + // 节点不能是它自身的子节点
130 if (!in_array($params['pid'], $this->childrenIds)) 131 if (!in_array($params['pid'], $this->childrenIds))
131 { 132 {
132 - $this->code = -1; 133 + $this->msg = __('The parent group can not be its own child');
133 return; 134 return;
134 } 135 }
135 $params['rules'] = explode(',', $params['rules']); 136 $params['rules'] = explode(',', $params['rules']);
@@ -137,7 +138,7 @@ class Group extends Backend @@ -137,7 +138,7 @@ class Group extends Backend
137 $parentmodel = model("AuthGroup")->get($params['pid']); 138 $parentmodel = model("AuthGroup")->get($params['pid']);
138 if (!$parentmodel) 139 if (!$parentmodel)
139 { 140 {
140 - $this->code = -1; 141 + $this->msg = __('The parent group can not found');
141 return; 142 return;
142 } 143 }
143 // 父级别的规则节点 144 // 父级别的规则节点
@@ -200,6 +201,11 @@ class Group extends Backend @@ -200,6 +201,11 @@ class Group extends Backend
200 continue; 201 continue;
201 } 202 }
202 } 203 }
  204 + if (!$ids)
  205 + {
  206 + $this->msg = __('You can not delete group that contain child group and administrators');
  207 + return;
  208 + }
203 $count = $this->model->where('id', 'in', $ids)->delete(); 209 $count = $this->model->where('id', 'in', $ids)->delete();
204 if ($count) 210 if ($count)
205 { 211 {
  1 +<?php
  2 +
  3 +return [
  4 + 'Group' => '所属组别',
  5 + 'Login time' => '最后登录',
  6 +];
  1 +<?php
  2 +
  3 +return [
  4 + 'The parent group can not be its own child' => '父组别不能是自身的子组别',
  5 + 'The parent group can not found' => '父组别未找到',
  6 + 'You can not delete group that contain child group and administrators' => '你不能删除含有子组和管理员的组',
  7 +];
  1 +<?php
  2 +
  3 +return [
  4 + 'Toggle all' => '显示全部',
  5 + 'Condition' => '条件',
  6 + 'Remark' => '备注',
  7 + 'Icon' => '图标',
  8 + 'Alert' => '警告',
  9 + 'If not necessary, use the command line to build rule' => '非必要情况下请使用命令行来生成',
  10 +];
1 <div class="callout callout-info"> 1 <div class="callout callout-info">
2 <h4>{:__('Alert')}!</h4> 2 <h4>{:__('Alert')}!</h4>
3 - {:__('If not necessary, use the rebuild node feature directly')} 3 + {:__('If not necessary, use the command line to build rule')}
4 </div> 4 </div>
5 <form id="add-form" class="form-horizontal form-ajax" role="form" data-toggle="validator" method="POST" action=""> 5 <form id="add-form" class="form-horizontal form-ajax" role="form" data-toggle="validator" method="POST" action="">
6 <div class="form-group"> 6 <div class="form-group">
@@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
8 <div id="toolbar" class="toolbar"> 8 <div id="toolbar" class="toolbar">
9 {:build_toolbar()} 9 {:build_toolbar()}
10 <a href="javascript:;" class="btn btn-danger btn-toggle-all"><i class="fa fa-plus"></i> {:__('Toggle all')}</a> 10 <a href="javascript:;" class="btn btn-danger btn-toggle-all"><i class="fa fa-plus"></i> {:__('Toggle all')}</a>
11 - <a href="javascript:;" class="btn btn-danger btn-rebuild">{:__('Rebuild node')}</a>  
12 </div> 11 </div>
13 <table id="table" class="table table-bordered table-hover" width="100%"> 12 <table id="table" class="table table-bordered table-hover" width="100%">
14 13
@@ -41,69 +41,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function @@ -41,69 +41,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
41 // 为表格绑定事件 41 // 为表格绑定事件
42 Table.api.bindevent(table);//当内容渲染完成后 42 Table.api.bindevent(table);//当内容渲染完成后
43 43
44 - $(document).on("click", ".btn-rebuild", function () {  
45 - Backend.api.layer.confirm(  
46 - __('Are you sure you want to rebuild node?'),  
47 - {icon: 3, title: __('Warning'), offset: 0},  
48 - function (index) {  
49 - Backend.api.layer.close(index);  
50 - Backend.api.ajax({url: "auth/rule/rebuild", data: {step: 1}}, function (content) {  
51 - table.bootstrapTable('refresh');  
52 - var msg = '<div style="padding:20px;"><div class="alert alert-warning alert-light">' + __('You can change the node name if you want to') + '</div><label>' + __('Node list') + '</label><div id="treeview"></div></div>';  
53 - Backend.api.layer.open({  
54 - type: 1,  
55 - content: msg,  
56 - area: ['600px', '400px'],  
57 - scrollbar: false,  
58 - success: function (layero, index) {  
59 - require(['jstree'], function () {  
60 - $("#treeview", $(layero)).jstree({  
61 - "themes": {"stripes": true},  
62 - "types": {  
63 - "menu": {  
64 - "icon": "fa fa-folder-open",  
65 - "valid_children": []  
66 - },  
67 - "file": {  
68 - "icon": "fa fa-file-o",  
69 - "valid_children": []  
70 - }  
71 - },  
72 - "plugins": ["types"],  
73 - "core": {  
74 - 'check_callback': true,  
75 - "data": content  
76 - }  
77 - }).bind("select_node.jstree", function (e, data) {  
78 - var ref = $("#treeview", layero).jstree(true);  
79 - ref.edit(data.node);  
80 - });  
81 - });  
82 - }  
83 - ,  
84 - btn: [__('OK'), __('Cancel')],  
85 - yes: function (index, layero) {  
86 - //递归获取所有节点信息  
87 - var get_children = function (node) {  
88 - var data = [];  
89 - $.each(node, function (i, j) {  
90 - data.push({id: j.id, name: j.text});  
91 - data = data.concat(get_children(j.children));  
92 - });  
93 - return data;  
94 - };  
95 - var data = get_children($("#treeview").jstree('get_json'));  
96 - Backend.api.ajax({url: "auth/rule/rebuild", data: {step: 2, data: data}}, function (content) {  
97 - Backend.api.layer.close(index);  
98 - top.location.reload();  
99 - });  
100 - }  
101 - });  
102 -  
103 - });  
104 - }  
105 - );  
106 - });  
107 //默认隐藏所有子节点 44 //默认隐藏所有子节点
108 table.on('post-body.bs.table', function (e, settings, json, xhr) { 45 table.on('post-body.bs.table', function (e, settings, json, xhr) {
109 $("a.btn[data-id][data-pid][data-pid!=0]").closest("tr").hide(); 46 $("a.btn[data-id][data-pid][data-pid!=0]").closest("tr").hide();