Fixes + english localization

This commit is contained in:
n1rwana 2021-12-13 00:21:42 +03:00
parent fead54dfb6
commit f8f0bbc8cb
7 changed files with 67 additions and 60 deletions

View file

@ -49,12 +49,11 @@ class TicketComments
// return $this->toTicket($this->tickets->get($id)); // return $this->toTicket($this->tickets->get($id));
// } // }
// We can get comment by it's ID using this function
function get(int $id): TicketComment function get(int $id): TicketComment
{ {
$comm = $this->comments->where(['id' => $id])->fetch(); $comment = $this->comments->where(['id' => $id])->fetch();
if (!is_null($comm)) if (!is_null($comment))
return new TicketComment($comm); return new TicketComment($comment);
else else
return null; return null;
} }

View file

@ -226,35 +226,26 @@ final class SupportPresenter extends OpenVKPresenter
$this->template->content = $parser->parse($content); $this->template->content = $parser->parse($content);
} }
function renderRateAnswerGood(int $id): void function renderRateAnswer(int $id, int $mark): void
{ {
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$comment = $this->comments->get($id); $comment = $this->comments->get($id);
if ($this->user->id === $this->tickets->get($comment->getTicketId()->getUser()->getId())) { if ($this->user->id === $this->tickets->get($comment->getTicketId())->getUser()->getId()) {
$comment->setMark(1); if ($mark === 1 || $mark === 2) {}
$comment->save(); $comments->setMark($mark);
$comments->save();
$this->flashFail("succ", "Успешно", "Вы оставили положительный отзыв об ответе"); if ($mark === 1) {
} else { $this->flashFail("succ", tr("information_-1"), tr("support_rated_good"));
$this->flashFail("err", "Ошибка", "Ошибка доступа"); } elseif ($mark === 2) {
$this->flashFail("succ", tr("information_-1"), tr("support_rated_bad"));
} }
}
function renderRateAnswerBad(int $id): void
{
$this->willExecuteWriteAction();
$this->assertUserLoggedIn();
$comment = $this->comments->get($id);
if ($this->user->id === $this->tickets->get($comment->getTicketId()->getUser()->getId())) {
$comment->setMark(2);
$comment->save();
$this->flashFail("succ", "Успешно", "Вы оставили положительный отзыв об ответе");
} else { } else {
$this->flashFail("err", "Ошибка", "Ошибка доступа"); $this->flashFail("err", tr("error"), tr("wrong_parameters"));
}
} else {
$this->flashFail("err", tr("error"), tr("forbidden"));
} }
} }
} }

View file

@ -109,17 +109,20 @@
<a href="/support/comment/{$comment->getId()}/delete">{_delete}</a> <a href="/support/comment/{$comment->getId()}/delete">{_delete}</a>
</div> </div>
{/if} {/if}
{elseif $comment->getUType() === 1}
{if $comment->getUType() === 1}
<div class="post-menu">
<strong>
{if $comment->getMark() != null}
{if $comment->getMark() === 1} {if $comment->getMark() === 1}
<div class="post-menu"> {_support_good_answer_agent}
<strong>{_support_good_answer_agent}</strong>
</div>
{elseif $comment->getMark() === 2} {elseif $comment->getMark() === 2}
<div class="post-menu"> {_support_bad_answer_agent}
<strong>{_support_bad_answer_agent}</strong>
</div>
{/if} {/if}
{/if} {/if}
</strong>
</div>
{/if}
</div> </div>
</td> </td>
</tr> </tr>

View file

@ -90,25 +90,28 @@
{$comment->getText()|noescape} {$comment->getText()|noescape}
{/if} {/if}
</div> </div>
{if $comment->getUType() === 0} {if $comment->getUType() === 0}
<div class="post-menu"> <div class="post-menu">
<a href="/support/comment/{$comment->getId()}/delete">{_delete}</a> <a href="/support/comment/{$comment->getId()}/delete">{_delete}</a>
</div> </div>
{/if} {/if}
{if $comment->getUType() === 1 && $comment->getMark() === 0} {if $comment->getUType() === 1}
<div class="post-menu"> <div class="post-menu">
<a href="/support/comment/{$comment->getId()}/rateGood">{_support_rate_good_answer}}</a> {if $comment->getMark() != null}
| <strong>
<a href="/support/comment/{$comment->getId()}/rateBad">{_support_rate_bad_answer}}</a> {if $comment->getMark() === 1}
</div> {_support_good_answer_user}
{elseif $comment->getMark() === 1}
<div class="post-menu">
<strong>{_support_good_answer_user}</strong>
</div>
{elseif $comment->getMark() === 2} {elseif $comment->getMark() === 2}
<div class="post-menu"> {_support_bad_answer_user}
<strong>{_support_bad_answer_user}</strong> {/if}
</strong>
{else}
<a href="/support/comment/{$comment->getId()}/rate/1">{_support_rate_good_answer}</a>
|
<a href="/support/comment/{$comment->getId()}/rate/2">{_support_rate_bad_answer}</a>
{/if}
</div> </div>
{/if} {/if}
</div> </div>

View file

@ -17,10 +17,8 @@ routes:
handler: "Support->AnswerTicket" handler: "Support->AnswerTicket"
- url: "/support/view/{num}" - url: "/support/view/{num}"
handler: "Support->view" handler: "Support->view"
- url: "/support/comment/{num}/rateGood" - url: "/support/comment/{num}/rate/{num}"
handler: "Support->RateAnswerGood" handler: "Support->RateAnswer"
- url: "/support/comment/{num}/rateBad"
handler: "Support->RateAnswerBad"
- url: "/al_comments.pl/create/support/{num}" - url: "/al_comments.pl/create/support/{num}"
handler: "Support->makeComment" handler: "Support->makeComment"
- url: "/al_comments.pl/create/support/reply/{num}" - url: "/al_comments.pl/create/support/reply/{num}"

View file

@ -552,6 +552,16 @@
"support_new_title" = "Enter the topic of your ticket"; "support_new_title" = "Enter the topic of your ticket";
"support_new_content" = "Describe the issue or suggestion"; "support_new_content" = "Describe the issue or suggestion";
"support_rate_good_answer" = "This is good answer";
"support_rate_bad_answer" = "This is bad answer";
"support_good_answer_user" = "You have left a positive feedback.";
"support_bad_answer_user" = "You have left a negative feedback.";
"support_good_answer_agent" = "User left a positive feedback.";
"support_bad_answer_agent" = "User left a negative feedback.";
"support_rated_good" = "You have left a positive feedback about the answer.";
"support_rated_bad" = "You have left a negative feedback about the answer.";
"wrong_parameters" = "Неверные параметры запроса.";
"comment" = "Comment"; "comment" = "Comment";
"sender" = "Sender"; "sender" = "Sender";

View file

@ -583,6 +583,9 @@
"support_bad_answer_user" = "Вы оставили негативный отзыв."; "support_bad_answer_user" = "Вы оставили негативный отзыв.";
"support_good_answer_agent" = "Пользователь оставил положительный отзыв"; "support_good_answer_agent" = "Пользователь оставил положительный отзыв";
"support_bad_answer_agent" = "Пользователь оставил негативный отзыв"; "support_bad_answer_agent" = "Пользователь оставил негативный отзыв";
"support_rated_good" = "Вы оставили положительный отзыв об ответе.";
"support_rated_bad" = "Вы оставили негативный отзыв об ответе.";
"wrong_parameters" = "Неверные параметры запроса.";
"comment" = "Комментарий"; "comment" = "Комментарий";
"sender" = "Отправитель"; "sender" = "Отправитель";