Adminlog.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. namespace app\admin\controller\auth;
  3. use app\admin\model\AuthGroup;
  4. use app\common\controller\Backend;
  5. /**
  6. * 管理员日志
  7. *
  8. * @icon fa fa-users
  9. * @remark 管理员可以查看自己所拥有的权限的管理员日志
  10. */
  11. class Adminlog extends Backend
  12. {
  13. protected $model = null;
  14. protected $childrenGroupIds = [];
  15. protected $childrenAdminIds = [];
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = model('AdminLog');
  20. $this->childrenAdminIds = $this->auth->getChildrenAdminIds(true);
  21. $this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin() ? true : false);
  22. $groupName = AuthGroup::where('id', 'in', $this->childrenGroupIds)
  23. ->column('id,name');
  24. $this->view->assign('groupdata', $groupName);
  25. }
  26. /**
  27. * 查看
  28. */
  29. public function index()
  30. {
  31. if ($this->request->isAjax())
  32. {
  33. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  34. $total = $this->model
  35. ->where($where)
  36. ->where('admin_id', 'in', $this->childrenAdminIds)
  37. ->order($sort, $order)
  38. ->count();
  39. $list = $this->model
  40. ->where($where)
  41. ->where('admin_id', 'in', $this->childrenAdminIds)
  42. ->order($sort, $order)
  43. ->limit($offset, $limit)
  44. ->select();
  45. $result = array("total" => $total, "rows" => $list);
  46. return json($result);
  47. }
  48. return $this->view->fetch();
  49. }
  50. /**
  51. * 详情
  52. */
  53. public function detail($ids)
  54. {
  55. $row = $this->model->get(['id' => $ids]);
  56. if (!$row)
  57. $this->error(__('No Results were found'));
  58. $this->view->assign("row", $row->toArray());
  59. return $this->view->fetch();
  60. }
  61. /**
  62. * 添加
  63. * @internal
  64. */
  65. public function add()
  66. {
  67. $this->error();
  68. }
  69. /**
  70. * 编辑
  71. * @internal
  72. */
  73. public function edit($ids = NULL)
  74. {
  75. $this->error();
  76. }
  77. /**
  78. * 删除
  79. */
  80. public function del($ids = "")
  81. {
  82. if ($ids)
  83. {
  84. $childrenGroupIds = $this->childrenGroupIds;
  85. $adminList = $this->model->where('id', 'in', $ids)->where('admin_id', 'in', function($query) use($childrenGroupIds) {
  86. $query->name('auth_group_access')->field('uid');
  87. })->select();
  88. if ($adminList)
  89. {
  90. $deleteIds = [];
  91. foreach ($adminList as $k => $v)
  92. {
  93. $deleteIds[] = $v->id;
  94. }
  95. if ($deleteIds)
  96. {
  97. $this->model->destroy($deleteIds);
  98. $this->success();
  99. }
  100. }
  101. }
  102. $this->error();
  103. }
  104. /**
  105. * 批量更新
  106. * @internal
  107. */
  108. public function multi($ids = "")
  109. {
  110. // 管理员禁止批量操作
  111. $this->error();
  112. }
  113. public function selectpage()
  114. {
  115. return parent::selectpage();
  116. }
  117. }