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 = []) { public static function link(?string $uri, $text, $cfg = []) {
$cfg += ['location' => 'main', 'escape' => true]; $cfg += ['location' => 'main', 'escape' => true, 'class' => ''];
if ($cfg['escape']) { if ($cfg['escape']) {
$text = HTML::escape($text); $text = HTML::escape($text);
} }
if ($uri === null) { 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 = []) { public static function autolink(string $url, array $attr = [], $cfg = []) {

View File

@ -367,7 +367,7 @@ class UOJProblem {
} }
public function getLink(array $cfg = []) { 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() { public function getAttachmentUri() {

View File

@ -252,17 +252,24 @@
</div> </div>
<div class="card mb-2"> <div class="card mb-2">
<div class="card-body"> <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"> <h4 class="card-title">
<?= UOJLocale::get('accepted problems') . ': ' . UOJLocale::get('n problems in total', count($ac_problems)) ?> <?= UOJLocale::get('accepted problems') . ': ' . UOJLocale::get('n problems in total', count($ac_problems)) ?>
</h4> </h4>
<ul class="nav uoj-ac-problems-list"> <ul class="nav uoj-ac-problems-list">
<?php foreach ($ac_problems as $problem) : ?> <?php foreach ($ac_problems as $prob) : ?>
<li class="nav-item"> <?php $problem = UOJProblem::query($prob['problem_id']) ?>
<a class="nav-link rounded uoj-ac-problems-list-item" href="/problem/<?= $problem['problem_id'] ?>" role="button"> <?php if ($problem->userCanView(Auth::user())) : ?>
#<?= $problem['problem_id'] ?>. <?= $problem['title'] ?> <li class="nav-item">
</a> <?= $problem->getLink(['with' => 'id', 'class' => 'nav-link rounded uoj-ac-problems-list-item']) ?>
</li> </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 endforeach ?>
<?php if (empty($ac_problems)) : ?> <?php if (empty($ac_problems)) : ?>