Group.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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('User');
  19. $this->view->assign("statusList", $this->model->getStatusList());
  20. }
  21. /**
  22. * 查看
  23. */
  24. public function index()
  25. {
  26. //设置过滤方法
  27. $this->request->filter(['strip_tags', 'trim']);
  28. if ($this->request->isAjax()) {
  29. //如果发送的来源是Selectpage,则转发到Selectpage
  30. if ($this->request->request('keyField')) {
  31. return $this->selectpage();
  32. }
  33. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  34. $list = $this->model
  35. //->with('group')
  36. ->where($where)
  37. ->order($sort, $order)
  38. ->paginate($limit);
  39. // foreach ($list as $k => $v) {
  40. // $v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname);
  41. // $v->hidden(['password', 'salt']);
  42. // }
  43. $result = array("total" => $list->total(), "rows" => $list->items());
  44. return json($result);
  45. }
  46. return $this->view->fetch();
  47. }
  48. public function add()
  49. {
  50. if ($this->request->isPost()) {
  51. $this->token();
  52. }
  53. $nodeList = \app\admin\model\UserRule::getTreeList();
  54. $this->assign("nodeList", $nodeList);
  55. return parent::add();
  56. }
  57. public function edit($ids = null)
  58. {
  59. if ($this->request->isPost()) {
  60. $this->token();
  61. }
  62. $row = $this->model->get($ids);
  63. if (!$row) {
  64. $this->error(__('No Results were found'));
  65. }
  66. $rules = explode(',', $row['rules']);
  67. $nodeList = \app\admin\model\UserRule::getTreeList($rules);
  68. $this->assign("nodeList", $nodeList);
  69. return parent::edit($ids);
  70. }
  71. }