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->willExecuteWriteAction();
if(!empty($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();
} else {
$ticket->delete();
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");
$ticket->delete();
}
}
}