From 7f46d683c3d086e04ed97b5d9bf243a94ef27443 Mon Sep 17 00:00:00 2001 From: n1rwana Date: Fri, 11 Aug 2023 02:11:40 +0300 Subject: [PATCH] Support: Give users the ability to close tickets themselves (#925) * User can close ticket (#879) * Localization * Update SupportPresenter.php * Update View.xml --- Web/Presenters/SupportPresenter.php | 24 ++++++++++++++++++++-- Web/Presenters/templates/Support/Agent.xml | 3 +-- Web/Presenters/templates/Support/List.xml | 2 +- Web/Presenters/templates/Support/View.xml | 13 ++++++++++++ Web/routes.yml | 2 ++ locales/en.strings | 7 +++++++ locales/ru.strings | 6 ++++++ 7 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Web/Presenters/SupportPresenter.php b/Web/Presenters/SupportPresenter.php index c4d729ea..8163dbf8 100644 --- a/Web/Presenters/SupportPresenter.php +++ b/Web/Presenters/SupportPresenter.php @@ -385,7 +385,7 @@ final class SupportPresenter extends OpenVKPresenter $agent->setNumerate((int) $this->postParam("number") ?? NULL); $agent->setIcon($this->postParam("avatar")); $agent->save(); - $this->flashFail("succ", "Успех", "Профиль отредактирован."); + $this->flashFail("succ", tr("agent_profile_edited")); } else { $agent = new SupportAgent; $agent->setAgent($this->user->identity->getId()); @@ -393,7 +393,27 @@ final class SupportPresenter extends OpenVKPresenter $agent->setNumerate((int) $this->postParam("number") ?? NULL); $agent->setIcon($this->postParam("avatar")); $agent->save(); - $this->flashFail("succ", "Успех", "Профиль создан. Теперь пользователи видят Ваши псевдоним и аватарку вместо стандартных аватарки и номера."); + $this->flashFail("succ", tr("agent_profile_created_1"), tr("agent_profile_created_2")); } } + + function renderCloseTicket(int $id): void + { + $this->assertUserLoggedIn(); + $this->assertNoCSRF(); + $this->willExecuteWriteAction(); + + $ticket = $this->tickets->get($id); + + if($ticket->isDeleted() === 1 || $ticket->getType() === 2 || $ticket->getUserId() !== $this->user->id) { + header("HTTP/1.1 403 Forbidden"); + header("Location: /support/view/" . $id); + exit; + } + + $ticket->setType(2); + $ticket->save(); + + $this->flashFail("succ", tr("ticket_changed"), tr("ticket_changed_comment")); + } } diff --git a/Web/Presenters/templates/Support/Agent.xml b/Web/Presenters/templates/Support/Agent.xml index 987fb081..a229d763 100644 --- a/Web/Presenters/templates/Support/Agent.xml +++ b/Web/Presenters/templates/Support/Agent.xml @@ -55,7 +55,6 @@

- {$agent->isShowNumber()}