Group.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\admin\controller\user;
  3. use app\common\controller\Backend;
  4. /**
  5. * 会员组管理
  6. *
  7. * @icon fa fa-users
  8. */
  9. class Group extends Backend
  10. {
  11. /**
  12. * @var \app\admin\model\UserGroup
  13. */
  14. protected $model = null;
  15. public function _initialize()
  16. {
  17. parent::_initialize();
  18. $this->model = model('UserGroup');
  19. $this->view->assign("statusList", $this->model->getStatusList());
  20. }
  21. public function add()
  22. {
  23. if ($this->request->isPost()) {
  24. $this->token();
  25. }
  26. $nodeList = \app\admin\model\UserRule::getTreeList();
  27. $this->assign("nodeList", $nodeList);
  28. return parent::add();
  29. }
  30. public function edit($ids = null)
  31. {
  32. if ($this->request->isPost()) {
  33. $this->token();
  34. }
  35. $row = $this->model->get($ids);
  36. if (!$row) {
  37. $this->error(__('No Results were found'));
  38. }
  39. $rules = explode(',', $row['rules']);
  40. $nodeList = \app\admin\model\UserRule::getTreeList($rules);
  41. $this->assign("nodeList", $nodeList);
  42. return parent::edit($ids);
  43. }
  44. }