From 9b8ffca752fdcf507b9607284abf6c22316a5aed Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 21 Sep 2022 19:26:13 +0800 Subject: [PATCH] feat: add contest_judger permission --- web/app/controllers/contest_inside.php | 4 ++-- web/app/controllers/super_manage.php | 2 ++ web/app/libs/uoj-utility-lib.php | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/web/app/controllers/contest_inside.php b/web/app/controllers/contest_inside.php index de86881..e3f67d6 100644 --- a/web/app/controllers/contest_inside.php +++ b/web/app/controllers/contest_inside.php @@ -99,8 +99,8 @@ } } - if (isSuperUser($myUser)) { - if (CONTEST_PENDING_FINAL_TEST <= $contest['cur_progress'] && $contest['cur_progress'] <= CONTEST_TESTING) { + if (isSuperUser($myUser) || isContestJudger($myUser)) { + if (CONTEST_PENDING_FINAL_TEST <= $contest['cur_progress']) { $start_test_form = new UOJForm('start_test'); $start_test_form->handle = function() { global $contest; diff --git a/web/app/controllers/super_manage.php b/web/app/controllers/super_manage.php index 1b5461f..7eb3b35 100644 --- a/web/app/controllers/super_manage.php +++ b/web/app/controllers/super_manage.php @@ -163,6 +163,7 @@ $usertype_options = array( 'problem_uploader' => '题目上传者', 'problem_manager' => '题目管理员', + 'contest_judger' => '比赛评测员', 'contest_only' => '仅比赛参加者', ); $usertype_form->addSelect('usertype_type', $usertype_options, '角色', ''); @@ -174,6 +175,7 @@ switch ($_POST['usertype_type']) { case 'problem_uploader': case 'problem_manager': + case 'contest_judger': case 'contest_only': $user = queryUser($username); $user = $_POST['usertype_op'] === 'add' diff --git a/web/app/libs/uoj-utility-lib.php b/web/app/libs/uoj-utility-lib.php index 7019e4a..bc98444 100644 --- a/web/app/libs/uoj-utility-lib.php +++ b/web/app/libs/uoj-utility-lib.php @@ -165,6 +165,12 @@ function isProblemManager($user) { } return hasUserType($user, 'problem_manager'); } +function isContestJudger($user) { + if ($user == null) { + return false; + } + return hasUserType($user, 'contest_judger'); +} function isSuperUser($user) { return $user != null && $user['usergroup'] == 'S';