fix(admin): replicate reference front-submit settings page 1:1

- Rewrite post_list/submit schema (PHP + JS) with the reference theme's
  field set, order, defaults and dependencies; topics fields excluded
- Map PostDisplay::get_submit_settings() and the FrontSubmit runtime to
  the new keys without legacy fallback
- Guest submission follows the capability matrix; category required on
  submit; pay limits read from the cash/points fieldset
- Drop dead front_submit_* settings, template branches and JS config
- Add submit settings reference contract test
This commit is contained in:
2026-09-24 12:29:19 +08:00
parent ed71314986
commit 264f2c51b2
14 changed files with 354 additions and 292 deletions
+12 -12
View File
@@ -227,29 +227,33 @@ class FrontSubmit {
}
return [
'enabled' => true,
'btn_text' => '发布文章',
'title_min' => 5,
'title_max' => 30,
'title_placeholder' => '请输入标题',
'content_placeholder' => '请输入内容',
'allowed_cat_ids' => [],
'default_user_id' => 0,
'guest_enabled' => false,
'allow_category' => true,
'default_user_id' => 1,
'allow_tags' => true,
'allow_cover' => true,
'custom_filter_s' => true,
'review_mode' => 'pending',
'pay_free_s' => true,
'pay_price_min' => 0,
'pay_price_max' => 100,
'pay_price_max' => 0,
'pay_points_min' => 0,
'pay_points_max' => 0,
'pay_vip_price_s' => true,
'pay_vip_1_enabled' => false,
'pay_vip_2_enabled' => false,
'pay_vip_1_discount' => 80,
'pay_vip_2_discount' => 50,
'pay_vip_1_discount' => 100,
'pay_vip_2_discount' => 100,
];
}
/**
* Whether the user (or guest) may open / create a submission.
*
* Guest submission is granted through the capability matrix ("all" column
* of new_post_add), mirroring the reference theme.
*/
public function can_submit(?int $user_id = null): bool {
$settings = $this->settings();
@@ -261,10 +265,6 @@ class FrontSubmit {
$user_id = get_current_user_id();
}
if ($user_id <= 0) {
return !empty($settings['guest_enabled']) && (int) ($settings['default_user_id'] ?? 0) > 0;
}
return $this->user_can_cap('new_post_add', $user_id);
}