feat(web/user): allow admins to edit user info and read system msgs
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-10-17 22:13:08 +08:00
parent dd730a4d6a
commit 75c8481676
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
14 changed files with 95 additions and 54 deletions

View File

@ -84,8 +84,8 @@
题目相关问题请联系各校区的竞赛教练以及题目管理员。 题目相关问题请联系各校区的竞赛教练以及题目管理员。
</p> </p>
<p class="card-text"> <p class="card-text">
系统相关问题请邮件联系 <a href="https://sjzezoj.com/user/profile/baoshuo" class="uoj-username">baoshuo</a><a href="mailto:i@baoshuo.ren">i@baoshuo.ren</a> 系统相关问题请邮件联系 <a href="https://sjzezoj.com/user/baoshuo" class="uoj-username">baoshuo</a><a href="mailto:i@baoshuo.ren">i@baoshuo.ren</a>
<a href="https://sjzezoj.com/user/profile/nekko" class="uoj-username">nekko</a><a href="mailto:1139855151@qq.com">1139855151@qq.com</a>)。 <a href="https://sjzezoj.com/user/nekko" class="uoj-username">nekko</a><a href="mailto:1139855151@qq.com">1139855151@qq.com</a>)。
</p> </p>
<h5 class="mt-4">开源项目</h5> <h5 class="mt-4">开源项目</h5>

View File

@ -180,7 +180,7 @@ EOD;
<?php $poster = queryUser($row['poster']); ?> <?php $poster = queryUser($row['poster']); ?>
<div class="mb-3"> <div class="mb-3">
<span class="me-2 d-inline-block"> <span class="me-2 d-inline-block">
<a class="text-decoration-none" href="<?= HTML::url('/user/profile/'.$poster['username']) ?>"> <a class="text-decoration-none" href="<?= HTML::url('/user/'.$poster['username']) ?>">
<img src="<?= HTML::avatar_addr($poster, 64) ?>" width="32" height="32" class="rounded" /> <img src="<?= HTML::avatar_addr($poster, 64) ?>" width="32" height="32" class="rounded" />
</a> </a>
<?= getUserLink($poster['username']) ?> <?= getUserLink($poster['username']) ?>

View File

@ -206,7 +206,7 @@
<?php else: ?> <?php else: ?>
media-left media-left
<?php endif ?>"> <?php endif ?>">
<a href="<?= HTML::url('/user/profile/'.$poster['username']) ?>" class="d-none d-sm-block <a href="<?= HTML::url('/user/'.$poster['username']) ?>" class="d-none d-sm-block
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?> <?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
text-decoration-none text-decoration-none
<?php endif ?>"> <?php endif ?>">

View File

@ -81,9 +81,9 @@
</div> </div>
<?php if (Auth::check()): ?> <?php if (Auth::check()): ?>
<?php if (Auth::id() != $user['username']): ?> <?php if (Auth::id() != $user['username']): ?>
<a type="button" class="btn btn-info btn-sm" href="/user/msg?enter=<?= $user['username'] ?>"><span class="glyphicon glyphicon-envelope"></span> <?= UOJLocale::get('send private message') ?></a> <a type="button" class="btn btn-info btn-sm" href="/user_msg?enter=<?= $user['username'] ?>"><span class="glyphicon glyphicon-envelope"></span> <?= UOJLocale::get('send private message') ?></a>
<?php else: ?> <?php else: ?>
<a type="button" class="btn btn-info btn-sm" href="/user/modify-profile"><span class="glyphicon glyphicon-pencil"></span> <?= UOJLocale::get('modify my profile') ?></a> <a type="button" class="btn btn-info btn-sm" href="/user/<?= $user['username'] ?>/edit"><span class="glyphicon glyphicon-pencil"></span> <?= UOJLocale::get('modify my profile') ?></a>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>

View File

