fix(user): hide hidden problems
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-02-13 11:57:10 +08:00
parent 5055fb3777
commit 2787028069
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
3 changed files with 18 additions and 11 deletions

View File

@ -307,17 +307,17 @@ class HTML {
}
public static function link(?string $uri, $text, $cfg = []) {
$cfg += ['location' => 'main', 'escape' => true];
$cfg += ['location' => 'main', 'escape' => true, 'class' => ''];
if ($cfg['escape']) {
$text = HTML::escape($text);
}
if ($uri === null) {
return HTML::tag('a', [], $text);
return HTML::tag('a', ['class' => $cfg['class']], $text);
}
return HTML::tag('a', ['href' => HTML::url($uri, $cfg)], $text);
return HTML::tag('a', ['href' => HTML::url($uri, $cfg), 'class' => $cfg['class']], $text);
}
public static function autolink(string $url, array $attr = [], $cfg = []) {

View File

@ -367,7 +367,7 @@ class UOJProblem {
}
public function getLink(array $cfg = []) {
return HTML::link($this->getUri(), $this->getTitle($cfg), ['escape' => false]);
return HTML::link($this->getUri(), $this->getTitle($cfg), ['escape' => false, 'class' => $cfg['class'] ?: '']);
}
public function getAttachmentUri() {

View File

@ -252,17 +252,24 @@
</div>
<div class="card mb-2">
<div class="card-body">
<?php $ac_problems = DB::selectAll("select a.problem_id as problem_id, b.title as title from best_ac_submissions a inner join problems b on a.problem_id = b.id where submitter = '{$user['username']}' order by id") ?>
<?php $ac_problems = DB::selectAll("select problem_id from best_ac_submissions where submitter = '{$user['username']}' order by problem_id") ?>
<h4 class="card-title">
<?= UOJLocale::get('accepted problems') . ': ' . UOJLocale::get('n problems in total', count($ac_problems)) ?>
</h4>
<ul class="nav uoj-ac-problems-list">
<?php foreach ($ac_problems as $problem) : ?>
<?php foreach ($ac_problems as $prob) : ?>
<?php $problem = UOJProblem::query($prob['problem_id']) ?>
<?php if ($problem->userCanView(Auth::user())) : ?>
<li class="nav-item">
<a class="nav-link rounded uoj-ac-problems-list-item" href="/problem/<?= $problem['problem_id'] ?>" role="button">
#<?= $problem['problem_id'] ?>. <?= $problem['title'] ?>
<?= $problem->getLink(['with' => 'id', 'class' => 'nav-link rounded uoj-ac-problems-list-item']) ?>
</li>
<?php else : ?>
<li class="nav-item">
<a class="nav-link disabled rounded" role="button">
#<?= $problem->info['id'] ?>. 隐藏的题目
</a>
</li>
<?php endif ?>
<?php endforeach ?>
<?php if (empty($ac_problems)) : ?>