diff --git a/assets/admin/src/schema/sections/post-list/submit.js b/assets/admin/src/schema/sections/post-list/submit.js index 8efa4fe8..a8d2da3c 100644 --- a/assets/admin/src/schema/sections/post-list/submit.js +++ b/assets/admin/src/schema/sections/post-list/submit.js @@ -2,123 +2,85 @@ export const submitSchema = { key: 'post_list.submit', title: '前台投稿', icon: 'fa fas fa-paper-plane', - description: '配置前台投稿表单字段、审核流程、附件权限和封面策略。', + description: '配置前台投稿的开关、可选分类、免登录发布用户、标题与付费限制。', defaults: { - front_submit_enabled: true, - front_submit_roles: 'author,editor,administrator', - front_submit_title: true, - front_submit_content: true, - front_submit_excerpt: true, - front_submit_cover: true, - front_submit_category: true, - post_article_cat: [], - front_submit_tags: true, - post_article_custom_filter_s: true, - front_submit_custom_fields: '', - front_submit_review_mode: 'pending', - front_submit_cover_required: false, - front_submit_max_images: 5, - front_submit_editor_mode: 'rich', - front_submit_draft_save: true, - front_submit_leave_warning: true, - front_submit_guest_enabled: false, + post_article_s: true, post_article_btn_txte: '发布文章', - post_article_title_strlen_limit_min: 5, - post_article_title_strlen_limit_max: 30, - post_article_user: 0, + post_article_cat: [], + post_article_custom_filter_s: true, + post_article_tag: true, + post_article_user: 1, + post_article_title_strlen_limit: { min: 5, max: 30 }, post_article_pay_free_s: true, - post_article_pay_price_min: '0.00', - post_article_pay_price_max: '100.00', + post_article_pay_price_limit: { price: { min: 0, max: 99999 }, points: { min: 0, max: 0 } }, post_article_pay_vip_price_s: true, - post_article_pay_vip_1_discount: 80, - post_article_pay_vip_2_discount: 50, + post_article_pay_vip_1_discount: 100, + post_article_pay_vip_2_discount: 100, + post_t_placeholder: '请输入标题', + post_c_placeholder: '请输入内容', }, groups: [ { - key: 'basic', - title: '基础配置', - icon: 'fa fas fa-cog', - fields: [ - { key: 'front_submit_enabled', label: '开启前台投稿', type: 'switch', default: true, help: '允许用户在前台提交文章' }, - { key: 'front_submit_roles', label: '允许投稿的角色', type: 'input', default: 'author,editor,administrator', dependsOn: { key: 'front_submit_enabled', value: true }, help: '逗号分隔角色标识' }, - { key: 'post_article_btn_txte', label: '投稿按钮文案', type: 'input', default: '发布文章', dependsOn: { key: 'front_submit_enabled', value: true }, help: '前台投稿按钮显示的文字' }, - { key: 'post_article_title_strlen_limit_min', label: '标题最少字数', type: 'number', default: 5, min: 1, max: 100, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_article_title_strlen_limit_max', label: '标题最多字数', type: 'number', default: 30, min: 5, max: 200, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_t_placeholder', label: '标题占位符', type: 'input', default: '', placeholder: '请输入标题', dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_c_placeholder', label: '内容占位符', type: 'textarea', default: '', placeholder: '请输入内容', dependsOn: { key: 'front_submit_enabled', value: true } }, - ], - }, - { - key: 'fields', - title: '表单字段', - icon: 'fa fas fa-list-alt', - fields: [ - { key: 'front_submit_title', label: '标题', type: 'switch', default: true, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'front_submit_content', label: '正文', type: 'switch', default: true, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'front_submit_excerpt', label: '摘要', type: 'switch', default: true, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'front_submit_cover', label: '封面图', type: 'switch', default: true, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'front_submit_category', label: '分类选择', type: 'switch', default: true, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_article_cat', label: '允许投稿分类', type: 'taxonomy_select', taxonomy: 'category', multiple: true, default: [], help: '为空则允许全部分类', dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'front_submit_guest_enabled', label: '允许免登录投稿', type: 'switch', default: false, help: '开启后访客可投稿;文章归属到下方用户', dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_article_user', label: '免登录归属用户', type: 'user_select', default: 0, help: '免登录投稿时文章归属的用户,搜索选择', dependsOn: { key: 'front_submit_guest_enabled', value: true } }, - { key: 'front_submit_tags', label: '标签输入', type: 'switch', default: true, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_article_custom_filter_s', label: '高级筛选选择', type: 'switch', default: true, help: '投稿时可选择自定义筛选维度值', dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'front_submit_custom_fields', label: '自定义字段', type: 'textarea', default: '', placeholder: '每行一个:field_key|字段名称|类型(input/textarea/select)', dependsOn: { key: 'front_submit_enabled', value: true } }, - ], - }, - { - key: 'review', - title: '审核策略', - icon: 'fa fas fa-tasks', + key: 'submit', + title: '', fields: [ + { key: 'post_article_s', label: '启用前台投稿', type: 'switch', default: true }, { - key: 'front_submit_review_mode', - label: '审核模式', - type: 'radio', - default: 'pending', - options: [ - { label: '待审核', value: 'pending' }, - { label: '直接发布', value: 'publish' }, - { label: '自动草稿', value: 'draft' }, - ], - dependsOn: { key: 'front_submit_enabled', value: true }, + key: 'submit_perm_notice', + label: '', + type: 'content', + ui_only: true, + content: '
此功能启用后,可以在权限管理中设置用户的发布、审核权限 【去设置】
', }, - { key: 'front_submit_cover_required', label: '封面图必填', type: 'switch', default: false, dependsOn: { key: 'front_submit_cover', value: true } }, - { key: 'front_submit_max_images', label: '正文最大图片数', type: 'number', default: 5, min: 0, max: 50, dependsOn: { key: 'front_submit_enabled', value: true } }, - ], - }, - { - key: 'editor', - title: '编辑器设置', - icon: 'fa fas fa-edit', - fields: [ + { key: 'post_article_btn_txte', label: '按钮文字', type: 'input', default: '发布文章', dependsOn: { key: 'post_article_s', value: true }, description: '投稿按钮的显示的文字,推荐4个字更加协调' }, + { key: 'post_article_cat', label: '投稿允许选择的分类', type: 'taxonomy_select', taxonomy: 'category', multiple: true, default: [], placeholder: '输入关键词以搜索分类', dependsOn: { key: 'post_article_s', value: true }, description: '投稿允许选择的分类,为空则允许选择全部分类,所选分类下如果有子分类则会自动显示,如果选择了上级分类,则不要再选该分类下的子分类。注意:请确保所选分类包含子分类总数不要超过50个,否则可能会引起页面崩溃' }, + { key: 'post_article_custom_filter_s', label: '允许选择高级筛选', type: 'switch', default: true, dependsOn: { key: 'post_article_s', value: true } }, { - key: 'front_submit_editor_mode', - label: '编辑器模式', - type: 'radio', - default: 'rich', - options: [ - { label: '富文本', value: 'rich' }, - { label: 'Markdown', value: 'markdown' }, - { label: '纯文本', value: 'plain' }, - ], - dependsOn: { key: 'front_submit_content', value: true }, + key: 'submit_filter_notice', + label: '', + type: 'content', + ui_only: true, + content: '此功能启用后,请先在文章列表/高级筛选中添加高级筛选明细 【去设置】
', }, - { key: 'front_submit_draft_save', label: '自动保存草稿', type: 'switch', default: true, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'front_submit_leave_warning', label: '离开页面提醒', type: 'switch', default: true, dependsOn: { key: 'front_submit_enabled', value: true } }, - ], - }, - { - key: 'paid', - title: '付费投稿权限', - icon: 'fa fas fa-database', - fields: [ - { key: 'post_article_pay_free_s', label: '允许设置免费', type: 'switch', default: true, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_article_pay_price_min', label: '最低价格', type: 'input', sanitize_type: 'money_decimal', default: '0.00', min: 0, max: 9999, help: '投稿可设置的最低付费金额', dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_article_pay_price_max', label: '最高价格', type: 'input', sanitize_type: 'money_decimal', default: '100.00', min: 0, max: 9999, help: '投稿可设置的最高付费金额', dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_article_pay_vip_price_s', label: '允许设置会员价', type: 'switch', default: true, dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_article_pay_vip_1_discount', label: 'VIP1 折扣(%)', type: 'number', default: 80, min: 0, max: 100, help: 'VIP1 会员折扣百分比,80 即 8 折', dependsOn: { key: 'front_submit_enabled', value: true } }, - { key: 'post_article_pay_vip_2_discount', label: 'VIP2 折扣(%)', type: 'number', default: 50, min: 0, max: 100, help: 'VIP2 会员折扣百分比,50 即 5 折', dependsOn: { key: 'front_submit_enabled', value: true } }, + { key: 'post_article_tag', label: '允许插入标签', type: 'switch', default: true, dependsOn: { key: 'post_article_s', value: true }, description: '前台投稿时候允许设置文章标签' }, + { key: 'post_article_user', label: '免登陆投稿发布用户', type: 'user_select', default: 1, dependsOn: { key: 'post_article_s', value: true }, description: '当选择投稿权限为无需登录就能投稿时,投稿文章的用户' }, + { key: 'post_article_title_strlen_limit', label: '标题字数限制', type: 'between_number', default: { min: 5, max: 30 }, unit: '字', description: '限制标题字数可有效的防止灌水等无意义内容(英文字符按0.5个字计算)' }, + { key: 'post_article_pay_free_s', label: '允许设置为免费资源', type: 'switch', default: true, dependsOn: { key: 'post_article_s', value: true }, description: '付费内容金额允许设置为 0' }, + { + key: 'post_article_pay_price_limit', + label: '付费内容金额限制', + type: 'fieldset', + default: { price: { min: 0, max: 99999 }, points: { min: 0, max: 0 } }, + description: '限制用户允许设置的金额,防止金额过高不合理(填0为不限制)', + fields: [ + { key: 'price', label: '现金金额限制', type: 'between_number', default: { min: 0, max: 99999 } }, + { key: 'points', label: '积分金额限制', type: 'between_number', default: { min: 0, max: 0 } }, + ], + }, + { key: 'post_article_pay_vip_price_s', label: '付费内容允许设置会员价', type: 'switch', default: true, dependsOn: { key: 'post_article_s', value: true }, description: '前台投稿时对拥有设置付费内容权限的用户,是否开启设置会员价格。开启此项,会直接在前台显示设置会员价的选项;关闭此项,则用户只能设置普通价格,会员价则按照下方设置的折扣自动计算' }, + { + key: 'post_article_pay_vip_1_discount', + label: '一级会员折扣', + type: 'number', + default: 100, + min: 0, + max: 100, + unit: '%', + dependsOn: { all: [{ key: 'post_article_s', value: true }, { key: 'post_article_pay_vip_price_s', value: false }] }, + }, + { + key: 'post_article_pay_vip_2_discount', + label: '二级会员折扣', + type: 'number', + default: 100, + min: 0, + max: 100, + unit: '%', + dependsOn: { all: [{ key: 'post_article_s', value: true }, { key: 'post_article_pay_vip_price_s', value: false }] }, + description: '执行价的百分之多少,0为免费,100为没有折扣,不能高于100', + }, + { key: 'post_t_placeholder', label: '投稿标题占位符', type: 'input', default: '请输入标题' }, + { key: 'post_c_placeholder', label: '投稿内容占位符', type: 'input', default: '请输入内容' }, ], }, ], diff --git a/assets/js/front-submit.js b/assets/js/front-submit.js index 5ac808d2..24cd967f 100644 --- a/assets/js/front-submit.js +++ b/assets/js/front-submit.js @@ -131,9 +131,6 @@ bindLeaveWarning: function () { var self = this; - if (cfg.leaveWarning === false) { - return; - } window.addEventListener('beforeunload', function (e) { if (self.isDirty && !self.isSubmitting && !window.post_is_save) { e.preventDefault(); diff --git a/src/Admin/Schema/SchemaPostList.php b/src/Admin/Schema/SchemaPostList.php index b1fc57bb..c3a60c91 100644 --- a/src/Admin/Schema/SchemaPostList.php +++ b/src/Admin/Schema/SchemaPostList.php @@ -297,56 +297,27 @@ class SchemaPostList { 'submit' => [ 'key' => 'submit', 'title' => '前台投稿', - 'version' => '1.0.0', + 'version' => '2.0.0', 'option_key' => 'aksrt_settings', 'groups' => [ - ['key' => 'basic', 'title' => '基础配置', 'fields' => [ - ['key' => 'front_submit_enabled', 'label' => '开启前台投稿', 'type' => 'switch', 'default' => true], - ['key' => 'front_submit_roles', 'label' => '允许投稿的角色', 'type' => 'input', 'default' => 'author,editor,administrator'], - ['key' => 'post_article_btn_txte', 'label' => '投稿按钮文案', 'type' => 'input', 'default' => '发布文章'], - ['key' => 'post_article_title_strlen_limit_min', 'label' => '标题最少字数', 'type' => 'number', 'default' => 5, 'min' => 1, 'max' => 100], - ['key' => 'post_article_title_strlen_limit_max', 'label' => '标题最多字数', 'type' => 'number', 'default' => 30, 'min' => 5, 'max' => 200], - ['key' => 'post_t_placeholder', 'label' => '标题占位符', 'type' => 'input', 'default' => '', 'description' => '留空使用默认'], - ['key' => 'post_c_placeholder', 'label' => '内容占位符', 'type' => 'textarea', 'default' => '', 'description' => '留空使用默认'], - ]], - ['key' => 'fields', 'title' => '表单字段', 'fields' => [ - ['key' => 'front_submit_title', 'label' => '标题', 'type' => 'switch', 'default' => true], - ['key' => 'front_submit_content', 'label' => '正文', 'type' => 'switch', 'default' => true], - ['key' => 'front_submit_excerpt', 'label' => '摘要', 'type' => 'switch', 'default' => true], - ['key' => 'front_submit_cover', 'label' => '封面图', 'type' => 'switch', 'default' => true], - ['key' => 'front_submit_category', 'label' => '分类选择', 'type' => 'switch', 'default' => true], - ['key' => 'post_article_cat', 'label' => '允许投稿分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => [], 'help' => '为空则允许全部分类'], - ['key' => 'front_submit_guest_enabled', 'label' => '允许免登录投稿', 'type' => 'switch', 'default' => false, 'help' => '开启后访客可投稿;文章归属到下方用户'], - ['key' => 'post_article_user', 'label' => '免登录归属用户', 'type' => 'user_select', 'default' => 0, 'help' => '免登录投稿时文章归属的用户,搜索选择'], - ['key' => 'front_submit_tags', 'label' => '标签输入', 'type' => 'switch', 'default' => true], - ['key' => 'post_article_custom_filter_s', 'label' => '高级筛选选择', 'type' => 'switch', 'default' => true, 'help' => '投稿时可选择自定义筛选维度值'], - ['key' => 'front_submit_custom_fields', 'label' => '自定义字段', 'type' => 'textarea', 'default' => ''], - ]], - ['key' => 'review', 'title' => '审核策略', 'fields' => [ - ['key' => 'front_submit_review_mode', 'label' => '审核模式', 'type' => 'radio', 'default' => 'pending', 'options' => [ - ['label' => '待审核', 'value' => 'pending'], - ['label' => '直接发布', 'value' => 'publish'], - ['label' => '自动草稿', 'value' => 'draft'], + ['key' => 'submit', 'title' => '前台投稿', 'fields' => [ + ['key' => 'post_article_s', 'label' => '启用前台投稿', 'type' => 'switcher', 'default' => true, 'description' => '此功能启用后,可以在权限管理中设置用户的发布、审核权限'], + ['key' => 'post_article_btn_txte', 'label' => '按钮文字', 'type' => 'input', 'default' => '发布文章', 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '投稿按钮的显示的文字,推荐4个字更加协调'], + ['key' => 'post_article_cat', 'label' => '投稿允许选择的分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => [], 'placeholder' => '输入关键词以搜索分类', 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '投稿允许选择的分类,为空则允许选择全部分类,所选分类下如果有子分类则会自动显示,如果选择了上级分类,则不要再选该分类下的子分类。注意:请确保所选分类包含子分类总数不要超过50个,否则可能会引起页面崩溃'], + ['key' => 'post_article_custom_filter_s', 'label' => '允许选择高级筛选', 'type' => 'switcher', 'default' => true, 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '此功能启用后,请先在文章列表/高级筛选中添加高级筛选明细'], + ['key' => 'post_article_tag', 'label' => '允许插入标签', 'type' => 'switcher', 'default' => true, 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '前台投稿时候允许设置文章标签'], + ['key' => 'post_article_user', 'label' => '免登陆投稿发布用户', 'type' => 'user_select', 'default' => 1, 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '当选择投稿权限为无需登录就能投稿时,投稿文章的用户'], + ['key' => 'post_article_title_strlen_limit', 'label' => '标题字数限制', 'type' => 'between_number', 'default' => ['min' => 5, 'max' => 30], 'unit' => '字', 'description' => '限制标题字数可有效的防止灌水等无意义内容(英文字符按0.5个字计算)'], + ['key' => 'post_article_pay_free_s', 'label' => '允许设置为免费资源', 'type' => 'switcher', 'default' => true, 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '付费内容金额允许设置为 0'], + ['key' => 'post_article_pay_price_limit', 'label' => '付费内容金额限制', 'type' => 'fieldset', 'default' => ['price' => ['min' => 0, 'max' => 99999], 'points' => ['min' => 0, 'max' => 0]], 'description' => '限制用户允许设置的金额,防止金额过高不合理(填0为不限制)', 'fields' => [ + ['key' => 'price', 'label' => '现金金额限制', 'type' => 'between_number', 'default' => ['min' => 0, 'max' => 99999]], + ['key' => 'points', 'label' => '积分金额限制', 'type' => 'between_number', 'default' => ['min' => 0, 'max' => 0]], ]], - ['key' => 'front_submit_cover_required', 'label' => '封面图必填', 'type' => 'switch', 'default' => false], - ['key' => 'front_submit_max_images', 'label' => '正文最大图片数', 'type' => 'number', 'default' => 5, 'min' => 0, 'max' => 50], - ]], - ['key' => 'editor', 'title' => '编辑器设置', 'fields' => [ - ['key' => 'front_submit_editor_mode', 'label' => '编辑器模式', 'type' => 'radio', 'default' => 'rich', 'options' => [ - ['label' => '富文本', 'value' => 'rich'], - ['label' => 'Markdown', 'value' => 'markdown'], - ['label' => '纯文本', 'value' => 'plain'], - ]], - ['key' => 'front_submit_draft_save', 'label' => '自动保存草稿', 'type' => 'switch', 'default' => true], - ['key' => 'front_submit_leave_warning', 'label' => '离开页面提醒', 'type' => 'switch', 'default' => true], - ]], - ['key' => 'paid', 'title' => '付费投稿权限', 'fields' => [ - ['key' => 'post_article_pay_free_s', 'label' => '允许设置免费', 'type' => 'switch', 'default' => true], - ['key' => 'post_article_pay_price_min', 'label' => '最低价格', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '0.00', 'min' => 0, 'max' => 9999, 'help' => '投稿可设置的最低付费金额'], - ['key' => 'post_article_pay_price_max', 'label' => '最高价格', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '100.00', 'min' => 0, 'max' => 9999, 'help' => '投稿可设置的最高付费金额'], - ['key' => 'post_article_pay_vip_price_s', 'label' => '允许设置会员价', 'type' => 'switch', 'default' => true], - ['key' => 'post_article_pay_vip_1_discount', 'label' => 'VIP1 折扣(%)', 'type' => 'number', 'default' => 80, 'min' => 0, 'max' => 100, 'help' => 'VIP1 会员折扣百分比,80 即 8 折'], - ['key' => 'post_article_pay_vip_2_discount', 'label' => 'VIP2 折扣(%)', 'type' => 'number', 'default' => 50, 'min' => 0, 'max' => 100, 'help' => 'VIP2 会员折扣百分比,50 即 5 折'], + ['key' => 'post_article_pay_vip_price_s', 'label' => '付费内容允许设置会员价', 'type' => 'switcher', 'default' => true, 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '前台投稿时对拥有设置付费内容权限的用户,是否开启设置会员价格。开启此项,会直接在前台显示设置会员价的选项;关闭此项,则用户只能设置普通价格,会员价则按照下方设置的折扣自动计算'], + ['key' => 'post_article_pay_vip_1_discount', 'label' => '一级会员折扣', 'type' => 'number', 'default' => 100, 'min' => 0, 'max' => 100, 'unit' => '%', 'dependsOn' => ['all' => [['key' => 'post_article_s', 'value' => true], ['key' => 'post_article_pay_vip_price_s', 'value' => false]]]], + ['key' => 'post_article_pay_vip_2_discount', 'label' => '二级会员折扣', 'type' => 'number', 'default' => 100, 'min' => 0, 'max' => 100, 'unit' => '%', 'dependsOn' => ['all' => [['key' => 'post_article_s', 'value' => true], ['key' => 'post_article_pay_vip_price_s', 'value' => false]]], 'description' => '执行价的百分之多少,0为免费,100为没有折扣,不能高于100'], + ['key' => 'post_t_placeholder', 'label' => '投稿标题占位符', 'type' => 'input', 'default' => '请输入标题'], + ['key' => 'post_c_placeholder', 'label' => '投稿内容占位符', 'type' => 'input', 'default' => '请输入内容'], ]], ], ], diff --git a/src/Core/FrontSubmit.php b/src/Core/FrontSubmit.php index e0e11ab8..3e61f73d 100644 --- a/src/Core/FrontSubmit.php +++ b/src/Core/FrontSubmit.php @@ -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); } diff --git a/src/Core/FrontSubmitPay.php b/src/Core/FrontSubmitPay.php index 26adba81..f782ff35 100644 --- a/src/Core/FrontSubmitPay.php +++ b/src/Core/FrontSubmitPay.php @@ -73,8 +73,8 @@ trait FrontSubmitPay { if ($pay_modo === 'points') { $points = $this->parse_front_points($raw['points_price'] ?? $data['points_price'] ?? null); - $min = $this->parse_front_points_limit($settings['pay_price_min'] ?? '0.00'); - $max = $this->parse_front_points_limit($settings['pay_price_max'] ?? '0.00'); + $min = max(0, (int) ($settings['pay_points_min'] ?? 0)); + $max = max(0, (int) ($settings['pay_points_max'] ?? 0)); if ($points === null) { return ['success' => false, 'message' => __('请设置正确的积分价格', 'aksrt')]; } @@ -119,8 +119,10 @@ trait FrontSubmitPay { $meta['vip2_price'] = '0.00'; } else { $price_minor = $this->parse_front_cash_minor($raw['price'] ?? null); - $min_minor = $this->parse_front_cash_minor($settings['pay_price_min'] ?? '0') ?? 0; - $max_minor = $this->parse_front_cash_minor($settings['pay_price_max'] ?? '0') ?? 0; + $min_yuan = max(0, (int) ($settings['pay_price_min'] ?? 0)); + $max_yuan = max(0, (int) ($settings['pay_price_max'] ?? 0)); + $min_minor = $min_yuan > 0 ? \AKSRT\Ledger\AssetAmount::balance((string) $min_yuan)->minor() : 0; + $max_minor = $max_yuan > 0 ? \AKSRT\Ledger\AssetAmount::balance((string) $max_yuan)->minor() : 0; if ($price_minor === null) { return ['success' => false, 'message' => __('请设置正确的价格', 'aksrt')]; } @@ -199,13 +201,6 @@ trait FrontSubmitPay { } } - private function parse_front_points_limit($value): int { - if (!is_string($value) || !preg_match('/^(0|[1-9]\d*)(?:\.00)?$/', trim($value), $matches)) { - return 0; - } - return $this->parse_front_points((string) $matches[1]) ?? 0; - } - /** * @param array