feat(admin): host the ban/report settings page in the SPA schema
The users-interaction sidebar entry 禁封/举报 was a redirect stub; it is
now a schema-driven settings page replicating the reference theme
field-for-field:
- user_ban_s / user_report_s switches, ban_preset_reason and
ban_appeal_keys as repeatable group rows ({t}), ban_appeal_desc and
user_report_desc HTML textareas with the reference default copy, and
user_report_img_s — keys, labels, help texts, defaults and ordering
all mirrored in SchemaUsers.php and the SPA report.js schema
- UserRuntime::ban_settings()/report_settings() and
BanAppeal::settings() read the new group-array values with fallback
to the previous line/comma formats
- delete the self-built SPA queue pages (UsersBan, UsersReport,
ReportDetailDrawer, UsersMessages) that the reference theme does not
have; legacy /users/report bookmarks still redirect to the native page
- contract tests: lock the schema keys/labels, the schemaPage mount and
the deleted-file state; drop reads of removed components
This commit is contained in:
@@ -173,7 +173,7 @@ class UserRuntime {
|
||||
}, $medal['items_by_slug'])),
|
||||
],
|
||||
'report' => [
|
||||
'enabled' => !empty($settings['user_report_enabled']),
|
||||
'enabled' => (bool) ($settings['user_report_s'] ?? $settings['user_report_enabled'] ?? false),
|
||||
'public_entry' => !isset($settings['user_report_public_entry']) || !empty($settings['user_report_public_entry']),
|
||||
'public_notice' => !isset($settings['user_report_public_notice']) || !empty($settings['user_report_public_notice']),
|
||||
'ban_notice_text' => $ban_notice_text !== '' ? $ban_notice_text : __('当前账号处于限制状态,部分互动能力已关闭。', 'aksrt'),
|
||||
@@ -200,21 +200,44 @@ class UserRuntime {
|
||||
*/
|
||||
public static function ban_settings(): array {
|
||||
$settings = Settings::get_all();
|
||||
$reasons_raw = (string) ($settings['ban_preset_reason'] ?? "spam|垃圾信息\nabuse|人身攻击\nviolation|违规操作");
|
||||
|
||||
// 预置原因:group 数组 [{t:...}](对齐参考主题)或旧版每行一条文本
|
||||
$reasons_raw = $settings['ban_preset_reason'] ?? null;
|
||||
$reasons = [];
|
||||
foreach (preg_split('/\r\n|\r|\n/', $reasons_raw) as $line) {
|
||||
$line = trim($line);
|
||||
if ($line === '') {
|
||||
continue;
|
||||
if (is_array($reasons_raw)) {
|
||||
foreach ($reasons_raw as $row) {
|
||||
$text = trim((string) ($row['t'] ?? ''));
|
||||
if ($text !== '') {
|
||||
$reasons[] = ['slug' => sanitize_key($text), 'name' => sanitize_text_field($text)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (preg_split('/\r\n|\r|\n/', (string) $reasons_raw) as $line) {
|
||||
$line = trim((string) $line);
|
||||
if ($line === '') {
|
||||
continue;
|
||||
}
|
||||
$parts = explode('|', $line, 2);
|
||||
$reasons[] = [
|
||||
'slug' => sanitize_key($parts[0]),
|
||||
'name' => sanitize_text_field($parts[1] ?? $parts[0]),
|
||||
];
|
||||
}
|
||||
$parts = explode('|', $line, 2);
|
||||
$reasons[] = [
|
||||
'slug' => sanitize_key($parts[0]),
|
||||
'name' => sanitize_text_field($parts[1] ?? $parts[0]),
|
||||
];
|
||||
}
|
||||
$appeal_keys_raw = (string) ($settings['ban_appeal_keys'] ?? '');
|
||||
$appeal_keys = array_filter(array_map('trim', explode(',', $appeal_keys_raw)));
|
||||
|
||||
// 申诉资料:group 数组 [{t:...}] 或旧版逗号分隔文本
|
||||
$keys_raw = $settings['ban_appeal_keys'] ?? null;
|
||||
$appeal_keys = [];
|
||||
if (is_array($keys_raw)) {
|
||||
foreach ($keys_raw as $row) {
|
||||
$text = trim((string) ($row['t'] ?? ''));
|
||||
if ($text !== '') {
|
||||
$appeal_keys[] = sanitize_text_field($text);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$appeal_keys = array_filter(array_map('trim', explode(',', (string) $keys_raw)));
|
||||
}
|
||||
|
||||
return [
|
||||
'reasons' => $reasons,
|
||||
@@ -229,9 +252,9 @@ class UserRuntime {
|
||||
public static function report_settings(): array {
|
||||
$settings = Settings::get_all();
|
||||
return [
|
||||
'enabled' => !empty($settings['user_report_enabled']),
|
||||
'public_entry' => !empty($settings['user_report_public_entry']),
|
||||
'public_notice' => !empty($settings['user_report_public_notice']),
|
||||
'enabled' => (bool) ($settings['user_report_s'] ?? $settings['user_report_enabled'] ?? false),
|
||||
'public_entry' => !isset($settings['user_report_public_entry']) || !empty($settings['user_report_public_entry']),
|
||||
'public_notice' => !isset($settings['user_report_public_notice']) || !empty($settings['user_report_public_notice']),
|
||||
'ban_notice_text' => sanitize_text_field((string) ($settings['user_report_ban_notice_text'] ?? '')),
|
||||
'img_enabled' => !empty($settings['user_report_img_s']),
|
||||
'desc' => wp_kses_post((string) ($settings['user_report_desc'] ?? '')),
|
||||
|
||||
Reference in New Issue
Block a user