mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 14:08:42 +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);
|
return new UOJContest($info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function queryUpcomingContestIds(array $user = null, $limit = -1) {
|
public static function queryUpcomingContests(array $user = null, $limit = -1) {
|
||||||
return array_map(fn ($x) => $x['id'], DB::selectAll([
|
return array_filter(array_map(fn ($x) => UOJContest::query($x['id']), DB::selectAll([
|
||||||
"select id from contests",
|
"select id from contests",
|
||||||
"where", [
|
"where", [
|
||||||
"status" => "unfinished",
|
"status" => "unfinished",
|
||||||
],
|
],
|
||||||
"order by start_time asc, id asc",
|
"order by start_time asc, id asc",
|
||||||
$limit == -1 ? "" : DB::limit($limit),
|
$limit == -1 ? "" : DB::limit($limit),
|
||||||
]));
|
])), fn ($contest) => $contest->userCanView($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function userCanManageSomeContest(array $user = null) {
|
public static function userCanManageSomeContest(array $user = null) {
|
||||||
|
@ -63,14 +63,13 @@ $parsedown = HTML::parsedown();
|
|||||||
|
|
||||||
<?php if (Auth::check()) : ?>
|
<?php if (Auth::check()) : ?>
|
||||||
<?php if (!isset($upcoming_contests_hidden)) : ?>
|
<?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 card-default mb-2" id="group-user-announcements">
|
||||||
<div class="card-header fw-bold bg-transparent">
|
<div class="card-header fw-bold bg-transparent">
|
||||||
近期比赛
|
近期比赛
|
||||||
</div>
|
</div>
|
||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
<?php foreach ($upcoming_contests as $id) : ?>
|
<?php foreach ($upcoming_contests as $contest) : ?>
|
||||||
<?php $contest = UOJContest::query($id); ?>
|
|
||||||
<?php if ($contest->info['cur_progress'] == CONTEST_NOT_STARTED || $contest->info['cur_progress'] == CONTEST_IN_PROGRESS) : ?>
|
<?php if ($contest->info['cur_progress'] == CONTEST_NOT_STARTED || $contest->info['cur_progress'] == CONTEST_IN_PROGRESS) : ?>
|
||||||
<li class="list-group-item text-center">
|
<li class="list-group-item text-center">
|
||||||
<?= $contest->getLink(['class' => 'fw-bold']) ?>
|
<?= $contest->getLink(['class' => 'fw-bold']) ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user