Adminlog.php 3.2 KB

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