fix: remove problem_uploader permission when add problem_manager
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-10-01 22:03:00 +08:00
parent 7678b34221
commit ce10dce025
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -211,12 +211,6 @@
$username = $_POST['usertype_username']; $username = $_POST['usertype_username'];
$user = queryUser($username); $user = queryUser($username);
switch ($_POST['usertype_type']) { switch ($_POST['usertype_type']) {
case 'student':
$user = $_POST['usertype_op'] === 'add'
? addUserType($user, 'student')
: removeUserType($user, 'student');
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
break;
case 'teacher': case 'teacher':
if ($_POST['usertype_op'] === 'add') { if ($_POST['usertype_op'] === 'add') {
$user = addUserType($user, 'teacher'); $user = addUserType($user, 'teacher');
@ -225,18 +219,26 @@
$user = removeUserType($user, 'teacher'); $user = removeUserType($user, 'teacher');
$user = addUserType($user, 'student'); $user = addUserType($user, 'student');
} }
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
break; break;
case 'problem_uploader':
case 'problem_manager': case 'problem_manager':
if ($_POST['usertype_op'] === 'add') {
$user = addUserType($user, 'problem_manager');
$user = removeUserType($user, 'problem_uploader');
} else {
$user = removeUserType($user, 'problem_manager');
}
break;
case 'student':
case 'problem_uploader':
case 'contest_judger': case 'contest_judger':
case 'contest_only': case 'contest_only':
$user = $_POST['usertype_op'] === 'add' $user = $_POST['usertype_op'] === 'add'
? addUserType($user, $_POST['usertype_type']) ? addUserType($user, $_POST['usertype_type'])
: removeUserType($user, $_POST['usertype_type']); : removeUserType($user, $_POST['usertype_type']);
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
break; break;
} }
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
}; };
$usertype_form->runAtServer(); $usertype_form->runAtServer();