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:
2026-08-13 00:24:54 +08:00
parent 0b06b2c7df
commit 8241570ca2
67 changed files with 780 additions and 1127 deletions
+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; ?>