feat(users): govern profiles and access

Normalize fixed profile fields, profile actions, and the five-column capability matrix for comments, uploads, and downloads.
This commit is contained in:
kate522 committed 2026-08-13 00:24:54 +08:00
1 parent 0b06b2c7df
commit 8241570ca2
67 files changed
+780 -1127

No files matched your search

-8
View File
@@ -56,14 +56,6 @@ $need_vip = $gate_code === 'aksrt_need_vip';
$priced = function_exists('aksrt_get_user_pay_price') ? aksrt_get_user_pay_price($post) : null;
$price = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($pay_meta['price'] ?? 0);
$pay_modo = is_array($priced) ? ((($priced['modo'] ?? '0') === 'points') ? 'points' : '0') : ((($pay_meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0');
$order_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_order_settings() : [];
$free_logged_show = !empty($order_settings['free_logged_show']);
if ($price <= 0 && $free_logged_show && !is_user_logged_in()) {
$can_dl = false;
$need_login = true;
$has_access = true; // free "access" but must login to download
}
$currency = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt');
$cash_symbol = '¥';
if (class_exists('\AKSRT\Settings\Settings')) {
+1 -2
View File
@@ -60,8 +60,7 @@ if ($is_logged_in) {
}
$currency_name = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt');
$paid_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_paid_content_settings() : [];
$dl_requires_login = !empty($paid_settings['download_login']);
$dl_requires_login = function_exists('aksrt_user_can') && !aksrt_user_can('resource_download', get_current_user_id());
?>
<main id="main-content" class="site-main container" tabindex="-1">
+13 -3
View File
@@ -68,9 +68,9 @@ if (file_exists($js)) {
true
);
}
if (!empty($ctx['can_upload_img']) || !empty($ctx['can_cover_image']) || !empty($ctx['can_cover_slide'])) {
wp_enqueue_media();
}
$attachment_settings = class_exists('\\AKSRT\\Settings\\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
$submit_image_max_size = max(1, min(20, (int) ($attachment_settings['submit_image_max_size'] ?? 5))) * MB_IN_BYTES;
$resource_max_size = max(1, min(200, (int) ($attachment_settings['resource_max_size'] ?? 50))) * MB_IN_BYTES;
wp_localize_script('aksrt-front-submit', 'aksrtSubmitData', [
'ajaxUrl' => admin_url('admin-ajax.php'),
@@ -83,6 +83,16 @@ if (file_exists($js)) {
'summary' => !empty($ctx['ai_available']),
'tags' => !empty($ctx['ai_available']),
],
'uploads' => [
'image' => !empty($ctx['can_upload_img']) ? [
'url' => esc_url_raw(rest_url('aksrt/v1/front-submit/upload/image')),
'maxSize' => $submit_image_max_size,
] : null,
'resource' => !empty($ctx['can_upload_file']) ? [
'url' => esc_url_raw(rest_url('aksrt/v1/front-submit/upload/resource')),
'maxSize' => $resource_max_size,
] : null,
],
'i18n' => [
'confirmLeave' => __('你有未保存的更改,确定要离开吗?', 'aksrt'),
'saving' => __('保存中...', 'aksrt'),
+2 -11
View File
@@ -43,7 +43,7 @@ $gate_data = $gate_blocked ? (array) $gate->get_error_data() : [];
$paid_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_paid_content_settings()
: ['download_credit' => true, 'download_captcha' => false];
: ['download_credit' => true];
$access = class_exists('\AKSRT\Content\Visibility')
? \AKSRT\Content\Visibility::get_post_access_state($post_id)
@@ -56,10 +56,7 @@ $pay_modo = is_array($priced)
$user_amount = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($meta['price'] ?? 0);
$cost = function_exists('aksrt_resource_download_cost') ? (int) aksrt_resource_download_cost($post_id) : 0;
$captcha_active = !empty($paid_settings['download_captcha']) || !empty($meta['require_captcha']);
if ($captcha_active && function_exists('aksrt_is_captcha_enabled_for') && !aksrt_is_captcha_enabled_for('download')) {
$captcha_active = false;
}
$captcha_active = function_exists('aksrt_is_captcha_enabled_for') && aksrt_is_captcha_enabled_for('download');
$balance = (int) ($gate_data['balance'] ?? (is_user_logged_in() && class_exists('\AKSRT\Credits\Credits') ? \AKSRT\Credits\Credits::balance(get_current_user_id()) : 0));
$login_url = (string) ($gate_data['login_url'] ?? wp_login_url(get_permalink($post_id)));
$vip_url = function_exists('aksrt_get_user_center_tab_url')
@@ -84,13 +81,7 @@ if ($is_need_login && $allow_guest_buy) {
$gate_blocked = true;
}
// Zibll pay_free_logged_show: free downloads still require login.
$free_logged_show = !empty($paid_settings['free_logged_show']);
$price_amount = (float) ($price_label['amount'] ?? $user_amount);
if ($price_amount <= 0 && $free_logged_show && !is_user_logged_in()) {
$is_need_login = true;
$gate_blocked = true;
}
// Zibll down_alone_page: single entry to independent download page.
$alone_page = !empty($paid_settings['down_alone_page']) || !empty($paid_settings['download']['alone_page']);
+2 -2
View File
@@ -213,9 +213,9 @@ return [
'can_cover_image' => $cap('new_post_image_cover'),
'can_cover_slide' => $cap('new_post_slide_cover'),
'can_cover_video' => $cap('new_post_video_cover'),
'can_upload_img' => $cap('new_post_upload_img'),
'can_upload_img' => $cap('upload_submit_image'),
'can_upload_video' => $cap('new_post_upload_video'),
'can_upload_file' => $cap('new_post_upload_file'),
'can_upload_file' => $cap('upload_resource_attachment'),
'can_hide' => $cap('new_post_hide'),
'can_iframe' => $cap('new_post_iframe_video'),
];
+7 -5
View File
@@ -44,14 +44,11 @@ $is_can_new = !empty($ctx['is_can_new']);
<?php
$toolbar1 = 'formatselect,bold,italic,bullist,numlist,alignleft,aligncenter,alignright,link,blockquote,code,fullscreen';
$plugins = 'paste,link,lists,fullscreen,wordpress,wplink,charmap';
if (!empty($ctx['can_upload_img']) || !empty($ctx['can_upload_video']) || !empty($ctx['can_upload_file'])) {
// media_buttons handle uploads; keep toolbar clean.
}
$editor_settings = [
'textarea_name' => 'post_content',
'textarea_rows' => 20,
'editor_height' => wp_is_mobile() ? 460 : 470,
'media_buttons' => !empty($ctx['can_upload_img']) || !empty($ctx['can_upload_video']) || !empty($ctx['can_upload_file']),
'media_buttons' => false,
'default_editor' => 'tinymce',
'quicktags' => false,
'teeny' => false,
@@ -66,8 +63,13 @@ $is_can_new = !empty($ctx['is_can_new']);
?>
</div>
<?php if (!empty($ctx['can_hide']) || !empty($ctx['can_pay'])) : ?>
<?php if (!empty($ctx['can_hide']) || !empty($ctx['can_pay']) || !empty($ctx['can_upload_img'])) : ?>
<div class="aksrt-submit-shortcode-tools">
<?php if (!empty($ctx['can_upload_img'])) : ?>
<button type="button" class="but" data-insert-upload-image>
<i class="fas fa-image"></i> <?php esc_html_e('上传图片', 'aksrt'); ?>
</button>
<?php endif; ?>
<?php if (!empty($ctx['can_hide'])) : ?>
<button type="button" class="but" data-insert-shortcode="hide" title="<?php esc_attr_e('插入登录后可见', 'aksrt'); ?>">
<i class="fas fa-eye-slash"></i> <?php esc_html_e('登录可见', 'aksrt'); ?>
+14 -7
View File
@@ -117,9 +117,16 @@ $downloads = is_array($pay['downloads'] ?? null) ? $pay['downloads'] : [];
<div class="aksrt-submit-pay-downloads" data-pay-downloads>
<div class="aksrt-submit-pay__row">
<strong><?php esc_html_e('付费下载', 'aksrt'); ?></strong>
<button type="button" class="but hollow c-blue" data-pay-download-add>
<i class="fas fa-plus"></i> <?php esc_html_e('添加资源', 'aksrt'); ?>
</button>
<span>
<button type="button" class="but hollow c-blue" data-pay-download-add>
<i class="fas fa-plus"></i> <?php esc_html_e('添加资源', 'aksrt'); ?>
</button>
<?php if (!empty($ctx['can_upload_file'])) : ?>
<button type="button" class="but hollow" data-pay-download-upload>
<i class="fas fa-upload"></i> <?php esc_html_e('上传附件', 'aksrt'); ?>
</button>
<?php endif; ?>
</span>
</div>
<div class="aksrt-submit-pay-downloads__list" data-pay-download-list>
<?php foreach ($downloads as $i => $row) :
@@ -128,8 +135,8 @@ $downloads = is_array($pay['downloads'] ?? null) ? $pay['downloads'] : [];
$code = (string) ($row['extract_code'] ?? '');
?>
<div class="aksrt-submit-pay-downloads__item" data-pay-download-item>
<input type="url" class="aksrt-form-input" name="aksrt_pay[downloads][<?php echo (int) $i; ?>][url]" value="<?php echo esc_attr($url); ?>" placeholder="<?php esc_attr_e('资源链接', 'aksrt'); ?>">
<input type="text" class="aksrt-form-input" name="aksrt_pay[downloads][<?php echo (int) $i; ?>][label]" value="<?php echo esc_attr($label); ?>" placeholder="<?php esc_attr_e('名称', 'aksrt'); ?>">
<input type="url" class="aksrt-form-input" data-pay-download-url name="aksrt_pay[downloads][<?php echo (int) $i; ?>][url]" value="<?php echo esc_attr($url); ?>" placeholder="<?php esc_attr_e('资源链接', 'aksrt'); ?>">
<input type="text" class="aksrt-form-input" data-pay-download-label name="aksrt_pay[downloads][<?php echo (int) $i; ?>][label]" value="<?php echo esc_attr($label); ?>" placeholder="<?php esc_attr_e('名称', 'aksrt'); ?>">
<input type="text" class="aksrt-form-input" name="aksrt_pay[downloads][<?php echo (int) $i; ?>][extract_code]" value="<?php echo esc_attr($code); ?>" placeholder="<?php esc_attr_e('提取码/备注', 'aksrt'); ?>">
<button type="button" class="but c-red cir" data-pay-download-remove title="<?php esc_attr_e('删除', 'aksrt'); ?>"><i class="fas fa-trash"></i></button>
</div>
@@ -137,8 +144,8 @@ $downloads = is_array($pay['downloads'] ?? null) ? $pay['downloads'] : [];
</div>
<template data-pay-download-tpl>
<div class="aksrt-submit-pay-downloads__item" data-pay-download-item>
<input type="url" class="aksrt-form-input" data-name="url" placeholder="<?php esc_attr_e('资源链接', 'aksrt'); ?>">
<input type="text" class="aksrt-form-input" data-name="label" placeholder="<?php esc_attr_e('名称', 'aksrt'); ?>">
<input type="url" class="aksrt-form-input" data-name="url" data-pay-download-url placeholder="<?php esc_attr_e('资源链接', 'aksrt'); ?>">
<input type="text" class="aksrt-form-input" data-name="label" data-pay-download-label placeholder="<?php esc_attr_e('名称', 'aksrt'); ?>">
<input type="text" class="aksrt-form-input" data-name="extract_code" placeholder="<?php esc_attr_e('提取码/备注', 'aksrt'); ?>">
<button type="button" class="but c-red cir" data-pay-download-remove title="<?php esc_attr_e('删除', 'aksrt'); ?>"><i class="fas fa-trash"></i></button>
</div>
+33 -22
View File
@@ -35,11 +35,12 @@ $show_follow = !array_key_exists('follow', $settings) || !empty($settings['follo
$show_avatar = !array_key_exists('avatar', $settings) || !empty($settings['avatar']);
$show_name = !array_key_exists('name', $settings) || !empty($settings['name']);
$show_desc = !array_key_exists('desc', $settings) || !empty($settings['desc']);
$show_social = !array_key_exists('social', $settings) || !empty($settings['social']);
$show_message = !array_key_exists('message', $settings) || !empty($settings['message']);
$contacts = $dashboard['user_contacts'] ?? [];
$social_on = !empty($dashboard['social_links_on']);
$profile_details = is_array($dashboard['profile_details'] ?? null) ? $dashboard['profile_details'] : [];
// Gender is rendered inside the dialog but never creates a standalone menu
// action: without visible social details there is no "更多资料" item.
$has_more_details = !empty($profile_details['website']) || !empty($profile_details['qq']) || !empty($profile_details['wechat']) || !empty($profile_details['github']);
$signals = $dashboard['profile_signals'] ?? [];
$notice = $dashboard['profile_notice'] ?? null;
$show_report = !empty($dashboard['show_report']);
@@ -73,6 +74,18 @@ $pm_url = ($pm_enabled && $messages_url !== '')
</span>
</div>
<?php endif; ?>
<?php if ($has_more_details || ($show_report && !$is_own)) : ?>
<div class="aksrt-cover-menu aksrt-cover-menu--author" data-aksrt-menu>
<button type="button" class="aksrt-cover-menu__trigger" aria-haspopup="true" aria-expanded="false" aria-label="<?php esc_attr_e('个人主页操作', 'aksrt'); ?>"><i class="fas fa-ellipsis-h" aria-hidden="true"></i></button>
<div class="aksrt-cover-menu__panel" role="menu" hidden>
<?php if ($has_more_details) : ?><button type="button" role="menuitem" data-aksrt-profile-details><i class="fas fa-address-card" aria-hidden="true"></i><?php esc_html_e('更多资料', 'aksrt'); ?></button><?php endif; ?>
<?php if ($show_report && !$is_own) : ?>
<?php if (is_user_logged_in()) : ?><button type="button" role="menuitem" data-aksrt-report='{"target_type":"user","target_id":<?php echo (int) $user_id; ?>}'><i class="far fa-flag" aria-hidden="true"></i><?php esc_html_e('举报用户', 'aksrt'); ?></button>
<?php else : ?><a role="menuitem" href="<?php echo esc_url(aksrt_get_login_url($home_url)); ?>"><i class="far fa-flag" aria-hidden="true"></i><?php esc_html_e('举报用户', 'aksrt'); ?></a><?php endif; ?>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
@@ -125,13 +138,6 @@ $pm_url = ($pm_enabled && $messages_url !== '')
</div>
<?php endif; ?>
<?php if ($show_social && !empty($contacts) && $social_on) : ?>
<div class="aksrt-author-hero__contacts">
<?php if (function_exists('aksrt_render_social_links')) : ?>
<?php aksrt_render_social_links($contacts); ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div class="aksrt-author-hero__actions">
@@ -176,19 +182,24 @@ $pm_url = ($pm_enabled && $messages_url !== '')
<?php endif; ?>
<?php endif; ?>
<?php if ($show_report) : ?>
<?php if (is_user_logged_in()) : ?>
<button type="button" class="btn-ghost btn-sm aksrt-author-hero__report-btn" data-aksrt-report='{"target_type":"user","target_id":<?php echo (int) $user_id; ?>}' title="<?php esc_attr_e('举报该用户', 'aksrt'); ?>">
<i class="far fa-flag" aria-hidden="true"></i>
</button>
<?php else : ?>
<a href="<?php echo esc_url(aksrt_get_login_url($home_url)); ?>" class="btn-ghost btn-sm aksrt-author-hero__report-btn">
<i class="far fa-flag" aria-hidden="true"></i>
</a>
<?php endif; ?>
<?php endif; ?>
<?php if ($is_author && function_exists('aksrt_render_admin_quick_link')) { aksrt_render_admin_quick_link('page-display/user-home', __('用户主页设置', 'aksrt')); } ?>
</div>
</div>
</div>
<?php if ($has_more_details) : ?>
<div class="aksrt-profile-details-modal" id="aksrt-profile-details-modal" hidden role="dialog" aria-modal="true" aria-labelledby="aksrt-profile-details-title">
<div class="aksrt-profile-details-modal__backdrop" data-aksrt-modal-close></div>
<div class="aksrt-profile-details-modal__dialog" tabindex="-1">
<button type="button" class="aksrt-profile-details-modal__close" data-aksrt-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>">&times;</button>
<h2 id="aksrt-profile-details-title"><?php esc_html_e('更多资料', 'aksrt'); ?></h2>
<dl>
<?php if (!empty($profile_details['gender'])) : ?><div><dt><?php esc_html_e('性别', 'aksrt'); ?></dt><dd><?php echo esc_html($profile_details['gender'] === 'male' ? __('男', 'aksrt') : __('女', 'aksrt')); ?></dd></div><?php endif; ?>
<?php if (!empty($profile_details['website'])) : ?><div><dt><?php esc_html_e('个人网站', 'aksrt'); ?></dt><dd><a href="<?php echo esc_url($profile_details['website']); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html($profile_details['website']); ?></a></dd></div><?php endif; ?>
<?php if (!empty($profile_details['github'])) : ?><div><dt>GitHub</dt><dd><a href="<?php echo esc_url($profile_details['github']); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html($profile_details['github']); ?></a></dd></div><?php endif; ?>
<?php if (!empty($profile_details['qq'])) : ?><div><dt>QQ</dt><dd><?php echo esc_html($profile_details['qq']); ?></dd></div><?php endif; ?>
<?php if (!empty($profile_details['wechat'])) : ?><div><dt><?php esc_html_e('微信', 'aksrt'); ?></dt><dd><?php echo esc_html($profile_details['wechat']); ?></dd></div><?php endif; ?>
</dl>
</div>
</div>
<?php endif; ?>