修复超级管理管理员无法显示部分日志的问题

pull/446/head
Karson 2023-04-24 09:47:07 +08:00
parent 03f46a637d
commit afe0fdce73
2 changed files with 21 additions and 8 deletions

View File

@ -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,9 +72,11 @@ class Adminlog extends Backend
if (!$row) {
$this->error(__('No Results were found'));
}
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();
}
}

View File

@ -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},