refactor(admin): clean up audit/permission/paid content config

- P1: remove the duplicate "审核联动" (ai_moderate_background/submit)
  block from the attachment permissions page; those settings live in
  the "评论审核" / API content audit surfaces.
- P2: rename the "内容审核" submenu to "评论审核" (permissions domain).
- P4: remove the "下载/付费内容中心" page and its schema/route chain;
  hardcode runtime policy so download always supports credit purchase
  and paid content is limited to posts. Drop the now-dead
  cms_features.download_credit flag and parse_slug_list helper.
This commit is contained in:
2026-08-13 01:14:21 +08:00
parent 2f4ce790a7
commit b4a4b295bc
16 changed files with 33 additions and 461 deletions
-1
View File
@@ -182,7 +182,6 @@ class GlobalController extends ControllerBase {
$params = $this->get_json_params($request);
$allowed = [
'resource_cpt_enabled' => 'bool',
'download_credit' => 'bool',
'search_include_resource' => 'bool',
];
$sanitized = $this->sanitize_fields($params, $allowed);
-43
View File
@@ -14,49 +14,6 @@ class SchemaPayment {
'domain' => 'payment',
'title' => '支付&付费',
'sections' => [
'paid' => [
'key' => 'paid',
'title' => '内容付费 / 下载',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'strategy', 'title' => '内容付费策略', 'fields' => [
['key' => 'payment_paid_post_types', 'label' => '受管内容类型', 'type' => 'input', 'default' => 'post'],
['key' => 'payment_vip_free_download', 'label' => 'VIP / 角色白名单免扣下载', 'type' => 'switch', 'default' => false],
['key' => 'payment_vip_exempt_roles', 'label' => '免扣角色列表', 'type' => 'input', 'default' => ''],
]],
['key' => 'delivery', 'title' => '交付说明', 'fields' => [
['key' => 'payment_paid_catalog_note', 'label' => '前台付费提示', 'type' => 'textarea', 'default' => ''],
['key' => 'payment_manual_delivery_note', 'label' => '人工交付备注', 'type' => 'textarea', 'default' => ''],
]],
['key' => 'display', 'title' => '展示设置', 'fields' => [
['key' => 'pay_mark', 'label' => '付费标记', 'type' => 'input', 'default' => '付费'],
['key' => 'payment_currency_symbol', 'label' => '货币符号', 'type' => 'input', 'default' => '¥'],
['key' => 'pay_show_user', 'label' => '显示购买用户', 'type' => 'switch', 'default' => true],
['key' => 'pay_show_paycount', 'label' => '显示购买次数', 'type' => 'switch', 'default' => true],
['key' => 'pay_box_position', 'label' => '付费框位置', 'type' => 'radio', 'default' => 'top', 'options' => [
['label' => '文章框顶部', 'value' => 'box_top'],
['label' => '正文顶部', 'value' => 'top'],
['label' => '正文底部', 'value' => 'bottom'],
['label' => '文章框底部', 'value' => 'box_bottom'],
]],
]],
['key' => 'download', 'title' => '下载能力', 'fields' => [
['key' => 'payment_download_enable', 'label' => '启用下载能力', 'type' => 'switch', 'default' => false],
['key' => 'payment_down_alone_page', 'label' => '独立下载页面', 'type' => 'switch', 'default' => false],
['key' => 'payment_download_remote_s', 'label' => '远程文件下载', 'type' => 'switch', 'default' => true],
['key' => 'payment_download_verify_nonce', 'label' => '下载鉴权', 'type' => 'switch', 'default' => true],
['key' => 'payment_download_user_log', 'label' => '用户下载记录条数', 'type' => 'number', 'default' => 50, 'min' => 0, 'max' => 9999],
['key' => 'payment_download_post_log', 'label' => '内容下载记录条数', 'type' => 'number', 'default' => 50, 'min' => 0, 'max' => 9999],
['key' => 'payment_download_remote_size', 'label' => '远程文件大小限制(KB)', 'type' => 'number', 'default' => 2048, 'min' => 1, 'max' => 999999],
['key' => 'payment_download_remote_ext', 'label' => '远程文件格式限制', 'type' => 'input', 'default' => 'zip,rar,7z'],
]],
['key' => 'coupon', 'title' => '内容优惠码', 'fields' => [
['key' => 'coupon_post_s', 'label' => '全站内容允许优惠码', 'type' => 'switch', 'default' => false],
['key' => 'coupon_desc', 'label' => '优惠码说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'coupon_post_s', 'value' => true]],
]],
],
],
'recharge' => [
'key' => 'recharge',
'title' => '余额充值',
+1 -1
View File
@@ -74,7 +74,7 @@ class SchemaPermissions {
],
'moderation' => [
'key' => 'moderation',
'title' => '内容审核',
'title' => '评论审核',
'version' => '1.0.0',
'option_key' => 'aksrt_moderation_config',
'groups' => [
-1
View File
@@ -137,7 +137,6 @@ class HomeCms {
public static function get_cms_features(): array {
$defaults = [
'resource_cpt_enabled' => true,
'download_credit' => true,
'search_include_resource' => true,
];
$s = Settings::get_all();
+21 -38
View File
@@ -16,9 +16,6 @@ class PaymentRuntime {
*/
public static function get_paid_content_settings(): array {
$settings = Settings::get_all();
$features = HomeCms::get_cms_features();
$catalog_note = trim((string) ($settings['payment_paid_catalog_note'] ?? ''));
$manual_note = trim((string) ($settings['payment_manual_delivery_note'] ?? ''));
$box_position = sanitize_key((string) ($settings['pay_box_position'] ?? 'top'));
// Zibll: box_top | top | bottom | box_bottom
@@ -27,35 +24,37 @@ class PaymentRuntime {
}
return [
'download_credit' => !empty($features['download_credit']) && Settings::credits_enabled(),
// 下载门槛永远支持积分购买模式(不再由页面开关控制)。
'download_credit' => Settings::credits_enabled(),
'default_cost' => Settings::download_default_cost(),
'paid_post_types' => self::parse_slug_list((string) ($settings['payment_paid_post_types'] ?? 'post'), ['post']),
'vip_free_download' => !empty($settings['payment_vip_free_download']),
'vip_exempt_roles' => self::parse_slug_list((string) ($settings['payment_vip_exempt_roles'] ?? '')),
'catalog_note' => $catalog_note,
'manual_delivery_note' => $manual_note !== '' ? $manual_note : __('付费或人工确认内容请在订单备注中记录交付方式。', 'aksrt'),
// 付费内容仅文章。
'paid_post_types' => ['post'],
'vip_free_download' => false,
'vip_exempt_roles' => [],
'catalog_note' => '',
'manual_delivery_note' => __('付费或人工确认内容请在订单备注中记录交付方式。', 'aksrt'),
'no_logged_in' => !isset($settings['pay_no_logged_in']) || !empty($settings['pay_no_logged_in']),
'down_alone_page' => !empty($settings['payment_down_alone_page']),
'down_alone_page' => false,
'display' => [
'mark' => sanitize_text_field((string) ($settings['pay_mark'] ?? '付费')),
'currency_symbol' => sanitize_text_field((string) ($settings['payment_currency_symbol'] ?? '¥')),
'currency_symbol' => '¥',
'show_user' => !isset($settings['pay_show_user']) || !empty($settings['pay_show_user']),
'show_paycount' => !isset($settings['pay_show_paycount']) || !empty($settings['pay_show_paycount']),
'box_position' => $box_position,
],
'download' => [
'enabled' => !empty($settings['payment_download_enable']),
'remote' => !isset($settings['payment_download_remote_s']) || !empty($settings['payment_download_remote_s']),
'verify_nonce' => !isset($settings['payment_download_verify_nonce']) || !empty($settings['payment_download_verify_nonce']),
'user_log' => max(0, min(9999, (int) ($settings['payment_download_user_log'] ?? 50))),
'post_log' => max(0, min(9999, (int) ($settings['payment_download_post_log'] ?? 50))),
'remote_size' => max(1, (int) ($settings['payment_download_remote_size'] ?? 2048)),
'remote_ext' => sanitize_text_field((string) ($settings['payment_download_remote_ext'] ?? 'zip,rar,7z')),
'alone_page' => !empty($settings['payment_down_alone_page']),
'enabled' => true,
'remote' => true,
'verify_nonce' => true,
'user_log' => 50,
'post_log' => 50,
'remote_size' => 2048,
'remote_ext' => 'zip,rar,7z',
'alone_page' => false,
],
// Content cashier coupon (zibll coupon_post_s / coupon_desc).
'coupon_post_s' => !empty($settings['coupon_post_s']),
'coupon_desc' => sanitize_textarea_field((string) ($settings['coupon_desc'] ?? '')),
// 内容收银台优惠码:不再提供全局开关,默认关闭。
'coupon_post_s' => false,
'coupon_desc' => '',
];
}
@@ -495,22 +494,6 @@ class PaymentRuntime {
return true;
}
/**
* @param string[] $fallback
* @return string[]
*/
private static function parse_slug_list(string $raw, array $fallback = []): array {
$items = preg_split('/[\s,]+/', $raw, -1, PREG_SPLIT_NO_EMPTY);
$normalized = [];
foreach ((array) $items as $item) {
$slug = sanitize_key((string) $item);
if ($slug !== '' && !in_array($slug, $normalized, true)) {
$normalized[] = $slug;
}
}
return !empty($normalized) ? $normalized : $fallback;
}
private static function count_structured_lines(string $raw): int {
$lines = preg_split('/[\r\n]+/', $raw, -1, PREG_SPLIT_NO_EMPTY);
$count = 0;