mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 08:18:41 +00:00
feat(web/contests): upcoming contests view permission check
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8d87fda233
commit
ef01c326b2
@ -17,15 +17,15 @@ class UOJContest {
|
||||
return new UOJContest($info);
|
||||
}
|
||||
|
||||
public static function queryUpcomingContestIds(array $user = null, $limit = -1) {
|
||||
return array_map(fn ($x) => $x['id'], DB::selectAll([
|
||||
public static function queryUpcomingContests(array $user = null, $limit = -1) {
|
||||
return array_filter(array_map(fn ($x) => UOJContest::query($x['id']), DB::selectAll([
|
||||
"select id from contests",
|
||||
"where", [
|
||||
"status" => "unfinished",
|
||||
],
|
||||
"order by start_time asc, id asc",
|
||||
$limit == -1 ? "" : DB::limit($limit),
|
||||
]));
|
||||
])), fn ($contest) => $contest->userCanView($user));
|
||||
}
|
||||
|
||||
public static function userCanManageSomeContest(array $user = null) {
|
||||
|
@ -63,14 +63,13 @@ $parsedown = HTML::parsedown();
|
||||
|
||||
<?php if (Auth::check()) : ?>
|
||||
<?php if (!isset($upcoming_contests_hidden)) : ?>
|
||||
<?php $upcoming_contests = UOJContest::queryUpcomingContestIds(Auth::user(), 5); ?>
|
||||
<?php $upcoming_contests = UOJContest::queryUpcomingContests(Auth::user(), 5); ?>
|
||||
<div class="card card-default mb-2" id="group-user-announcements">
|
||||
<div class="card-header fw-bold bg-transparent">
|
||||
近期比赛
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<?php foreach ($upcoming_contests as $id) : ?>
|
||||
<?php $contest = UOJContest::query($id); ?>
|
||||
<?php foreach ($upcoming_contests as $contest) : ?>
|
||||
<?php if ($contest->info['cur_progress'] == CONTEST_NOT_STARTED || $contest->info['cur_progress'] == CONTEST_IN_PROGRESS) : ?>
|
||||
<li class="list-group-item text-center">
|
||||
<?= $contest->getLink(['class' => 'fw-bold']) ?>
|
||||
|
Loading…
Reference in New Issue
Block a user