Support: Fix deleting tickets

This commit is contained in:
Maxim Leshchenko 2021-12-10 17:17:01 +02:00
parent 763c0c91e2
commit 2af7dcc4f4
No known key found for this signature in database
GPG key ID: BB9C44A8733FBEEE

View file

@ -116,15 +116,18 @@ final class SupportPresenter extends OpenVKPresenter
{ {
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
if (!empty($id)) {
if(!empty($id)) {
$ticket = $this->tickets->get($id); $ticket = $this->tickets->get($id);
if (!$ticket || $ticket->isDeleted() != 0 || $ticket->authorId() !== $this->user->id) if(!$ticket || $ticket->isDeleted() != 0 || $ticket->authorId() !== $this->user->id && !$this->hasPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0)) {
{
$this->notFound(); $this->notFound();
} else { } else {
$ticket->delete();
header("HTTP/1.1 302 Found"); header("HTTP/1.1 302 Found");
if($ticket->authorId() !== $this->user->id && $this->hasPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0))
header("Location: /support/tickets");
else
header("Location: /support"); header("Location: /support");
$ticket->delete();
} }
} }
} }