mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
parent
324297db7e
commit
a935b2ca31
10 changed files with 71 additions and 10 deletions
|
@ -768,7 +768,7 @@ class User extends RowModel
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ban(string $reason, bool $deleteSubscriptions = true): void
|
function ban(string $reason, bool $deleteSubscriptions = true, ?int $unban_time = NULL): void
|
||||||
{
|
{
|
||||||
if($deleteSubscriptions) {
|
if($deleteSubscriptions) {
|
||||||
$subs = DatabaseConnection::i()->getContext()->table("subscriptions");
|
$subs = DatabaseConnection::i()->getContext()->table("subscriptions");
|
||||||
|
@ -782,6 +782,7 @@ class User extends RowModel
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setBlock_Reason($reason);
|
$this->setBlock_Reason($reason);
|
||||||
|
$this->setUnblock_time($unban_time);
|
||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1018,5 +1019,21 @@ class User extends RowModel
|
||||||
return (bool) $this->getRecord()->activated;
|
return (bool) $this->getRecord()->activated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUnbanTime(): ?string
|
||||||
|
{
|
||||||
|
return !is_null($this->getRecord()->unblock_time) ? date('d.m.Y', $this->getRecord()->unblock_time) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
function canUnbanThemself(): bool
|
||||||
|
{
|
||||||
|
if (!$this->isBanned())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ($this->getRecord()->unblock_time > time() || $this->getRecord()->unblock_time == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
use Traits\TSubscribable;
|
use Traits\TSubscribable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,11 +340,13 @@ final class AdminPresenter extends OpenVKPresenter
|
||||||
{
|
{
|
||||||
$this->assertNoCSRF();
|
$this->assertNoCSRF();
|
||||||
|
|
||||||
|
$unban_time = strtotime($this->queryParam("date")) ?: NULL;
|
||||||
|
|
||||||
$user = $this->users->get($id);
|
$user = $this->users->get($id);
|
||||||
if(!$user)
|
if(!$user)
|
||||||
exit(json_encode([ "error" => "User does not exist" ]));
|
exit(json_encode([ "error" => "User does not exist" ]));
|
||||||
|
|
||||||
$user->ban($this->queryParam("reason"));
|
$user->ban($this->queryParam("reason"), true, $unban_time);
|
||||||
exit(json_encode([ "success" => true, "reason" => $this->queryParam("reason") ]));
|
exit(json_encode([ "success" => true, "reason" => $this->queryParam("reason") ]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +358,8 @@ final class AdminPresenter extends OpenVKPresenter
|
||||||
if(!$user)
|
if(!$user)
|
||||||
exit(json_encode([ "error" => "User does not exist" ]));
|
exit(json_encode([ "error" => "User does not exist" ]));
|
||||||
|
|
||||||
$user->setBlock_Reason(null);
|
$user->setBlock_Reason(NULL);
|
||||||
|
$user->setUnblock_time(NULL);
|
||||||
$user->save();
|
$user->save();
|
||||||
exit(json_encode([ "success" => true ]));
|
exit(json_encode([ "success" => true ]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,6 +323,23 @@ final class AuthPresenter extends OpenVKPresenter
|
||||||
$this->redirect("/");
|
$this->redirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderUnbanThemself(): void
|
||||||
|
{
|
||||||
|
$this->assertUserLoggedIn();
|
||||||
|
$this->willExecuteWriteAction();
|
||||||
|
|
||||||
|
if(!$this->user->identity->canUnbanThemself())
|
||||||
|
$this->flashFail("err", tr("error"), tr("forbidden"));
|
||||||
|
|
||||||
|
$user = $this->users->get($this->user->id);
|
||||||
|
|
||||||
|
$user->setBlock_Reason(NULL);
|
||||||
|
$user->setUnblock_Time(NULL);
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
$this->flashFail("succ", tr("banned_unban_title"), tr("banned_unban_description"));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function will revoke all tokens, including API and Web tokens and except active one
|
* This function will revoke all tokens, including API and Web tokens and except active one
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,7 +17,6 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
private $users;
|
private $users;
|
||||||
|
|
||||||
public $deactivationTolerant = false;
|
public $deactivationTolerant = false;
|
||||||
|
|
||||||
function __construct(Users $users)
|
function __construct(Users $users)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
|
|
|
@ -12,6 +12,16 @@
|
||||||
<p>
|
<p>
|
||||||
{tr("banned_1", htmlentities($thisUser->getCanonicalName()))|noescape}<br/>
|
{tr("banned_1", htmlentities($thisUser->getCanonicalName()))|noescape}<br/>
|
||||||
{tr("banned_2", htmlentities($thisUser->getBanReason()))|noescape}
|
{tr("banned_2", htmlentities($thisUser->getBanReason()))|noescape}
|
||||||
|
|
||||||
|
{if !$thisUser->getUnbanTime()}
|
||||||
|
{_banned_perm}
|
||||||
|
{else}
|
||||||
|
{tr("banned_until_time", $thisUser->getUnbanTime())|noescape}
|
||||||
|
{/if}
|
||||||
|
</p>
|
||||||
|
<p n:if="$thisUser->canUnbanThemself()">
|
||||||
|
<hr/>
|
||||||
|
<center><a class="button" href="/unban.php">{_banned_unban_myself}</a></center>
|
||||||
</p>
|
</p>
|
||||||
<hr/>
|
<hr/>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -543,12 +543,14 @@
|
||||||
uBanMsgTxt = "Вы собираетесь забанить пользователя " + {$user->getCanonicalName()} + ".";
|
uBanMsgTxt = "Вы собираетесь забанить пользователя " + {$user->getCanonicalName()} + ".";
|
||||||
uBanMsgTxt += "<br/><b>Предупреждение</b>: Это действие удалит все подписки пользователя и отпишет всех от него.";
|
uBanMsgTxt += "<br/><b>Предупреждение</b>: Это действие удалит все подписки пользователя и отпишет всех от него.";
|
||||||
uBanMsgTxt += "<br/><br/><b>Причина бана</b>: <input type='text' id='uBanMsgInput' placeholder='придумайте что-нибудь крутое' />"
|
uBanMsgTxt += "<br/><br/><b>Причина бана</b>: <input type='text' id='uBanMsgInput' placeholder='придумайте что-нибудь крутое' />"
|
||||||
|
uBanMsgTxt += "<br/><br/><b>Заблокировать до</b>: <input type='date' id='uBanMsgDate' />";
|
||||||
|
|
||||||
MessageBox("Забанить " + {$user->getFirstName()}, uBanMsgTxt, ["Подтвердить", "Отмена"], [
|
MessageBox("Забанить " + {$user->getFirstName()}, uBanMsgTxt, ["Подтвердить", "Отмена"], [
|
||||||
(function() {
|
(function() {
|
||||||
res = document.querySelector("#uBanMsgInput").value;
|
res = document.querySelector("#uBanMsgInput").value;
|
||||||
|
date = document.querySelector("#uBanMsgDate").value;
|
||||||
xhr = new XMLHttpRequest();
|
xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", "/admin/ban/" + {$user->getId()} + "?reason=" + res + "&hash=" + {rawurlencode($csrfToken)}, true);
|
xhr.open("GET", "/admin/ban/" + {$user->getId()} + "?reason=" + res + "&date=" + date + "&hash=" + {rawurlencode($csrfToken)}, true);
|
||||||
xhr.onload = (function() {
|
xhr.onload = (function() {
|
||||||
if(xhr.responseText.indexOf("success") === -1)
|
if(xhr.responseText.indexOf("success") === -1)
|
||||||
MessageBox("Ошибка", "Не удалось забанить пользователя...", ["OK"], [Function.noop]);
|
MessageBox("Ошибка", "Не удалось забанить пользователя...", ["OK"], [Function.noop]);
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
<img src="/assets/packages/static/openvk/img/oof.apng" alt="Пользователь заблокирован." style="width: 20%;" />
|
<img src="/assets/packages/static/openvk/img/oof.apng" alt="Пользователь заблокирован." style="width: 20%;" />
|
||||||
<p>
|
<p>
|
||||||
{tr("user_banned", htmlentities($user->getFirstName()))|noescape}<br/>
|
{tr("user_banned", htmlentities($user->getFirstName()))|noescape}<br/>
|
||||||
{_user_banned_comment} <b>{$user->getBanReason()}</b>.
|
{_user_banned_comment} <b>{$user->getBanReason()}</b>.<br/>
|
||||||
|
Пользователь заблокирован до: <b>{$user->getUnbanTime()}</b>
|
||||||
</p>
|
</p>
|
||||||
{if isset($thisUser)}
|
{if isset($thisUser)}
|
||||||
<p n:if="$thisUser->getChandlerUser()->can('access')->model('admin')->whichBelongsTo(NULL) || $thisUser->getChandlerUser()->can('write')->model('openvk\Web\Models\Entities\TicketReply')->whichBelongsTo(0)">
|
<p n:if="$thisUser->getChandlerUser()->can('access')->model('admin')->whichBelongsTo(NULL) || $thisUser->getChandlerUser()->can('write')->model('openvk\Web\Models\Entities\TicketReply')->whichBelongsTo(0)">
|
||||||
|
|
|
@ -65,6 +65,8 @@ routes:
|
||||||
handler: "Auth->verifyEmail"
|
handler: "Auth->verifyEmail"
|
||||||
- url: "/setSID/{slug}"
|
- url: "/setSID/{slug}"
|
||||||
handler: "Auth->su"
|
handler: "Auth->su"
|
||||||
|
- url: "/unban.php"
|
||||||
|
handler: "Auth->unbanThemself"
|
||||||
- url: "/revokeAllTokens"
|
- url: "/revokeAllTokens"
|
||||||
handler: "Auth->revokeAllTokens"
|
handler: "Auth->revokeAllTokens"
|
||||||
- url: "/settings"
|
- url: "/settings"
|
||||||
|
|
|
@ -842,8 +842,13 @@
|
||||||
"banned_header" = "You are banned";
|
"banned_header" = "You are banned";
|
||||||
"banned_alt" = "The user is blocked.";
|
"banned_alt" = "The user is blocked.";
|
||||||
"banned_1" = "Sorry <b>$1</b>, but you have been banned.";
|
"banned_1" = "Sorry <b>$1</b>, but you have been banned.";
|
||||||
"banned_2" = "And the reason for this is simple: <b>$1</b>. Unfortunately, this time we had to block you forever.";
|
"banned_2" = "And the reason for this is simple: <b>$1</b>.";
|
||||||
|
"banned_perm" = "Unfortunately, this time we had to block you forever.";
|
||||||
|
"banned_until_time" = "This time we had to block you until <b>$1</b>";
|
||||||
"banned_3" = "You can still <a href=\"/support?act=new\">write to the support</a> if you think there was an error or <a href=\"/logout?hash=$1\">logout</a>.";
|
"banned_3" = "You can still <a href=\"/support?act=new\">write to the support</a> if you think there was an error or <a href=\"/logout?hash=$1\">logout</a>.";
|
||||||
|
"banned_unban_myself" = "Unban myself";
|
||||||
|
"banned_unban_title" = "Your account has been unbanned";
|
||||||
|
"banned_unban_description" = "Try not to break the rules anymore.";
|
||||||
|
|
||||||
/* Registration confirm */
|
/* Registration confirm */
|
||||||
|
|
||||||
|
|
|
@ -887,8 +887,13 @@
|
||||||
"banned_header" = "Вы были верискокнуты";
|
"banned_header" = "Вы были верискокнуты";
|
||||||
"banned_alt" = "Пользователь заблокирован.";
|
"banned_alt" = "Пользователь заблокирован.";
|
||||||
"banned_1" = "Извините, <b>$1</b>, но вы были верискокнуты.";
|
"banned_1" = "Извините, <b>$1</b>, но вы были верискокнуты.";
|
||||||
"banned_2" = "А причина этому проста: <b>$1</b>. К сожалению, на этот раз нам пришлось заблокировать вас навсегда.";
|
"banned_2" = "А причина этому проста: <b>$1</b>.";
|
||||||
|
"banned_perm" = "К сожалению, на этот раз нам пришлось заблокировать вас навсегда";
|
||||||
|
"banned_until_time" = "На этот раз нам пришлось заблокировать вас до <b>$1</b>";
|
||||||
"banned_3" = "Вы всё ещё можете <a href=\"/support?act=new\">написать в службу поддержки</a>, если считаете что произошла ошибка или <a href=\"/logout?hash=$1\">выйти</a>.";
|
"banned_3" = "Вы всё ещё можете <a href=\"/support?act=new\">написать в службу поддержки</a>, если считаете что произошла ошибка или <a href=\"/logout?hash=$1\">выйти</a>.";
|
||||||
|
"banned_unban_myself" = "Разморозить страницу";
|
||||||
|
"banned_unban_title" = "Ваш аккаунт разблокирован";
|
||||||
|
"banned_unban_description" = "Постарайтесь больше не нарушать правила.";
|
||||||
|
|
||||||
/* Registration confirm */
|
/* Registration confirm */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue