From ef01c326b2d63ff0a6e83e57c5dd19c9c15b17b4 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 12 Nov 2022 10:29:53 +0800 Subject: [PATCH] feat(web/contests): upcoming contests view permission check --- web/app/models/UOJContest.php | 6 +++--- web/app/views/sidebar.php | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/web/app/models/UOJContest.php b/web/app/models/UOJContest.php index 2fd0ad7..e7496d9 100644 --- a/web/app/models/UOJContest.php +++ b/web/app/models/UOJContest.php @@ -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) { diff --git a/web/app/views/sidebar.php b/web/app/views/sidebar.php index efc7f80..956c64a 100644 --- a/web/app/views/sidebar.php +++ b/web/app/views/sidebar.php @@ -63,14 +63,13 @@ $parsedown = HTML::parsedown(); - +
近期比赛