feat(admin): rebuild ban page to mirror the reference theme

- rename the users.php submenu to 举报&禁封申诉 and the page heading to
  用户禁封申诉及用户举报管理
- merge report tickets and ban appeals into one Zibll-style queue:
  type filter buttons (全部/禁封申诉/用户举报), status subsubsub
  (全部/待处理/已批准/已拒绝), search box, sortable widefat table with
  the same column set (状态/类型/提交用户/详情/提交时间/更新时间),
  inline process forms and 20-per-page pagination
- report process form shows the reported target, restriction status and
  an enforcement action select; appeal form offers approve/reject radios
  with a message to the user
- move restriction enforcement into ReportCenter::apply_action so REST
  and the native page share one implementation; add get_report_row()
- drop the old three-tab rendering (reports/appeals tabs) and fix all
  notice/mail/SPA links to the merged page
This commit is contained in:
kate522 committed 2026-09-19 22:00:17 +08:00
1 parent 3764d48755
commit 902e71ee62
8 files changed
+626 -217

No files matched your search

+81
View File
@@ -159,6 +159,87 @@ class ReportCenter {
return $result !== false;
}
/**
* 获取单条举报原始行(ARRAY_A),不存在返回 null。
*/
public function get_report_row(int $report_id): ?array {
$table = $this->table();
if ($table === '' || $report_id <= 0) {
return null;
}
global $wpdb;
$row = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$table} WHERE id = %d", $report_id), ARRAY_A);
return $row ?: null;
}
/**
* 对举报目标执行处罚动作(REST 与原生后台共用入口)。
*
* @param string $target_type 目标类型 post/comment/user
* @param int $target_id 目标 ID
* @param string $action_taken none/warn/mute/suspend/ban/clear/content_removed
* @param string $reason 处罚原因(写入限制记录)
* @return string 执行结果描述,未执行返回空串
*/
public function apply_action(string $target_type, int $target_id, string $action_taken, string $reason = ''): string {
if ($target_id <= 0 || $action_taken === 'none') {
return '';
}
if ($target_type === 'user') {
if (!class_exists('\AKSRT\User\Restriction')) {
return '';
}
$svc = \AKSRT\User\Restriction::get_instance();
if ($action_taken === 'clear') {
$removed = $svc->lift_user_restriction($target_id);
return $removed > 0
? sprintf(__('已解除 %d 条生效中的限制', 'aksrt'), $removed)
: __('该用户没有生效中的限制', 'aksrt');
}
if (in_array($action_taken, \AKSRT\User\Restriction::TYPES, true)) {
$labels = [
\AKSRT\User\Restriction::TYPE_WARN => __('警告', 'aksrt'),
\AKSRT\User\Restriction::TYPE_MUTE => __('禁言', 'aksrt'),
\AKSRT\User\Restriction::TYPE_SUSPEND => __('停权', 'aksrt'),
\AKSRT\User\Restriction::TYPE_BAN => __('封禁', 'aksrt'),
];
$result = $svc->restrict(
$target_id,
$action_taken,
$reason !== '' ? $reason : __('举报处理处罚', 'aksrt'),
\AKSRT\User\Restriction::SCOPE_GLOBAL,
'',
get_current_user_id()
);
if (!empty($result['success'])) {
return sprintf(__('已对用户执行限制:%s', 'aksrt'), $labels[$action_taken] ?? $action_taken);
}
return '';
}
return '';
}
if ($action_taken === 'content_removed' && $target_type === 'post' && get_post($target_id)) {
wp_update_post([
'ID' => $target_id,
'post_status' => 'pending',
]);
return __('已将内容改为待审状态', 'aksrt');
}
if ($action_taken === 'content_removed' && $target_type === 'comment' && get_comment($target_id)) {
wp_set_comment_status($target_id, 'hold', true);
return __('已将评论改为待审状态', 'aksrt');
}
return '';
}
/**
* Get status counts for the admin dashboard.
*