优化管理员日志管理只显示当前组以及以下的数据
This commit is contained in:
@@ -21,7 +21,10 @@ class Admin extends Backend
|
||||
|
||||
protected array|string $quickSearchField = ['username', 'nickname'];
|
||||
|
||||
protected string|int|bool $dataLimit = 'allAuthAndOthers';
|
||||
/**
|
||||
* 开启数据范围;具体范围见重写的 getDataLimitAdminIds(角色组树:仅本人 + 下级组内管理员)
|
||||
*/
|
||||
protected bool|string|int $dataLimit = true;
|
||||
|
||||
protected string $dataLimitField = 'id';
|
||||
|
||||
@@ -31,6 +34,17 @@ class Admin extends Backend
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 非超管:仅可管理「本人 + 树形下级组内」的管理员账号;与角色组管理页的可见范围一致(列表不含仅同级的其他管理员)
|
||||
*/
|
||||
protected function getDataLimitAdminIds(): array
|
||||
{
|
||||
if (!$this->dataLimit || !$this->auth || $this->auth->isSuperAdmin()) {
|
||||
return [];
|
||||
}
|
||||
return $this->auth->getSelfAndSubordinateAdminIds();
|
||||
}
|
||||
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$response = $this->initializeBackend($request);
|
||||
@@ -357,9 +371,12 @@ class Admin extends Backend
|
||||
if ($this->auth->isSuperAdmin()) {
|
||||
return null;
|
||||
}
|
||||
$authGroups = $this->auth->getAllAuthGroups('allAuthAndOthers');
|
||||
$allowedGroupIds = array_values(array_unique(array_merge(
|
||||
Db::name('admin_group_access')->where('uid', $this->auth->id)->column('group_id'),
|
||||
$this->auth->getAdminChildGroups()
|
||||
)));
|
||||
foreach ($groups as $group) {
|
||||
if (!in_array($group, $authGroups)) {
|
||||
if (!in_array($group, $allowedGroupIds, false)) {
|
||||
return $this->error(__('You have no permission to add an administrator to this group!'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user