From 84635a22ba45e79d9f170f69151866e1b2c9e12c Mon Sep 17 00:00:00 2001 From: Ilya Prokopenko Date: Sun, 17 Jul 2022 17:50:37 +0300 Subject: [PATCH] Support: Add closing all tickets when banned slowly getting back on "business"... Resolves #584 --- Web/Presenters/SupportPresenter.php | 5 +++++ Web/Presenters/templates/User/View.xml | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Web/Presenters/SupportPresenter.php b/Web/Presenters/SupportPresenter.php index b8d197d6..92859bb6 100644 --- a/Web/Presenters/SupportPresenter.php +++ b/Web/Presenters/SupportPresenter.php @@ -6,6 +6,7 @@ use openvk\Web\Models\Entities\TicketComment; use openvk\Web\Models\Repositories\TicketComments; use openvk\Web\Util\Telegram; use Chandler\Session\Session; +use Chandler\Database\DatabaseConnection; use Parsedown; final class SupportPresenter extends OpenVKPresenter @@ -322,6 +323,10 @@ final class SupportPresenter extends OpenVKPresenter $user->setBlock_In_Support_Reason($this->queryParam("reason")); $user->save(); + + if($this->queryParam("close_tickets")) + DatabaseConnection::i()->getConnection()->query("UPDATE tickets SET type = 2 WHERE user_id = ".$id); + $this->returnJson([ "success" => true, "reason" => $this->queryParam("reason") ]); } diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index c0d92e7a..2f2d0794 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -580,12 +580,14 @@ function toggleBanInSupport() { uBanMsgTxt = "Вы собираетесь заблокировать в поддержке пользователя " + {$user->getCanonicalName()} + "."; uBanMsgTxt += "

Причина бана: "; + uBanMsgTxt += "

"; MessageBox("Заблокировать в поддержке " + {$user->getFirstName()}, uBanMsgTxt, ["Подтвердить", "Отмена"], [ (function() { res = document.querySelector("#uBanMsgInput").value; + cls = document.querySelector("#uBanClsTicketsInput").value; xhr = new XMLHttpRequest(); - xhr.open("GET", "/admin/support/ban/" + {$user->getId()} + "?reason=" + res + "&hash=" + {rawurlencode($csrfToken)}, true); + xhr.open("GET", "/admin/support/ban/" + {$user->getId()} + "?reason=" + res + "&close_tickets=" + cls + "&hash=" + {rawurlencode($csrfToken)}, true); xhr.onload = (function() { if(xhr.responseText.indexOf("success") === -1) MessageBox("Ошибка", "Не удалось заблокировать пользователя в поддержке...", ["OK"], [Function.noop]);