mirror of
https://github.com/openvk/openvk
synced 2025-07-07 16:29:50 +03:00
isLikedByUser
This commit is contained in:
parent
8765d54578
commit
ca0fe71774
7 changed files with 35 additions and 28 deletions
|
@ -113,5 +113,18 @@ class TicketComment extends RowModel
|
|||
return $this->getRecord()->mark;
|
||||
}
|
||||
|
||||
function isLikedByUser(): ?bool
|
||||
{
|
||||
$mark = $this->getMark();
|
||||
|
||||
if($mark === 0) {
|
||||
return false;
|
||||
} elseif ($mark === 1) {
|
||||
return true;
|
||||
} elseif ($mark === null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
use Traits\TRichText;
|
||||
}
|
||||
|
|
|
@ -232,24 +232,18 @@ final class SupportPresenter extends OpenVKPresenter
|
|||
$this->assertUserLoggedIn();
|
||||
|
||||
$comment = $this->comments->get($id);
|
||||
|
||||
if($this->user->id === $this->tickets->get($comment->getTicketId())->getUser()->getId()) {
|
||||
if($mark === 1 || $mark === 2) {}
|
||||
$comments->setMark($mark);
|
||||
$comments->save();
|
||||
if($mark === 1) {
|
||||
// $this->flashFail("succ", tr("information_-1"), tr("support_rated_good"));
|
||||
exit(header("HTTP/1.1 200 OK"));
|
||||
} elseif($mark === 2) {
|
||||
// $this->flashFail("succ", tr("information_-1"), tr("support_rated_bad"));
|
||||
exit(header("HTTP/1.1 200 OK"));
|
||||
}
|
||||
} else {
|
||||
// $this->flashFail("err", tr("error"), tr("wrong_parameters"));
|
||||
$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 {
|
||||
// $this->flashFail("err", tr("error"), tr("forbidden"));
|
||||
exit(header("HTTP/1.1 403 Forbidden"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -110,12 +110,12 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
{if $comment->getUType() === 1 && $comment->getMark() != null}}
|
||||
{if $comment->getUType() === 1}
|
||||
<div class="post-menu">
|
||||
<strong>
|
||||
{if $comment->getMark() === 1}
|
||||
{if $comment->isLikedByUser() === true}
|
||||
{_support_good_answer_agent}
|
||||
{elseif $comment->getMark() === 2}
|
||||
{elseif $comment->isLikedByUser() === false}
|
||||
{_support_bad_answer_agent}
|
||||
{/if}
|
||||
</strong>
|
||||
|
|
|
@ -118,16 +118,16 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
{if $comment->getUType() === 1 && $comment->getMark() != null}}
|
||||
{if $comment->getUType() === 1}
|
||||
<div class="post-menu">
|
||||
<strong id="markText-{$comment->getId()}">
|
||||
{if $comment->getMark() === 1}
|
||||
{if $comment->isLikedByUser() === true}
|
||||
{_support_good_answer_user}
|
||||
{elseif $comment->getMark() === 2}
|
||||
{elseif $comment->isLikedByUser() === false}
|
||||
{_support_bad_answer_user}
|
||||
{/if}
|
||||
</strong>
|
||||
{if $comment->getMark() === 0}
|
||||
{if $comment->isLikedByUser() === null}
|
||||
<a onClick="markAnswer({$comment->getId()}, 1)">{_support_rate_good_answer}</a>
|
||||
|
|
||||
<a onClick="markAnswer({$comment->getId()}, 2)">{_support_rate_bad_answer}</a>
|
||||
|
|
|
@ -18,7 +18,7 @@ routes:
|
|||
- url: "/support/view/{num}"
|
||||
handler: "Support->view"
|
||||
- url: "/support/comment/{num}/rate/{num}"
|
||||
handler: "Support->RateAnswer"
|
||||
handler: "Support->rateAnswer"
|
||||
- url: "/al_comments.pl/create/support/{num}"
|
||||
handler: "Support->makeComment"
|
||||
- url: "/al_comments.pl/create/support/reply/{num}"
|
||||
|
|
|
@ -1 +1 @@
|
|||
ALTER TABLE `tickets_comments` ADD `mark` TINYINT NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `tickets_comments` ADD `mark` BOOLEAN NULL DEFAULT NULL;
|
|
@ -554,12 +554,12 @@
|
|||
|
||||
"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_user" = "You left a positive feedback.";
|
||||
"support_bad_answer_user" = "You 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.";
|
||||
"support_rated_good" = "You left a positive feedback about the answer.";
|
||||
"support_rated_bad" = "You left a negative feedback about the answer.";
|
||||
"wrong_parameters" = "Invalid request parameters.";
|
||||
|
||||
"comment" = "Comment";
|
||||
|
|
Loading…
Reference in a new issue