diff --git a/web/app/controllers/user_info_edit.php b/web/app/controllers/user_info_edit.php index e4a2f4d..b1354b9 100644 --- a/web/app/controllers/user_info_edit.php +++ b/web/app/controllers/user_info_edit.php @@ -27,9 +27,13 @@ 'url' => "/user/{$user['username']}/edit/profile", ], 'password' => [ - 'name' => ' 修改密码', + 'name' => ' 修改密码', 'url' => "/user/{$user['username']}/edit/password", ], + 'privilege' => [ + 'name' => ' 特权', + 'url' => "/user/{$user['username']}/edit/privilege", + ] ]; if (!isset($tabs_info[$cur_tab])) { @@ -177,6 +181,39 @@ EOD); DB::update("UPDATE `user_info` SET `password` = '$password' where `username` = '{$user['username']}'"); die(json_encode(['status' => 'success', 'message' => '密码修改成功'])); } + } elseif ($cur_tab == 'privilege') { + if (isset($_POST['submit-privilege']) && $_POST['submit-privilege'] == 'privilege' && isSuperUser($myUser)) { + header('Content-Type: application/json'); + + $user['usertype'] = 'student'; + + if ($_POST['user_type'] == 'teacher') { + removeUserType($user, 'student'); + addUserType($user, 'teacher'); + } else { + addUserType($user, 'student'); + } + + if ($_POST['problem_uploader'] == 'yes') { + addUserType($user, 'problem_uploader'); + } + + if ($_POST['problem_manager'] == 'yes') { + addUserType($user, 'problem_manager'); + } + + if ($_POST['contest_judger'] == 'yes') { + addUserType($user, 'contest_judger'); + } + + if ($_POST['contest_only'] == 'yes') { + addUserType($user, 'contest_only'); + } + + DB::update("UPDATE `user_info` SET `usertype` = '{$user['usertype']}' where `username` = '{$user['username']}'"); + + die(json_encode(['status' => 'success', 'message' => '权限修改成功'])); + } } $pageTitle = $user['username'] == $myUser['username'] @@ -260,6 +297,7 @@ EOD); 如需修改其他用户的密码,请前往 系统管理 页面操作。 +