diff --git a/Web/Presenters/AdminPresenter.php b/Web/Presenters/AdminPresenter.php index 9c356d55..39845ae4 100644 --- a/Web/Presenters/AdminPresenter.php +++ b/Web/Presenters/AdminPresenter.php @@ -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 diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index c9457cba..7af04225 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -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]); diff --git a/Web/Presenters/templates/User/banned.xml b/Web/Presenters/templates/User/banned.xml index a9cfed3c..f1e6f8c1 100644 --- a/Web/Presenters/templates/User/banned.xml +++ b/Web/Presenters/templates/User/banned.xml @@ -4,4 +4,29 @@ {tr("user_banned", htmlentities($user->getFirstName()))|noescape}
{_"user_banned_comment"} {$user->getBanReason()}.

+

+
{_unban_user_action} +

+ + diff --git a/Web/routes.yml b/Web/routes.yml index 2c22687f..a31bffad 100644 --- a/Web/routes.yml +++ b/Web/routes.yml @@ -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}" diff --git a/locales/en.strings b/locales/en.strings index 5d138899..a305cbdd 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -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"; diff --git a/locales/ru.strings b/locales/ru.strings index cc98e2d8..0c71d919 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -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" = "Разблокировать в поддержке";