feat(users): enforce real bans from report processing and fix appeal lifting
- apply_report_action now writes aksrt_user_restriction via Restriction::restrict
and lifts via new lift_user_restriction(), replacing the display-only
aksrt_user_ban_state meta dual-track
- ban type restrictions destroy the target user's sessions on apply
- appeal approval lifts active ban/suspend/mute restrictions instead of
updating a nonexistent status column
- UsersBan.vue posts to /users/{id}/restrict with valid types (warn/mute/
suspend/ban), scope and expires_at
- add comment report entry to the comment actions dropdown
- add duplicate pending report guard on submit
- remove dead ReportCenter ajax handlers, option migration, REST alias
routes and write-only restriction meta
- fix report admin mail link to the real aksrt_user_ban page
- add report-ban contract tests
This commit is contained in:
1 parent
4dafe96c4b
commit
835e0f983d
12 files changed
+291
-214
No files matched your search
@@ -143,6 +143,36 @@ if (!function_exists('aksrt_get_comment_header_html')) :
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_comment_report_html')) :
|
||||
/**
|
||||
* 评论举报入口 — 登录用户可举报他人评论(前台走 report.js 的 data-aksrt-report 契约)。
|
||||
*
|
||||
* @param WP_Comment $comment Comment.
|
||||
* @return string
|
||||
*/
|
||||
function aksrt_get_comment_report_html(WP_Comment $comment): string {
|
||||
if (!is_user_logged_in() || !class_exists('\AKSRT\Settings\Settings')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$author_id = (int) $comment->user_id;
|
||||
$reporter_id = get_current_user_id();
|
||||
if ($author_id > 0 && $author_id === $reporter_id) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$settings = \AKSRT\Settings\Settings::get_user_identity_settings();
|
||||
if (empty($settings['report']['enabled'])) {
|
||||
return '';
|
||||
}
|
||||
if (function_exists('aksrt_user_can') && !aksrt_user_can('user_report', $reporter_id, $author_id)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '<li><a class="comment-report-link" href="javascript:;" data-aksrt-report=\'{"target_type":"comment","target_id":' . (int) $comment->comment_ID . '}\'><i class="fa fas fa-flag mr10 fa-fw" aria-hidden="true"></i><text>' . esc_html__('举报', 'aksrt') . '</text></a></li>';
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_comments_action_dropdown_html')) :
|
||||
/**
|
||||
* More-actions menu (legacy: legacy) — pin / edit / approve / delete.
|
||||
@@ -178,6 +208,7 @@ if (!function_exists('aksrt_get_comments_action_dropdown_html')) :
|
||||
if (!empty($perms['can_delete'])) {
|
||||
$lists .= '<li><a class="comment-trash-link c-red" data-comment-action="delete" data-commentid="' . (int) $comment->comment_ID . '" data-postid="' . (int) $comment->comment_post_ID . '" href="javascript:;"><i class="fa far fa-trash-alt mr10 fa-fw" aria-hidden="true"></i>' . esc_html__('删除', 'aksrt') . '</a></li>';
|
||||
}
|
||||
$lists .= aksrt_get_comment_report_html($comment);
|
||||
|
||||
if ($lists === '') {
|
||||
return '';
|
||||
|
||||
Reference in new issue
Block a user