fix: username color in system_msg
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-02-13 18:46:06 +08:00
parent 1612fa4adc
commit b7428e1c85
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
4 changed files with 12 additions and 8 deletions

View File

@ -35,8 +35,8 @@ if (UOJRequest::post('submit-remove_solution') === 'remove_solution') {
sendSystemMsg(
$blog->info['poster'],
'题解移除通知',
"<p>" . UOJUser::getLink($blog->info['poster']) . " 您好:</p>" .
"<p>您为问题 " . UOJProblem::cur()->getLink(['with' => 'id']) . " 提交的题解 " . $blog->getLink() . " 已被" . (isSuperUser(Auth::user()) ? "管理员" : " " . UOJUser::getLink(Auth::user()) . " ") . "移除。</p>"
"<p>" . UOJUser::getLink($blog->info['poster'], ['color' => false]) . " 您好:</p>" .
"<p>您为问题 " . UOJProblem::cur()->getLink(['with' => 'id']) . " 提交的题解 " . $blog->getLink() . " 已被管理员移除。</p>"
);
}

View File

@ -60,7 +60,7 @@ $comment_form->handle = function () {
$page = floor($rank / 20) + 1;
$uri = getLongTablePageUri($page) . '#' . "comment-{$comment_id}";
$user_link = UOJUser::getLink(Auth::user());
$user_link = UOJUser::getLink(Auth::user(), ['color' => false]);
foreach ($referrers as $referrer) {
$content = $user_link . ' 在博客 ' . $blog['title'] . ' 的评论里提到你:<a href="' . $uri . '">点击此处查看</a>';
@ -137,7 +137,7 @@ $reply_form->handle = function (&$vdata) {
$page = floor($rank / 20) + 1;
$uri = getLongTablePageUri($page) . '#' . "comment-{$reply_id}";
$user_link = UOJUser::getLink(Auth::user());
$user_link = UOJUser::getLink(Auth::user(), ['color' => false]);
foreach ($referrers as $referrer) {
$content = $user_link . ' 在博客 ' . $blog['title'] . ' 的评论里提到你:<a href="' . $uri . '">点击此处查看</a>';
@ -195,7 +195,7 @@ if (UOJUserBlog::userHasManagePermission(Auth::user())) {
sendSystemMsg(
$comment->info['poster'],
'评论隐藏通知',
"<p>" . UOJUser::getLink($comment->info['poster']) . " 您好:</p>" .
"<p>" . UOJUser::getLink($comment->info['poster'], ['color' => false]) . " 您好:</p>" .
"<p>您为博客 " . UOJBlog::cur()->getLink() . " 回复的评论 “" . substr($comment->info['content'], 0, 30) . "……” 已被管理员隐藏,隐藏原因为 “{$reason}”。</p>"
);
}

View File

@ -66,7 +66,7 @@ class UOJContest {
calcStandings($contest, $data, $score, $standings, ['update_contests_submissions' => true]);
for ($i = 0; $i < count($standings); $i++) {
$user_link = UOJUser::getLink($standings[$i][2][0]);
$user_link = UOJUser::getLink($standings[$i][2][0], ['color' => false]);
$tail = $standings[$i][0] == $total_score ? ',请继续保持。' : ',请继续努力!';
$content = '<p>' . $user_link . ' 您好:</p>';

View File

@ -247,7 +247,11 @@ class UOJUser {
return $custom_color ?: '#0d6efd';
}
public static function getLink($user) {
public static function getLink($user, $cfg = []) {
$cfg += [
'color' => true,
];
if (is_string($user)) {
$info = UOJUser::query($user);
@ -267,7 +271,7 @@ class UOJUser {
return HTML::tag('span', [
'class' => 'uoj-username',
'data-color' => UOJUser::getUserColor($user),
'data-color' => $cfg['color'] ? UOJUser::getUserColor($user) : '',
'data-realname' => trim(HTML::escape($realname)),
], $user['username']);
}