|
@@ -29,6 +29,7 @@ class Group extends Apic
|
|
|
//无需要权限判断的方法
|
|
|
protected $noNeedRight = ['roletree'];
|
|
|
|
|
|
+
|
|
|
public function _initialize()
|
|
|
{
|
|
|
parent::_initialize();
|
|
@@ -49,7 +50,7 @@ class Group extends Apic
|
|
|
if (in_array($n['id'], $groupIds) || in_array($n['pid'], $groupIds)) {
|
|
|
continue;
|
|
|
}
|
|
|
- $groupList = array_merge($groupList, Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['pid'])));
|
|
|
+ $groupList = array_merge($groupList, Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['pid'])));//费了很大的劲,把自己加入到了子组的第一个
|
|
|
foreach ($groupList as $index => $item) {
|
|
|
$groupIds[] = $item['id'];
|
|
|
}
|
|
@@ -62,9 +63,9 @@ class Group extends Apic
|
|
|
|
|
|
$this->grouplist = $groupList;
|
|
|
$this->groupdata = $groupName;
|
|
|
- $this->assignconfig("admin", ['id' => $this->auth->id, 'group_ids' => $this->auth->getGroupIds()]);
|
|
|
+// $this->assignconfig("admin", ['id' => $this->auth->id, 'group_ids' => $this->auth->getGroupIds()]);
|
|
|
|
|
|
- $this->view->assign('groupdata', $this->groupdata);
|
|
|
+// $this->view->assign('groupdata', $this->groupdata);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -72,14 +73,13 @@ class Group extends Apic
|
|
|
*/
|
|
|
public function index()
|
|
|
{
|
|
|
- if ($this->request->isAjax()) {
|
|
|
+
|
|
|
$list = $this->grouplist;
|
|
|
- $total = count($list);
|
|
|
- $result = array("total" => $total, "rows" => $list);
|
|
|
+// $total = count($list);
|
|
|
+// $result = array("total" => $total, "list" => $list);
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
|
|
|
- return json($result);
|
|
|
- }
|
|
|
- return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -87,9 +87,15 @@ class Group extends Apic
|
|
|
*/
|
|
|
public function add()
|
|
|
{
|
|
|
- if ($this->request->isPost()) {
|
|
|
- $this->token();
|
|
|
- $params = $this->request->post("row/a", [], 'strip_tags');
|
|
|
+
|
|
|
+
|
|
|
+ $params = [
|
|
|
+ 'company_id' => $this->auth->company_id,
|
|
|
+ 'pid' => input('pid',0),
|
|
|
+ 'name' => input('name',''),
|
|
|
+ 'rules' => input('rules','','strip_tags'),
|
|
|
+ 'status' => 'normal',
|
|
|
+ ];
|
|
|
$params['rules'] = explode(',', $params['rules']);
|
|
|
if (!in_array($params['pid'], $this->childrenGroupIds)) {
|
|
|
$this->error(__('The parent group exceeds permission limit'));
|
|
@@ -113,15 +119,15 @@ class Group extends Apic
|
|
|
$this->success();
|
|
|
}
|
|
|
$this->error();
|
|
|
- }
|
|
|
- return $this->view->fetch();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑
|
|
|
*/
|
|
|
- public function edit($ids = null)
|
|
|
+ public function info()
|
|
|
{
|
|
|
+ $ids = input('id','');
|
|
|
if (!in_array($ids, $this->childrenGroupIds)) {
|
|
|
$this->error(__('You have no permission'));
|
|
|
}
|
|
@@ -129,9 +135,26 @@ class Group extends Apic
|
|
|
if (!$row) {
|
|
|
$this->error(__('No Results were found'));
|
|
|
}
|
|
|
- if ($this->request->isPost()) {
|
|
|
- $this->token();
|
|
|
- $params = $this->request->post("row/a", [], 'strip_tags');
|
|
|
+ $this->success(1,$row);
|
|
|
+ }
|
|
|
+ public function edit()
|
|
|
+ {
|
|
|
+ $ids = input('id','');
|
|
|
+ if (!in_array($ids, $this->childrenGroupIds)) {
|
|
|
+ $this->error(__('You have no permission1'));
|
|
|
+ }
|
|
|
+ $row = $this->model->get(['id' => $ids]);
|
|
|
+ if (!$row) {
|
|
|
+ $this->error(__('No Results were found'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $params = [
|
|
|
+ 'pid' => input('pid',0),
|
|
|
+ 'name' => input('name',''),
|
|
|
+ 'rules' => input('rules','','strip_tags'),
|
|
|
+ 'status' => 'normal',
|
|
|
+ ];
|
|
|
//父节点不能是非权限内节点
|
|
|
if (!in_array($params['pid'], $this->childrenGroupIds)) {
|
|
|
$this->error(__('The parent group exceeds permission limit'));
|
|
@@ -175,21 +198,17 @@ class Group extends Apic
|
|
|
}
|
|
|
}
|
|
|
$this->error();
|
|
|
- return;
|
|
|
- }
|
|
|
- $this->view->assign("row", $row);
|
|
|
- return $this->view->fetch();
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
|
*/
|
|
|
- public function del($ids = "")
|
|
|
+ public function del()
|
|
|
{
|
|
|
- if (!$this->request->isPost()) {
|
|
|
- $this->error(__("Invalid parameters"));
|
|
|
- }
|
|
|
- $ids = $ids ? $ids : $this->request->post("ids");
|
|
|
+
|
|
|
+ $ids = input('id','');
|
|
|
if ($ids) {
|
|
|
$ids = explode(',', $ids);
|
|
|
$grouplist = $this->auth->getGroups();
|