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:
1 parent
c0e0912eee
commit
381256ed59
12 files changed
+191
-1236
No files matched your search
@@ -612,26 +612,48 @@ class SchemaUsers {
|
||||
'report' => [
|
||||
'key' => 'report',
|
||||
'title' => '禁封/举报',
|
||||
'version' => '1.0.0',
|
||||
'version' => '1.1.0',
|
||||
'option_key' => 'aksrt_settings',
|
||||
'groups' => [
|
||||
['key' => 'entry', 'title' => '前台入口', 'fields' => [
|
||||
['key' => 'user_report_enabled', 'label' => '启用举报/禁封结构', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'user_report_public_entry', 'label' => '公开主页展示举报入口', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'user_report_enabled', 'value' => true]],
|
||||
['key' => 'user_report_public_notice', 'label' => '公开显示限制提示', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'user_report_enabled', 'value' => true]],
|
||||
['key' => 'user_report_ban_notice_text', 'label' => '限制提示文案', 'type' => 'input', 'default' => '当前账号处于限制状态,部分互动能力已关闭。', 'dependsOn' => ['key' => 'user_report_enabled', 'value' => true]],
|
||||
]],
|
||||
['key' => 'taxonomy', 'title' => '举报分类', 'fields' => [
|
||||
['key' => 'user_report_categories', 'label' => '举报分类', 'type' => 'textarea', 'default' => "spam|垃圾信息\nabuse|人身攻击\ncopyright|版权投诉"],
|
||||
]],
|
||||
['key' => 'ban', 'title' => '禁封设置', 'fields' => [
|
||||
['key' => 'ban_preset_reason', 'label' => '预设封禁原因', 'type' => 'textarea', 'default' => "spam|垃圾信息\nabuse|人身攻击\nviolation|违规操作", 'dependsOn' => ['key' => 'user_report_enabled', 'value' => true]],
|
||||
['key' => 'ban_appeal_desc', 'label' => '申诉说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'user_report_enabled', 'value' => true]],
|
||||
['key' => 'ban_appeal_keys', 'label' => '申诉关键词', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'user_report_enabled', 'value' => true]],
|
||||
]],
|
||||
['key' => 'image', 'title' => '图片举报', 'fields' => [
|
||||
['key' => 'user_report_img_s', 'label' => '启用图片举报', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'user_report_enabled', 'value' => true]],
|
||||
['key' => 'user_report_desc', 'label' => '举报说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'user_report_enabled', 'value' => true]],
|
||||
// 字段集合、顺序、文案、默认值 1:1 对齐参考主题"用户&互动/禁封举报"
|
||||
['key' => 'main', 'title' => '', 'fields' => [
|
||||
['key' => 'user_ban_s', 'label' => '禁封功能', 'type' => 'switch', 'default' => true, 'help' => '启用后可以设置用户禁封,即小黑屋和封号的功能'],
|
||||
['key' => 'user_report_s', 'label' => '举报功能', 'type' => 'switch', 'default' => true, 'help' => '前台显示举报按钮,用户可以举报其它不良信息', 'dependsOn' => ['key' => 'user_ban_s', 'value' => true]],
|
||||
[
|
||||
'key' => 'ban_preset_reason',
|
||||
'label' => '预置原因',
|
||||
'type' => 'group',
|
||||
'button_title' => '添加原因',
|
||||
'help' => '举报/禁封的时候可选择的原因',
|
||||
'default' => [
|
||||
['t' => '发布色情、违法内容'],
|
||||
['t' => '存在欺诈骗钱行为'],
|
||||
['t' => '骚扰他人'],
|
||||
['t' => '涉嫌侵权'],
|
||||
['t' => '发布垃圾广告信息'],
|
||||
],
|
||||
'fields' => [
|
||||
['key' => 't', 'label' => '原因', 'type' => 'input', 'default' => ''],
|
||||
],
|
||||
],
|
||||
['key' => 'ban_appeal_desc', 'label' => '申诉说明', 'type' => 'textarea', 'rows' => 5, 'help' => '用户申诉时候显示的内容(支持HTML代码,请注意代码规范)', 'default' => "<div>为了良好的交流环境,申诉请阅读以下事项</div>\n<li>首次违规将拉入小黑屋7天</li>\n<li>3次违规后将直接禁封账号</li>\n<li>违规情节严重将无法提交申诉</li>\n<li>申诉提交后约2-3个工作日进行审核</li>\n<li>如有其它疑问请与客服联系</li>"],
|
||||
[
|
||||
'key' => 'ban_appeal_keys',
|
||||
'label' => '申诉所需资料',
|
||||
'type' => 'group',
|
||||
'button_title' => '添加申诉资料',
|
||||
'help' => '用户提交申诉时候需要提供的资料;此处的信息收集,仅用于记录和申诉审核',
|
||||
'default' => [
|
||||
['t' => '真实姓名'],
|
||||
['t' => '邮箱'],
|
||||
['t' => '手机号'],
|
||||
],
|
||||
'fields' => [
|
||||
['key' => 't', 'label' => '资料项', 'type' => 'input', 'default' => ''],
|
||||
],
|
||||
],
|
||||
['key' => 'user_report_img_s', 'label' => '举报可上传图片', 'type' => 'switch', 'default' => true, 'help' => '举报时允许上传图片进行举证(最多上传3张)', 'dependsOn' => ['key' => 'user_report_s', 'value' => true]],
|
||||
['key' => 'user_report_desc', 'label' => '举报说明', 'type' => 'textarea', 'rows' => 5, 'help' => '举报时候显示的内容(支持HTML代码,请注意代码规范)', 'dependsOn' => ['key' => 'user_report_s', 'value' => true], 'default' => "<div>举报说明:</div>\n<li>请确保举报的内容属实</li>\n<li>我们将会在收到举报后2个工作日内进行处理</li>\n<li>举报属实我们将根据社区管理条例对该用户进行封号处理</li>\n<li>如有其它疑问请与客服联系</li>"],
|
||||
]],
|
||||
],
|
||||
],
|
||||
|
||||
@@ -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'] ?? '')),
|
||||
|
||||
+10
-3
@@ -34,10 +34,17 @@ class BanAppeal {
|
||||
*/
|
||||
public static function settings(): array {
|
||||
$all = class_exists('\AKSRT\Settings\Settings') ? (array) \AKSRT\Settings\Settings::get_all() : [];
|
||||
$keys_raw = (string) ($all['ban_appeal_keys'] ?? '');
|
||||
$keys = array_values(array_filter(array_map('trim', preg_split('/[,,\n]/', $keys_raw) ?: [])));
|
||||
// 申诉资料:group 数组 [{t:...}](对齐参考主题)或旧版逗号分隔文本
|
||||
$keys_raw = $all['ban_appeal_keys'] ?? null;
|
||||
if (is_array($keys_raw)) {
|
||||
$keys = array_values(array_filter(array_map(static function ($row): string {
|
||||
return trim((string) ($row['t'] ?? ''));
|
||||
}, $keys_raw)));
|
||||
} else {
|
||||
$keys = array_values(array_filter(array_map('trim', preg_split('/[,,\n]/', (string) $keys_raw) ?: [])));
|
||||
}
|
||||
return [
|
||||
'enabled' => !isset($all['user_report_enabled']) || !empty($all['user_report_enabled']),
|
||||
'enabled' => (bool) ($all['user_report_s'] ?? (isset($all['user_report_enabled']) ? $all['user_report_enabled'] : true)),
|
||||
'desc' => (string) ($all['ban_appeal_desc'] ?? ''),
|
||||
'keys' => $keys,
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user