From be7510a6bb24da2aeb85314e1c896b4779c857b6 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 15 Jan 2023 09:38:29 +0800 Subject: [PATCH] feat(super_manage): allow change usergroup to temp user --- web/app/controllers/super_manage.php | 58 +++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/web/app/controllers/super_manage.php b/web/app/controllers/super_manage.php index ad04c3e..c5a61e7 100644 --- a/web/app/controllers/super_manage.php +++ b/web/app/controllers/super_manage.php @@ -516,7 +516,7 @@ EOD); 'new_tmp_expiration_time', 'text', '过期时间', - (new DateTime())->add(new DateInterval('P7D'))->format('Y-m-d H:i:s'), + UOJTime::time2str((new DateTime())->add(new DateInterval('P7D'))->setTime(0, 0, 0)), function ($str, &$vdata) { try { $vdata['expiration_time'] = new DateTime($str); @@ -657,6 +657,7 @@ EOD); ); $change_usergroup_form->addVSelect('op_type', [ 'banneduser' => '设为封禁用户', + 'tempuser' => '设为临时用户', 'normaluser' => '设为普通用户', 'superuser' => '设为超级用户', ], '操作类型', ''); @@ -666,15 +667,59 @@ EOD); switch ($_POST['op_type']) { case 'banneduser': - DB::update("update user_info set usergroup = 'B', usertype = 'banned' where username = '{$username}'"); - $usergroup = '被封禁的用户'; + DB::update([ + "update user_info", + "set", [ + "usergroup" => "B", + "usertype" => "banned", + "expiration_time" => null, + ], + "where", [ + "username" => $username, + ], + ]); + $usergroup = '被封禁的用户,该用户将无法再次登录系统'; + break; + case 'tempuser': + DB::update([ + "update user_info", + "set", [ + "usergroup" => "T", + "usertype" => "student", + "expiration_time" => DB::now(), + ], + "where", [ + "username" => $username, + ], + ]); + $usergroup = '临时用户,请前往个人信息编辑页面修改过期时间'; break; case 'normaluser': - DB::update("update user_info set usergroup = 'U', usertype = 'student' where username = '{$username}'"); + DB::update([ + "update user_info", + "set", [ + "usergroup" => "U", + "usertype" => "student", + "expiration_time" => null, + ], + "where", [ + "username" => $username, + ], + ]); $usergroup = '普通用户'; break; case 'superuser': - DB::update("update user_info set usergroup = 'S', usertype = 'student' where username = '{$username}'"); + DB::update([ + "update user_info", + "set", [ + "usergroup" => "S", + "usertype" => "student", + "expiration_time" => null, + ], + "where", [ + "username" => $username, + ], + ]); $usergroup = '超级用户'; break; } @@ -1429,7 +1474,8 @@ EOD);
注意事项