Support: Add closing all tickets when banned

slowly getting back on "business"...
Resolves #584
This commit is contained in:
Ilya Prokopenko 2022-07-17 17:50:37 +03:00
parent e2054d72a4
commit 84635a22ba
No known key found for this signature in database
GPG key ID: 7736BBBB05F14A56
2 changed files with 8 additions and 1 deletions

View file

@ -6,6 +6,7 @@ use openvk\Web\Models\Entities\TicketComment;
use openvk\Web\Models\Repositories\TicketComments; use openvk\Web\Models\Repositories\TicketComments;
use openvk\Web\Util\Telegram; use openvk\Web\Util\Telegram;
use Chandler\Session\Session; use Chandler\Session\Session;
use Chandler\Database\DatabaseConnection;
use Parsedown; use Parsedown;
final class SupportPresenter extends OpenVKPresenter final class SupportPresenter extends OpenVKPresenter
@ -322,6 +323,10 @@ final class SupportPresenter extends OpenVKPresenter
$user->setBlock_In_Support_Reason($this->queryParam("reason")); $user->setBlock_In_Support_Reason($this->queryParam("reason"));
$user->save(); $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") ]); $this->returnJson([ "success" => true, "reason" => $this->queryParam("reason") ]);
} }

View file

@ -580,12 +580,14 @@
function toggleBanInSupport() { function toggleBanInSupport() {
uBanMsgTxt = "Вы собираетесь заблокировать в поддержке пользователя " + {$user->getCanonicalName()} + "."; uBanMsgTxt = "Вы собираетесь заблокировать в поддержке пользователя " + {$user->getCanonicalName()} + ".";
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/><input type='checkbox' id='uBanClsTicketsInput' /><label for='uBanClsTicketsInput'>Закрыть все обращения пользователя</label>";
MessageBox("Заблокировать в поддержке " + {$user->getFirstName()}, uBanMsgTxt, ["Подтвердить", "Отмена"], [ MessageBox("Заблокировать в поддержке " + {$user->getFirstName()}, uBanMsgTxt, ["Подтвердить", "Отмена"], [
(function() { (function() {
res = document.querySelector("#uBanMsgInput").value; res = document.querySelector("#uBanMsgInput").value;
cls = document.querySelector("#uBanClsTicketsInput").value;
xhr = new XMLHttpRequest(); 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() { xhr.onload = (function() {
if(xhr.responseText.indexOf("success") === -1) if(xhr.responseText.indexOf("success") === -1)
MessageBox("Ошибка", "Не удалось заблокировать пользователя в поддержке...", ["OK"], [Function.noop]); MessageBox("Ошибка", "Не удалось заблокировать пользователя в поддержке...", ["OK"], [Function.noop]);