feat(users): govern profiles and access

Normalize fixed profile fields, profile actions, and the five-column capability matrix for comments, uploads, and downloads.
This commit is contained in:
2026-08-13 00:24:54 +08:00
parent 0b06b2c7df
commit 8241570ca2
67 changed files with 780 additions and 1127 deletions
+15 -8
View File
@@ -46,7 +46,7 @@ class PermissionsController extends ControllerBase {
'groups' => $this->build_capability_groups($defs, $caps, $columns),
'summary' => [
'cap_count' => count($defs),
'group_count' => 3,
'group_count' => 5,
'column_count' => count($columns),
],
],
@@ -114,6 +114,16 @@ class PermissionsController extends ControllerBase {
'title' => __('评论权限', 'aksrt'),
'items' => [],
],
'upload' => [
'key' => 'upload',
'title' => __('上传权限', 'aksrt'),
'items' => [],
],
'download' => [
'key' => 'download',
'title' => __('下载权限', 'aksrt'),
'items' => [],
],
];
foreach ($defs as $cap_id => $def) {
@@ -122,10 +132,13 @@ class PermissionsController extends ControllerBase {
$bucket_key = 'comment';
} elseif (str_starts_with($cap_id, 'new_post_')) {
$bucket_key = 'post';
} elseif (str_starts_with($cap_id, 'upload_')) {
$bucket_key = 'upload';
} elseif (str_starts_with($cap_id, 'resource_')) {
$bucket_key = 'download';
}
$excludes = $def['exclude_roles'] ?? [];
$only_roles = $def['roles'] ?? null;
$values = $caps[$cap_id] ?? [];
$visible_columns = [];
@@ -133,9 +146,6 @@ class PermissionsController extends ControllerBase {
if (in_array($column, $excludes, true)) {
continue;
}
if ($only_roles !== null && !in_array($column, $only_roles, true) && !in_array($column, ['all', 'logged', 'level', 'vip', 'auth'], true)) {
continue;
}
$visible_columns[] = $column;
}
@@ -157,9 +167,6 @@ class PermissionsController extends ControllerBase {
'level' => __('等级≥', 'aksrt'),
'vip' => __('VIP≥', 'aksrt'),
'auth' => __('已认证', 'aksrt'),
'moderator' => __('版主', 'aksrt'),
'plate_author' => __('超级版主', 'aksrt'),
'cat_moderator' => __('分区版主', 'aksrt'),
];
}
}