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); 如需修改其他用户的密码,请前往 系统管理 页面操作。 +
@@ -309,6 +347,99 @@ EOD); return false; }); + +
+
+ +
+ +
+ +
+ +
+ +
+ > + +
+
+ > + +
+
+ +
+ > + +
+ +
+ > + +
+ +
+ > + +
+ +
+ > + +
+
+ + +
+ +
+ + + +
+
diff --git a/web/app/libs/uoj-utility-lib.php b/web/app/libs/uoj-utility-lib.php index 89c649a..8954e89 100644 --- a/web/app/libs/uoj-utility-lib.php +++ b/web/app/libs/uoj-utility-lib.php @@ -129,7 +129,7 @@ function blog_name_decode($name) { return $name; } -function addUserType($user, $type) { +function addUserType(&$user, $type) { $usertype = explode(',', $user['usertype']); if (!in_array($type, $usertype)) { $usertype[] = $type; @@ -137,7 +137,7 @@ function addUserType($user, $type) { $user['usertype'] = implode(',', $usertype); return $user; } -function removeUserType($user, $type) { +function removeUserType(&$user, $type) { $usertype = explode(',', $user['usertype']); if (in_array($type, $usertype)) { $usertype = array_diff($usertype, array($type)); diff --git a/web/app/locale/user/en.php b/web/app/locale/user/en.php index 5e72ddd..281cb57 100644 --- a/web/app/locale/user/en.php +++ b/web/app/locale/user/en.php @@ -1,6 +1,7 @@ 'Website', + 'user type' => 'User type', 'admin' => 'Admin', 'student' => 'Student', 'teacher' => 'Teacher', diff --git a/web/app/locale/user/zh-cn.php b/web/app/locale/user/zh-cn.php index c4528f4..449014c 100644 --- a/web/app/locale/user/zh-cn.php +++ b/web/app/locale/user/zh-cn.php @@ -1,6 +1,7 @@ '网址', + 'user type' => '用户类型', 'admin' => '管理员', 'student' => '学生', 'teacher' => '老师',