角色开发中
This commit is contained in:
parent
cc13121bb8
commit
e90b2f8c83
@ -73,4 +73,62 @@ class Group extends AdminApi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// if ($this->request->isAjax()) {
|
||||||
|
$list = $this->grouplist;
|
||||||
|
$total = count($list);
|
||||||
|
$result = array("total" => $total, "rows" => $list);
|
||||||
|
$this->success('查询成功', $result);
|
||||||
|
// return json($result);
|
||||||
|
// }
|
||||||
|
// return $this->view->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
if ($this->request->isPost()) {
|
||||||
|
$this->token();
|
||||||
|
$params = $this->request->post();
|
||||||
|
foreach ($params as $k => &$v){
|
||||||
|
$params[$k] = strip_tags($v);
|
||||||
|
}
|
||||||
|
|
||||||
|
$params['rules'] = explode(',', $params['rules']);
|
||||||
|
if (!in_array($params['pid'], $this->childrenGroupIds)) {
|
||||||
|
$this->error(__('The parent group exceeds permission limit'));
|
||||||
|
}
|
||||||
|
$parentmodel = (new AuthGroup)->get($params['pid']);
|
||||||
|
if (!$parentmodel) {
|
||||||
|
$this->error(__('The parent group can not found'));
|
||||||
|
}
|
||||||
|
// 父级别的规则节点
|
||||||
|
$parentrules = explode(',', $parentmodel->rules);
|
||||||
|
// 当前组别的规则节点
|
||||||
|
$currentrules = $this->auth->getRuleIds();
|
||||||
|
$rules = $params['rules'];
|
||||||
|
// 如果父组不是超级管理员则需要过滤规则节点,不能超过父组别的权限
|
||||||
|
$rules = in_array('*', $parentrules) ? $rules : array_intersect($parentrules, $rules);
|
||||||
|
// 如果当前组别不是超级管理员则需要过滤规则节点,不能超当前组别的权限
|
||||||
|
$rules = in_array('*', $currentrules) ? $rules : array_intersect($currentrules, $rules);
|
||||||
|
$params['rules'] = implode(',', $rules);
|
||||||
|
if ($params) {
|
||||||
|
$this->model->create($params);
|
||||||
|
$this->success();
|
||||||
|
}
|
||||||
|
$this->error();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user