feat: add contest_judger permission
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-09-21 19:26:13 +08:00
parent ca3680727c
commit 9b8ffca752
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
3 changed files with 10 additions and 2 deletions

View File

@ -99,8 +99,8 @@
} }
} }
if (isSuperUser($myUser)) { if (isSuperUser($myUser) || isContestJudger($myUser)) {
if (CONTEST_PENDING_FINAL_TEST <= $contest['cur_progress'] && $contest['cur_progress'] <= CONTEST_TESTING) { if (CONTEST_PENDING_FINAL_TEST <= $contest['cur_progress']) {
$start_test_form = new UOJForm('start_test'); $start_test_form = new UOJForm('start_test');
$start_test_form->handle = function() { $start_test_form->handle = function() {
global $contest; global $contest;

View File

@ -163,6 +163,7 @@
$usertype_options = array( $usertype_options = array(
'problem_uploader' => '题目上传者', 'problem_uploader' => '题目上传者',
'problem_manager' => '题目管理员', 'problem_manager' => '题目管理员',
'contest_judger' => '比赛评测员',
'contest_only' => '仅比赛参加者', 'contest_only' => '仅比赛参加者',
); );
$usertype_form->addSelect('usertype_type', $usertype_options, '角色', ''); $usertype_form->addSelect('usertype_type', $usertype_options, '角色', '');
@ -174,6 +175,7 @@
switch ($_POST['usertype_type']) { switch ($_POST['usertype_type']) {
case 'problem_uploader': case 'problem_uploader':
case 'problem_manager': case 'problem_manager':
case 'contest_judger':
case 'contest_only': case 'contest_only':
$user = queryUser($username); $user = queryUser($username);
$user = $_POST['usertype_op'] === 'add' $user = $_POST['usertype_op'] === 'add'

View File

@ -165,6 +165,12 @@ function isProblemManager($user) {
} }
return hasUserType($user, 'problem_manager'); return hasUserType($user, 'problem_manager');
} }
function isContestJudger($user) {
if ($user == null) {
return false;
}
return hasUserType($user, 'contest_judger');
}
function isSuperUser($user) { function isSuperUser($user) {
return $user != null && $user['usergroup'] == 'S'; return $user != null && $user['usergroup'] == 'S';