From afe0fdce73956053cc9d1c9134188da06ad3ec48 Mon Sep 17 00:00:00 2001 From: Karson Date: Mon, 24 Apr 2023 09:47:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B6=85=E7=BA=A7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=AE=A1=E7=90=86=E5=91=98=E6=97=A0=E6=B3=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=83=A8=E5=88=86=E6=97=A5=E5=BF=97=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/auth/Adminlog.php | 28 +++++++++++++------ public/assets/js/backend/auth/adminlog.js | 1 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/application/admin/controller/auth/Adminlog.php b/application/admin/controller/auth/Adminlog.php index c4895c11..9ed148ce 100644 --- a/application/admin/controller/auth/Adminlog.php +++ b/application/admin/controller/auth/Adminlog.php @@ -44,9 +44,15 @@ class Adminlog extends Backend $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $isSuperAdmin = $this->auth->isSuperAdmin(); + $childrenAdminIds = $this->childrenAdminIds; $list = $this->model ->where($where) - ->where('admin_id', 'in', $this->childrenAdminIds) + ->where(function ($query) use ($isSuperAdmin, $childrenAdminIds) { + if (!$isSuperAdmin) { + $query->where('admin_id', 'in', $childrenAdminIds); + } + }) ->order($sort, $order) ->paginate($limit); @@ -66,8 +72,10 @@ class Adminlog extends Backend if (!$row) { $this->error(__('No Results were found')); } - if (!$row['admin_id'] || !in_array($row['admin_id'], $this->childrenAdminIds)) { - $this->error(__('You have no permission')); + if (!$this->auth->isSuperAdmin()) { + if (!$row['admin_id'] || !in_array($row['admin_id'], $this->childrenAdminIds)) { + $this->error(__('You have no permission')); + } } $this->view->assign("row", $row->toArray()); return $this->view->fetch(); @@ -101,7 +109,15 @@ class Adminlog extends Backend } $ids = $ids ? $ids : $this->request->post("ids"); if ($ids) { - $adminList = $this->model->where('id', 'in', $ids)->where('admin_id', 'in', $this->childrenAdminIds)->select(); + $isSuperAdmin = $this->auth->isSuperAdmin(); + $childrenAdminIds = $this->childrenAdminIds; + $adminList = $this->model->where('id', 'in', $ids) + ->where(function ($query) use ($isSuperAdmin, $childrenAdminIds) { + if (!$isSuperAdmin) { + $query->where('admin_id', 'in', $childrenAdminIds); + } + }) + ->select(); if ($adminList) { $deleteIds = []; foreach ($adminList as $k => $v) { @@ -126,8 +142,4 @@ class Adminlog extends Backend $this->error(); } - public function selectpage() - { - return parent::selectpage(); - } } diff --git a/public/assets/js/backend/auth/adminlog.js b/public/assets/js/backend/auth/adminlog.js index 08765e3c..58586172 100644 --- a/public/assets/js/backend/auth/adminlog.js +++ b/public/assets/js/backend/auth/adminlog.js @@ -24,6 +24,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ {field: 'state', checkbox: true,}, {field: 'id', title: 'ID', operate: false}, + {field: 'admin_id', title: __('Admin_id'), formatter: Table.api.formatter.search, visible: false}, {field: 'username', title: __('Username'), formatter: Table.api.formatter.search}, {field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '模糊搜索'}, {field: 'url', title: __('Url'), formatter: Table.api.formatter.url},