diff --git a/Web/Models/Entities/TicketComment.php b/Web/Models/Entities/TicketComment.php index 1f54fa92..36d21d8e 100644 --- a/Web/Models/Entities/TicketComment.php +++ b/Web/Models/Entities/TicketComment.php @@ -108,7 +108,7 @@ class TicketComment extends RowModel return false; # Кооостыыыль!!! } - function getMark(): int + function getMark(): ?int { return $this->getRecord()->mark; } diff --git a/Web/Models/Repositories/TicketComments.php b/Web/Models/Repositories/TicketComments.php index af5d8029..6201089c 100644 --- a/Web/Models/Repositories/TicketComments.php +++ b/Web/Models/Repositories/TicketComments.php @@ -49,7 +49,7 @@ class TicketComments // return $this->toTicket($this->tickets->get($id)); // } - function get(int $id): TicketComment + function get(int $id): ?TicketComment { $comment = $this->comments->where(['id' => $id])->fetch(); if (!is_null($comment)) diff --git a/Web/Presenters/SupportPresenter.php b/Web/Presenters/SupportPresenter.php index 683a9597..6ecd9150 100644 --- a/Web/Presenters/SupportPresenter.php +++ b/Web/Presenters/SupportPresenter.php @@ -233,17 +233,15 @@ final class SupportPresenter extends OpenVKPresenter $comment = $this->comments->get($id); - if($this->user->id === $this->tickets->get($comment->getTicketId())->getUser()->getId()) { - $comments->setMark($mark); - $comments->save(); - - if($mark === 1 || $mark === 2) { - exit(header("HTTP/1.1 200 OK")); - } else { - exit(header("HTTP/1.1 400 Bad Request")); - } - } else { + if($this->user->id !== $this->tickets->get($comment->getTicketId())->getUser()->getId()) exit(header("HTTP/1.1 403 Forbidden")); - } + + if($mark === 1 || $mark === 2) + header("HTTP/1.1 200 OK"); + else + exit(header("HTTP/1.1 400 Bad Request")); + + $comment->setMark($mark); + $comment->save(); } } \ No newline at end of file