From 6b20408fc107be586d310478618021ffd02dbe80 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 20 Oct 2022 11:18:01 +0800 Subject: [PATCH] feat(web/user/edit): edit real name --- web/app/controllers/user_info_edit.php | 20 +++++++++++++++++++- web/app/locale/user/en.php | 1 + web/app/locale/user/zh-cn.php | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/web/app/controllers/user_info_edit.php b/web/app/controllers/user_info_edit.php index aed14b2..353b002 100644 --- a/web/app/controllers/user_info_edit.php +++ b/web/app/controllers/user_info_edit.php @@ -51,6 +51,23 @@
用户名不能被修改。
EOD); + if (isSuperUser($myUser)) { + $update_profile_form->addVInput('realname', 'text', UOJLocale::get('user::real name'), $user['realname'], + function($realname, &$vdata) { + $vdata['realname'] = $realname; + + return ''; + }, null); + } else { + $real_name = UOJLocale::get('user::real name'); + $update_profile_form->appendHTML(<< + + +
只有管理员才能修改用户的真实姓名。
+ +EOD); + } $update_profile_form->addVCheckboxes('avatar_source', [ 'gravatar' => 'Gravatar', 'qq' => 'QQ', @@ -154,9 +171,10 @@ EOD); $esc_avatar_source = DB::escape($_POST['avatar_source']); if (isSuperUser($myUser)) { + $esc_realname = DB::escape($vdata['realname']); $esc_school = DB::escape($vdata['school']); - DB::update("UPDATE user_info SET school = '$esc_school' WHERE username = '{$user['username']}'"); + DB::update("UPDATE user_info SET realname = '$esc_realname', school = '$esc_school' WHERE username = '{$user['username']}'"); } DB::update("UPDATE user_info SET email = '$esc_email', qq = '$esc_qq', sex = '$esc_sex', motto = '$esc_motto', codeforces_handle = '$esc_codeforces_handle', github = '$esc_github', website = '$esc_website', avatar_source = '$esc_avatar_source' WHERE username = '{$user['username']}'"); diff --git a/web/app/locale/user/en.php b/web/app/locale/user/en.php index df24ebc..95a9e2f 100644 --- a/web/app/locale/user/en.php +++ b/web/app/locale/user/en.php @@ -1,5 +1,6 @@ 'Real name', 'belongs to these groups' => 'Belongs to these groups:', 'avatar source' => 'Avatar source', 'website' => 'Website', diff --git a/web/app/locale/user/zh-cn.php b/web/app/locale/user/zh-cn.php index 710cdce..e956cda 100644 --- a/web/app/locale/user/zh-cn.php +++ b/web/app/locale/user/zh-cn.php @@ -1,5 +1,6 @@ '真实姓名', 'belongs to these groups' => '属于这些小组:', 'avatar source' => '头像来源', 'website' => '网址',