feat(web/user/edit): edit real name
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-10-20 11:18:01 +08:00
parent a9583e605e
commit 6b20408fc1
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
3 changed files with 21 additions and 1 deletions

View File

@ -51,6 +51,23 @@
<div id="help-username" class="form-text">用户名不能被修改。</div>
</div>
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
<div class="mb-3">
<label for="input-realname" class="form-label">$real_name</label>
<input type="text" class="form-control" id="input-realname" aria-describedby="help-realname" value="{$user['realname']}" disabled>
<div id="help-realname" class="form-text">只有管理员才能修改用户的真实姓名。</div>
</div>
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']}'");

View File

@ -1,5 +1,6 @@
<?php
return [
'real name' => 'Real name',
'belongs to these groups' => 'Belongs to these groups:',
'avatar source' => 'Avatar source',
'website' => 'Website',

View File

@ -1,5 +1,6 @@
<?php
return [
'real name' => '真实姓名',
'belongs to these groups' => '属于这些小组:',
'avatar source' => '头像来源',
'website' => '网址',