mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +03:00
Users: Allow admins to easily unban users
This commit is contained in:
parent
6588734caa
commit
6538f0ccd2
6 changed files with 44 additions and 2 deletions
|
@ -346,7 +346,20 @@ final class AdminPresenter extends OpenVKPresenter
|
|||
exit(json_encode([ "error" => "User does not exist" ]));
|
||||
|
||||
$user->ban($this->queryParam("reason"));
|
||||
exit(json_encode([ "reason" => $this->queryParam("reason") ]));
|
||||
exit(json_encode([ "success" => true, "reason" => $this->queryParam("reason") ]));
|
||||
}
|
||||
|
||||
function renderQuickUnban(int $id): void
|
||||
{
|
||||
$this->assertNoCSRF();
|
||||
|
||||
$user = $this->users->get($id);
|
||||
if(!$user)
|
||||
exit(json_encode([ "error" => "User does not exist" ]));
|
||||
|
||||
$user->setBlock_Reason(null);
|
||||
$user->save();
|
||||
exit(json_encode([ "success" => true ]));
|
||||
}
|
||||
|
||||
function renderQuickWarn(int $id): void
|
||||
|
|
|
@ -522,7 +522,7 @@
|
|||
xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "/admin/ban/" + {$user->getId()} + "?reason=" + res + "&hash=" + {rawurlencode($csrfToken)}, true);
|
||||
xhr.onload = (function() {
|
||||
if(xhr.responseText.indexOf("reason") === -1)
|
||||
if(xhr.responseText.indexOf("success") === -1)
|
||||
MessageBox("Ошибка", "Не удалось забанить пользователя...", ["OK"], [Function.noop]);
|
||||
else
|
||||
MessageBox("Операция успешна", "Пользователь заблокирован", ["OK"], [Function.noop]);
|
||||
|
|
|
@ -4,4 +4,29 @@
|
|||
{tr("user_banned", htmlentities($user->getFirstName()))|noescape}<br/>
|
||||
{_"user_banned_comment"} <b>{$user->getBanReason()}</b>.
|
||||
</p>
|
||||
<p n:if="isset($thisUser) && $thisUser->getChandlerUser()->can('access')->model('admin')->whichBelongsTo(NULL)">
|
||||
<br/><a href="javascript:toggleUnbanUser()" class="button">{_unban_user_action}</a>
|
||||
</p>
|
||||
</center>
|
||||
|
||||
<script n:if="isset($thisUser) && $thisUser->getChandlerUser()->can('access')->model('admin')->whichBelongsTo(NULL)">
|
||||
function toggleUnbanUser() {
|
||||
uUnbanMsgTxt = "Вы собираетесь разбанить пользователя " + {$user->getCanonicalName()} + ".";
|
||||
uUnbanMsgTxt += "<br/>Сейчас он заблокирован по причине: <strong>" + {$user->getBanReason()} + "</strong>.";
|
||||
|
||||
MessageBox("Разбанить " + {$user->getFirstName()}, uUnbanMsgTxt, ["Подтвердить", "Отмена"], [
|
||||
(function() {
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "/admin/unban/" + {$user->getId()} + "?hash=" + {rawurlencode($csrfToken)}, true);
|
||||
xhr.onload = (function() {
|
||||
if(xhr.responseText.indexOf("success") === -1)
|
||||
MessageBox("Ошибка", "Не удалось разблокировать пользователя...", ["OK"], [Function.noop]);
|
||||
else
|
||||
MessageBox("Операция успешна", "Пользователь разблокирован", ["OK"], [Function.noop]);
|
||||
});
|
||||
xhr.send(null);
|
||||
}),
|
||||
Function.noop
|
||||
]);
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -271,6 +271,8 @@ routes:
|
|||
handler: "Admin->gifts"
|
||||
- url: "/admin/ban/{num}"
|
||||
handler: "Admin->quickBan"
|
||||
- url: "/admin/unban/{num}"
|
||||
handler: "Admin->quickUnban"
|
||||
- url: "/admin/warn/{num}"
|
||||
handler: "Admin->quickWarn"
|
||||
- url: "/admin/support/ban/{num}"
|
||||
|
|
|
@ -834,6 +834,7 @@
|
|||
"manage_user_action" = "Manage user";
|
||||
"manage_group_action" = "Manage group";
|
||||
"ban_user_action" = "Ban user";
|
||||
"unban_user_action" = "Unban user";
|
||||
"warn_user_action" = "Warn user";
|
||||
"ban_in_support_user_action" = "Ban in support";
|
||||
"unban_in_support_user_action" = "Unban in support";
|
||||
|
|
|
@ -877,6 +877,7 @@
|
|||
"manage_user_action" = "Управление пользователем";
|
||||
"manage_group_action" = "Управление группой";
|
||||
"ban_user_action" = "Заблокировать пользователя";
|
||||
"unban_user_action" = "Разблокировать пользователя";
|
||||
"warn_user_action" = "Предупредить пользователя";
|
||||
"ban_in_support_user_action" = "Заблокировать в поддержке";
|
||||
"unban_in_support_user_action" = "Разблокировать в поддержке";
|
||||
|
|
Loading…
Reference in a new issue