@ -3,22 +3,32 @@
redirectToLogin(); redirectToLogin();
} }
if (!validateUsername($_GET['username']) || !($user = queryUser($_GET['username']))) {
become404Page();
}
if (!isSuperUser($myUser) && $myUser['username'] != $user['username']) {
become403Page();
}
function handlePost() { function handlePost() {
global $myUser; global $myUser, $user;
if ($user['username'] == Auth::id()) {
if (!isset($_POST['old_password'])) { if (!isset($_POST['old_password'])) {
return '无效表单'; return '无效表单';
} }
$old_password = $_POST['old_password']; $old_password = $_POST['old_password'];
if (!validatePassword($old_password) || !checkPassword($myUser, $old_password)) { if (!validatePassword($old_password) || !checkPassword($user, $old_password)) {
return "失败:密码错误。"; return "失败:密码错误。";
} }
}
if ($_POST['ptag']) { if ($_POST['ptag']) {
$password = $_POST['password']; $password = $_POST['password'];
if (!validatePassword($password)) { if (!validatePassword($password)) {
return "失败:无效密码。"; return "失败:无效密码。";
} }
$password = getPasswordToStore($password, $myUser['username']); $password = getPasswordToStore($password, $user['username']);
DB::update("update user_info set password = '$password' where username = '{$myUser['username']}'"); DB::update("update user_info set password = '$password' where username = '{$user['username']}'");
} }
$email = $_POST['email']; $email = $_POST['email'];
@ -26,7 +36,7 @@
return "失败:无效电子邮箱。"; return "失败:无效电子邮箱。";
} }
$esc_email = DB::escape($email); $esc_email = DB::escape($email);
DB::update("update user_info set email = '$esc_email' where username = '{$myUser['username']}'"); DB::update("update user_info set email = '$esc_email' where username = '{$user['username']}'");
if ($_POST['Qtag']) { if ($_POST['Qtag']) {
$qq = $_POST['qq']; $qq = $_POST['qq'];
@ -34,19 +44,19 @@
return "失败无效QQ。"; return "失败无效QQ。";
} }
$esc_qq = DB::escape($qq); $esc_qq = DB::escape($qq);
DB::update("update user_info set qq = '$esc_qq' where username = '{$myUser['username']}'"); DB::update("update user_info set qq = '$esc_qq' where username = '{$user['username']}'");
} else { } else {
DB::update("update user_info set QQ = NULL where username = '{$myUser['username']}'"); DB::update("update user_info set QQ = NULL where username = '{$user['username']}'");
} }
if ($_POST['sex'] == "U" || $_POST['sex'] == 'M' || $_POST['sex'] == 'F') { if ($_POST['sex'] == "U" || $_POST['sex'] == 'M' || $_POST['sex'] == 'F') {
$sex = $_POST['sex']; $sex = $_POST['sex'];
$esc_sex = DB::escape($sex); $esc_sex = DB::escape($sex);
DB::update("update user_info set sex = '$esc_sex' where username = '{$myUser['username']}'"); DB::update("update user_info set sex = '$esc_sex' where username = '{$user['username']}'");
} }
if (validateMotto($_POST['motto'])) { if (validateMotto($_POST['motto'])) {
$esc_motto = DB::escape($_POST['motto']); $esc_motto = DB::escape($_POST['motto']);
DB::update("update user_info set motto = '$esc_motto' where username = '{$myUser['username']}'"); DB::update("update user_info set motto = '$esc_motto' where username = '{$user['username']}'");
} }
return "ok"; return "ok";
@ -60,8 +70,18 @@
$REQUIRE_LIB['md5'] = ''; $REQUIRE_LIB['md5'] = '';
?> ?>
<?php echoUOJPageHeader(UOJLocale::get('modify my profile')) ?> <?php echoUOJPageHeader(UOJLocale::get('modify my profile')) ?>
<h2 class="page-header"><?= UOJLocale::get('modify my profile') ?></h2> <h2 class="page-header">
<?php if ($user['username'] == Auth::id()): ?>
<?= UOJLocale::get('modify my profile') ?>
<?php else: ?>
修改 <?= $user['username'] ?> 的个人信息
<?php endif ?>
</h2>
<?php if (isSuperUser($myUser)): ?>
<p>您正在使用管理特权修改 <?= $user['username'] ?> 的个人信息。</p>
<?php endif ?>
<form id="form-update" class="form-horizontal"> <form id="form-update" class="form-horizontal">
<?php if ($user['username'] == Auth::id()): ?>
<h4><?= UOJLocale::get('please enter your password for authorization') ?></h4> <h4><?= UOJLocale::get('please enter your password for authorization') ?></h4>
<div id="div-old_password" class="form-group"> <div id="div-old_password" class="form-group">
<label for="input-old_password" class="col-sm-2 control-label"><?= UOJLocale::get('password') ?></label> <label for="input-old_password" class="col-sm-2 control-label"><?= UOJLocale::get('password') ?></label>
@ -70,6 +90,7 @@
<span class="help-block" id="help-old_password"></span> <span class="help-block" id="help-old_password"></span>
</div> </div>
</div> </div>
<?php endif ?>
<h4><?= UOJLocale::get('please enter your new profile') ?></h4> <h4><?= UOJLocale::get('please enter your new profile') ?></h4>
<div id="div-password" class="form-group"> <div id="div-password" class="form-group">
<label for="input-password" class="col-sm-2 control-label"><?= UOJLocale::get('new password') ?></label> <label for="input-password" class="col-sm-2 control-label"><?= UOJLocale::get('new password') ?></label>
@ -82,14 +103,14 @@
<div id="div-email" class="form-group"> <div id="div-email" class="form-group">
<label for="input-email" class="col-sm-2 control-label"><?= UOJLocale::get('email') ?></label> <label for="input-email" class="col-sm-2 control-label"><?= UOJLocale::get('email') ?></label>
<div class="col-sm-3"> <div class="col-sm-3">
<input type="email" class="form-control" name="email" id="input-email" value="<?=$myUser['email']?>" placeholder="<?= UOJLocale::get('enter your email') ?>" maxlength="50" /> <input type="email" class="form-control" name="email" id="input-email" value="<?=$user['email']?>" placeholder="<?= UOJLocale::get('enter your email') ?>" maxlength="50" />
<span class="help-block" id="help-email"></span> <span class="help-block" id="help-email"></span>
</div> </div>
</div> </div>
<div id="div-qq" class="form-group"> <div id="div-qq" class="form-group">
<label for="input-qq" class="col-sm-2 control-label"><?= UOJLocale::get('QQ') ?></label> <label for="input-qq" class="col-sm-2 control-label"><?= UOJLocale::get('QQ') ?></label>
<div class="col-sm-3"> <div class="col-sm-3">
<input type="text" class="form-control" name="qq" id="input-qq" value="<?= $myUser['qq'] != 0 ? $myUser['qq'] : '' ?>" placeholder="<?= UOJLocale::get('enter your QQ') ?>" maxlength="50" /> <input type="text" class="form-control" name="qq" id="input-qq" value="<?= $user['qq'] != 0 ? $user['qq'] : '' ?>" placeholder="<?= UOJLocale::get('enter your QQ') ?>" maxlength="50" />
<span class="help-block" id="help-qq"></span> <span class="help-block" id="help-qq"></span>
</div> </div>
</div> </div>
@ -97,16 +118,16 @@
<label for="input-sex" class="col-sm-2 control-label"><?= UOJLocale::get('sex') ?></label> <label for="input-sex" class="col-sm-2 control-label"><?= UOJLocale::get('sex') ?></label>
<div class="col-sm-3"> <div class="col-sm-3">
<select class="form-control" id="input-sex" name="sex"> <select class="form-control" id="input-sex" name="sex">
<option value="U"<?= Auth::user()['sex'] == 'U' ? ' selected="selected"' : ''?>><?= UOJLocale::get('refuse to answer') ?></option> <option value="U"<?= $user['sex'] == 'U' ? ' selected="selected"' : ''?>><?= UOJLocale::get('refuse to answer') ?></option>
<option value="M"<?= Auth::user()['sex'] == 'M' ? ' selected="selected"' : ''?>><?= UOJLocale::get('male') ?></option> <option value="M"<?= $user['sex'] == 'M' ? ' selected="selected"' : ''?>><?= UOJLocale::get('male') ?></option>
<option value="F"<?= Auth::user()['sex'] == 'F' ? ' selected="selected"' : ''?>><?= UOJLocale::get('female') ?></option> <option value="F"<?= $user['sex'] == 'F' ? ' selected="selected"' : ''?>><?= UOJLocale::get('female') ?></option>
</select> </select>
</div> </div>
</div> </div>
<div id="div-motto" class="form-group"> <div id="div-motto" class="form-group">
<label for="input-motto" class="col-sm-2 control-label"><?= UOJLocale::get('motto') ?></label> <label for="input-motto" class="col-sm-2 control-label"><?= UOJLocale::get('motto') ?></label>
<div class="col-sm-3"> <div class="col-sm-3">
<textarea class="form-control" id="input-motto" name="motto"><?=HTML::escape($myUser['motto'])?></textarea> <textarea class="form-control" id="input-motto" name="motto"><?=HTML::escape($user['motto'])?></textarea>
<span class="help-block" id="help-motto">格言支持 Markdown 语法。</span> <span class="help-block" id="help-motto">格言支持 Markdown 语法。</span>
</div> </div>
</div> </div>
@ -126,7 +147,10 @@
function validateUpdatePost() { function validateUpdatePost() {
var ok = true; var ok = true;
ok &= getFormErrorAndShowHelp('email', validateEmail); ok &= getFormErrorAndShowHelp('email', validateEmail);
<?php if ($user['username'] == Auth::id()): ?>
ok &= getFormErrorAndShowHelp('old_password', validatePassword); ok &= getFormErrorAndShowHelp('old_password', validatePassword);
<?php endif ?>
if ($('#input-password').val().length > 0) if ($('#input-password').val().length > 0)
ok &= getFormErrorAndShowHelp('password', validateSettingPassword); ok &= getFormErrorAndShowHelp('password', validateSettingPassword);
@ -138,14 +162,16 @@
function submitUpdatePost() { function submitUpdatePost() {
if (!validateUpdatePost()) if (!validateUpdatePost())
return; return;
$.post('/user/modify-profile', { $.post('', {
change : '', change : '',
etag : $('#input-email').val().length, etag : $('#input-email').val().length,
ptag : $('#input-password').val().length, ptag : $('#input-password').val().length,
Qtag : $('#input-qq').val().length, Qtag : $('#input-qq').val().length,
email : $('#input-email').val(), email : $('#input-email').val(),
password : md5($('#input-password').val(), "<?= getPasswordClientSalt() ?>"), password : md5($('#input-password').val(), "<?= getPasswordClientSalt() ?>"),
<?php if ($user['username'] == Auth::id()): ?>
old_password : md5($('#input-old_password').val(), "<?= getPasswordClientSalt() ?>"), old_password : md5($('#input-old_password').val(), "<?= getPasswordClientSalt() ?>"),
<?php endif ?>
qq : $('#input-qq').val(), qq : $('#input-qq').val(),
sex : $('#input-sex').val(), sex : $('#input-sex').val(),
motto : $('#input-motto').val() motto : $('#input-motto').val()
@ -162,7 +188,7 @@
} }
}], }],
onhidden : function(dialog) { onhidden : function(dialog) {
window.location.href = '/user/profile/<?=$myUser['username']?>'; window.location.href = '/user/<?=$user['username']?>';
} }
}); });
} else { } else {

View File

@ -210,7 +210,7 @@ function submitMessagePost(conversationName) {
$('#help-message').text(''); $('#help-message').text('');
$('#form-group-message').removeClass('has-error'); $('#form-group-message').removeClass('has-error');
$.post('/user/msg', { $.post('', {
user_msg : 1, user_msg : 1,
receiver : conversationName, receiver : conversationName,
message : $('#input-message').val() message : $('#input-message').val()
@ -224,7 +224,7 @@ function refreshHistory(conversation, page) {
var ret = false; var ret = false;
$('#conversation-name').text(conversation); $('#conversation-name').text(conversation);
$('#pageShow').text("" + page.toString() + ""); $('#pageShow').text("" + page.toString() + "");
$.get('/user/msg', { $.get('', {
getHistory : '', getHistory : '',
conversationName : conversation, conversationName : conversation,
pageNumber : page pageNumber : page
@ -246,7 +246,7 @@ function refreshHistory(conversation, page) {
function refreshConversations() { function refreshConversations() {
$("#conversations").empty(); $("#conversations").empty();
$.get('/user/msg', { $.get('', {
getConversations : "" getConversations : ""
}, function(msg) { }, function(msg) {
var result = JSON.parse(msg); var result = JSON.parse(msg);

View File

@ -1,8 +1,16 @@
<?php <?php
if (!Auth::check() && UOJConfig::$data['switch']['force-login']) { if (!Auth::check()) {
redirectToLogin(); redirectToLogin();
} }
if (!validateUsername($_GET['username']) || !($user = queryUser($_GET['username']))) {
become404Page();
}
if (!isSuperUser($myUser) && $myUser['username'] != $user['username']) {
become403Page();
}
$header_row = <<<EOD $header_row = <<<EOD
<tr> <tr>
<th>消息</th> <th>消息</th>
@ -10,7 +18,7 @@
</tr> </tr>
EOD; EOD;
function echoSysMsg($msg) { function echoSysMsg($msg) {
echo $msg['read_time'] == null ? '<tr class="warning">' : '<tr>'; echo $msg['read_time'] == null ? '<tr class="table-warning">' : '<tr>';
echo '<td>'; echo '<td>';
echo '<h4>'.$msg['title'].'</h4>'; echo '<h4>'.$msg['title'].'</h4>';
echo $msg['content']; echo $msg['content'];
@ -21,6 +29,10 @@ EOD;
?> ?>
<?php echoUOJPageHeader('系统消息') ?> <?php echoUOJPageHeader('系统消息') ?>
<h2>系统消息</h2> <h2>系统消息</h2>
<?php echoLongTable(array('*'), 'user_system_msg', "receiver='" . Auth::id() . "'", 'order by id desc', $header_row, 'echoSysMsg', array('table_classes' => array('table'))) ?> <?php echoLongTable(array('*'), 'user_system_msg', "receiver='" . $user['username'] . "'", 'order by id desc', $header_row, 'echoSysMsg', array('table_classes' => array('table'))) ?>
<?php DB::update("update user_system_msg set read_time = now() where receiver = '" . Auth::id() . "'") ?> <?php
if (Auth::id() == $user['username']) {
DB::update("update user_system_msg set read_time = now() where receiver = '" . $user['username'] . "'");
}
?>
<?php echoUOJPageFooter() ?> <?php echoUOJPageFooter() ?>

View File

@ -70,10 +70,12 @@ Route::group([
Route::any('/register', '/register.php'); Route::any('/register', '/register.php');
Route::any('/forgot-password', '/forgot_pw.php'); Route::any('/forgot-password', '/forgot_pw.php');
Route::any('/reset-password', '/reset_pw.php'); Route::any('/reset-password', '/reset_pw.php');
Route::any('/user/profile/{username}', '/user_info.php');
Route::any('/user/modify-profile', '/change_user_info.php'); Route::any('/user/{username}', '/user_info.php');
Route::any('/user/msg', '/user_msg.php'); Route::any('/user/{username}/edit', '/user_info_edit.php');
Route::any('/user/system-msg', '/user_system_msg.php'); Route::any('/user_msg', '/user_msg.php');
Route::any('/user/{username}/system_msg', '/user_system_msg.php');
Route::any('/super-manage(?:/{tab})?', '/super_manage.php'); Route::any('/super-manage(?:/{tab})?', '/super_manage.php');
Route::any('/download.php', '/download.php'); Route::any('/download.php', '/download.php');

View File

@ -119,12 +119,12 @@ mb-4" role="navigation">
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li> <li>
<a class="dropdown-item" href="<?= HTML::url('/user/profile/' . Auth::id()) ?>"> <a class="dropdown-item" href="<?= HTML::url('/user/' . Auth::id()) ?>">
<?= UOJLocale::get('my profile') ?> <?= UOJLocale::get('my profile') ?>
</a> </a>
</li> </li>
<li> <li>
<a class="dropdown-item" href="<?= HTML::url('/user/msg') ?>"> <a class="dropdown-item" href="<?= HTML::url('/user_msg') ?>">
<?= UOJLocale::get('private message') ?> <?= UOJLocale::get('private message') ?>
<?php if ($new_user_msg_num): ?> <?php if ($new_user_msg_num): ?>
<span class="badge bg-danger rounded-pill"> <span class="badge bg-danger rounded-pill">
@ -134,7 +134,7 @@ mb-4" role="navigation">
</a> </a>
</li> </li>
<li> <li>
<a class="dropdown-item" href="<?= HTML::url('/user/system-msg') ?>"> <a class="dropdown-item" href="<?= HTML::url('/user/'.Auth::id().'system_msg') ?>">
<?= UOJLocale::get('system message') ?> <?= UOJLocale::get('system message') ?>
<?php if ($new_system_msg_num): ?> <?php if ($new_system_msg_num): ?>
<span class="badge bg-danger rounded-pill"> <span class="badge bg-danger rounded-pill">

View File

@ -186,12 +186,12 @@ mb-4" role="navigation">
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li> <li>
<a class="dropdown-item" href="<?= HTML::url('/user/profile/' . Auth::id()) ?>"> <a class="dropdown-item" href="<?= HTML::url('/user/' . Auth::id()) ?>">
<?= UOJLocale::get('my profile') ?> <?= UOJLocale::get('my profile') ?>
</a> </a>
</li> </li>
<li> <li>
<a class="dropdown-item" href="<?= HTML::url('/user/msg') ?>"> <a class="dropdown-item" href="<?= HTML::url('/user_msg') ?>">
<?= UOJLocale::get('private message') ?> <?= UOJLocale::get('private message') ?>
<?php if ($new_user_msg_num): ?> <?php if ($new_user_msg_num): ?>
<span class="badge bg-danger rounded-pill"> <span class="badge bg-danger rounded-pill">
@ -201,7 +201,7 @@ mb-4" role="navigation">
</a> </a>
</li> </li>
<li> <li>
<a class="dropdown-item" href="<?= HTML::url('/user/system-msg') ?>"> <a class="dropdown-item" href="<?= HTML::url('/user/'.Auth::id().'/system_msg') ?>">
<?= UOJLocale::get('system message') ?> <?= UOJLocale::get('system message') ?>
<?php if ($new_system_msg_num): ?> <?php if ($new_system_msg_num): ?>
<span class="badge bg-danger rounded-pill"> <span class="badge bg-danger rounded-pill">

View File

@ -267,9 +267,9 @@
<span class="uoj-username" data-link="0"><?= Auth::id() ?></span> <?= $new_msg_tot_html ?> <span class="uoj-username" data-link="0"><?= Auth::id() ?></span> <?= $new_msg_tot_html ?>
</a> </a>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li role="presentation"><a class="dropdown-item" href="<?= HTML::url('/user/profile/' . Auth::id()) ?>"><?= UOJLocale::get('my profile') ?></a></li> <li role="presentation"><a class="dropdown-item" href="<?= HTML::url('/user/' . Auth::id()) ?>"><?= UOJLocale::get('my profile') ?></a></li>
<li role="presentation"><a class="dropdown-item" href="<?= HTML::url('/user/msg') ?>"><?= UOJLocale::get('private message') ?>&nbsp;&nbsp;<?= $new_user_msg_num_html ?></a></li> <li role="presentation"><a class="dropdown-item" href="<?= HTML::url('/user_msg') ?>"><?= UOJLocale::get('private message') ?>&nbsp;&nbsp;<?= $new_user_msg_num_html ?></a></li>
<li role="presentation"><a class="dropdown-item" href="<?= HTML::url('/user/system-msg') ?>"><?= UOJLocale::get('system message') ?>&nbsp;&nbsp;<?= $new_system_msg_num_html ?></a></li> <li role="presentation"><a class="dropdown-item" href="<?= HTML::url('/user/'.Auth::id().'/system_msg') ?>"><?= UOJLocale::get('system message') ?>&nbsp;&nbsp;<?= $new_system_msg_num_html ?></a></li>
<?php if (isSuperUser(Auth::user())): ?> <?php if (isSuperUser(Auth::user())): ?>
<li role="presentation"><a class="dropdown-item" href="<?= HTML::url('/super-manage') ?>"><?= UOJLocale::get('system manage') ?></a></li> <li role="presentation"><a class="dropdown-item" href="<?= HTML::url('/super-manage') ?>"><?= UOJLocale::get('system manage') ?></a></li>
<?php endif ?> <?php endif ?>

View File

@ -160,12 +160,13 @@ function fTime($time, $gran = -1) {
<nav class="nav mb-2"> <nav class="nav mb-2">
<?php if (Auth::check()): ?> <?php if (Auth::check()): ?>
<?php if (Auth::id() != $user['username']): ?> <?php if (Auth::id() != $user['username']): ?>
<a class="nav-link" href="/user/msg?enter=<?= $user['username'] ?>"> <a class="nav-link" href="/user_msg?enter=<?= $user['username'] ?>">
<i class="bi bi-chat-left-dots"></i> <i class="bi bi-chat-left-dots"></i>
<?= UOJLocale::get('send private message') ?> <?= UOJLocale::get('send private message') ?>
</a> </a>
<?php else: ?> <?php endif ?>
<a class="nav-link" href="/user/modify-profile"> <?php if (Auth::id() == $user['username'] || isSuperUser(Auth::user())): ?>
<a class="nav-link" href="/user/<?= $user['username'] ?>/edit">
<i class="bi bi-pencil"></i> <i class="bi bi-pencil"></i>
<?= UOJLocale::get('modify my profile') ?> <?= UOJLocale::get('modify my profile') ?>
</a> </a>

View File

@ -129,7 +129,7 @@ function getUserLink(username, realname) {
if (realname) { if (realname) {
text = text + ' <span class="uoj-realname d-inline-block">(' + realname + ')</span>'; text = text + ' <span class="uoj-realname d-inline-block">(' + realname + ')</span>';
} }
return '<a class="uoj-username" href="' + uojHome + '/user/profile/' + username + '">' + text + '</a>'; return '<a class="uoj-username" href="' + uojHome + '/user/' + username + '">' + text + '</a>';
} }
function getUserSpan(username, realname) { function getUserSpan(username, realname) {
if (!username) { if (!username) {