diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 64b689e4..c4888d75 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -214,6 +214,11 @@ class User extends RowModel { return $this->getRecord()->block_reason; } + + function getBanInSupportReason(): ?string + { + return $this->getRecord()->block_in_support_reason; + } function getType(): int { @@ -673,6 +678,11 @@ class User extends RowModel { return !is_null($this->getBanReason()); } + + function isBannedInSupport(): bool + { + return !is_null($this->getBanInSupportReason()); + } function isOnline(): bool { diff --git a/Web/Presenters/SupportPresenter.php b/Web/Presenters/SupportPresenter.php index a96ac465..9c2bcc8e 100644 --- a/Web/Presenters/SupportPresenter.php +++ b/Web/Presenters/SupportPresenter.php @@ -1,7 +1,7 @@ template->tickets = $this->tickets->getTicketsByUserId($this->user->id, $this->template->page); } + if($this->template->mode === "new") + $this->template->banReason = $this->user->identity->getBanInSupportReason(); + if($_SERVER["REQUEST_METHOD"] === "POST") { + if($this->user->identity->isBannedInSupport()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + if(!empty($this->postParam("name")) && !empty($this->postParam("text"))) { $this->willExecuteWriteAction(); @@ -268,4 +274,32 @@ final class SupportPresenter extends OpenVKPresenter exit(header("HTTP/1.1 200 OK")); } -} \ No newline at end of file + + function renderQuickBanInSupport(int $id): void + { + $this->assertPermission("openvk\Web\Models\Entities\TicketReply", "write", 0); + $this->assertNoCSRF(); + + $user = (new Users)->get($id); + if(!$user) + exit(json_encode([ "error" => "User does not exist" ])); + + $user->setBlock_In_Support_Reason($this->queryParam("reason")); + $user->save(); + $this->returnJson([ "success" => true, "reason" => $this->queryParam("reason") ]); + } + + function renderQuickUnbanInSupport(int $id): void + { + $this->assertPermission("openvk\Web\Models\Entities\TicketReply", "write", 0); + $this->assertNoCSRF(); + + $user = (new Users)->get($id); + if(!$user) + exit(json_encode([ "error" => "User does not exist" ])); + + $user->setBlock_In_Support_Reason(null); + $user->save(); + $this->returnJson([ "success" => true ]); + } +} diff --git a/Web/Presenters/templates/Support/Index.xml b/Web/Presenters/templates/Support/Index.xml index 8f0f8737..133cf073 100644 --- a/Web/Presenters/templates/Support/Index.xml +++ b/Web/Presenters/templates/Support/Index.xml @@ -26,16 +26,26 @@
{if $isNew} -
-
-
-

-

- -

-
-
-
+ {if !is_null($banReason)} +
+ {_'banned_alt'} +
+

+ {tr("banned_in_support_1", htmlentities($thisUser->getCanonicalName()))|noescape}
+ {tr("banned_in_support_2", htmlentities($banReason))|noescape} +

+ {else} +
+
+
+

+

+ +

+
+
+
+ {/if} {/if} {/if} diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index f421925c..c9457cba 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -93,6 +93,16 @@ {_warn_user_action} {/if} + + {if $thisUser->getChandlerUser()->can('write')->model('openvk\Web\Models\Entities\TicketReply')->whichBelongsTo(0)} + + {if $user->isBannedInSupport()} + {_unban_in_support_user_action} + {else} + {_ban_in_support_user_action} + {/if} + + {/if} {_send_gift} {_"send_message"} @@ -526,7 +536,7 @@ function warnUser() { uBanMsgTxt = "Вы собираетесь предупредить пользователя " + {$user->getCanonicalName()} + "."; uBanMsgTxt += "
Мы отправим уведомление пользователю в личные сообщения от имени аккаунта администратора."; - uBanMsgTxt += "

Текст предупреждения: " + uBanMsgTxt += "

Текст предупреждения: "; MessageBox("Выдать предупреждение " + {$user->getFirstName()}, uBanMsgTxt, ["Подтвердить", "Отмена"], [ (function() { @@ -546,6 +556,51 @@ } + +