Explorar o código

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

Karson %!s(int64=2) %!d(string=hai) anos
pai
achega
ab7ebc3787

+ 20 - 8
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();
-    }
 }

+ 1 - 0
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},