From d502fb95ac9b16940277661bbfc5aafcf30fd57c Mon Sep 17 00:00:00 2001
From: Baoshuo
Date: Sun, 25 Sep 2022 21:03:56 +0800
Subject: [PATCH] feat: change uploader username
---
.../controllers/problem_managers_manage.php | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/web/app/controllers/problem_managers_manage.php b/web/app/controllers/problem_managers_manage.php
index 2146ba5..a9e456e 100644
--- a/web/app/controllers/problem_managers_manage.php
+++ b/web/app/controllers/problem_managers_manage.php
@@ -34,6 +34,36 @@
);
$managers_form->runAtServer();
+
+
+ if (isSuperUser($myUser)) {
+ $update_uploader_form = new UOJForm('update_uploader');
+ $update_uploader_form->addInput('new_uploader_username', 'text', '用户名', $problem['uploader'] ?: 'root',
+ function ($x) {
+ if (!validateUsername($x)) {
+ return '用户名不合法';
+ }
+
+ if (!queryUser($x)) {
+ return '用户不存在';
+ }
+
+ return '';
+ },
+ null
+ );
+ $update_uploader_form->submit_button_config['align'] = 'compressed';
+ $update_uploader_form->submit_button_config['text'] = '修改上传者';
+ $update_uploader_form->submit_button_config['class_str'] = 'mt-2 btn btn-warning';
+ $update_uploader_form->handle = function() {
+ global $problem;
+
+ $username = $_POST['new_uploader_username'];
+
+ DB::query("update problems set uploader = '{$username}' where id = {$problem['id']}");
+ };
+ $update_uploader_form->runAtServer();
+ }
?>
#=$problem['id']?> : =$problem['title']?> 管理
@@ -64,4 +94,9 @@
命令格式:命令一行一个,+mike表示把mike加入管理者,-mike表示把mike从管理者中移除
printHTML(); ?> + + + printHTML(); ?> + +