mirror of
https://github.com/openvk/openvk
synced 2025-07-07 08:19:49 +03:00
IF(s) fixed + AJAX 2.0 :D
This commit is contained in:
parent
bcdb62675f
commit
5c402c5479
3 changed files with 39 additions and 25 deletions
|
@ -232,20 +232,24 @@ final class SupportPresenter extends OpenVKPresenter
|
||||||
$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()) {
|
||||||
if ($mark === 1 || $mark === 2) {}
|
if($mark === 1 || $mark === 2) {}
|
||||||
$comments->setMark($mark);
|
$comments->setMark($mark);
|
||||||
$comments->save();
|
$comments->save();
|
||||||
if ($mark === 1) {
|
if($mark === 1) {
|
||||||
$this->flashFail("succ", tr("information_-1"), tr("support_rated_good"));
|
// $this->flashFail("succ", tr("information_-1"), tr("support_rated_good"));
|
||||||
} elseif ($mark === 2) {
|
exit(header("HTTP/1.1 200 OK"));
|
||||||
$this->flashFail("succ", tr("information_-1"), tr("support_rated_bad"));
|
} elseif($mark === 2) {
|
||||||
|
// $this->flashFail("succ", tr("information_-1"), tr("support_rated_bad"));
|
||||||
|
exit(header("HTTP/1.1 200 OK"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->flashFail("err", tr("error"), tr("wrong_parameters"));
|
// $this->flashFail("err", tr("error"), tr("wrong_parameters"));
|
||||||
|
exit(header("HTTP/1.1 400 Bad Request"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->flashFail("err", tr("error"), tr("forbidden"));
|
// $this->flashFail("err", tr("error"), tr("forbidden"));
|
||||||
|
exit(header("HTTP/1.1 403 Forbidden"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,15 +110,13 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{if $comment->getUType() === 1}
|
{if $comment->getUType() === 1 && $comment->getMark() != null}}
|
||||||
<div class="post-menu">
|
<div class="post-menu">
|
||||||
<strong>
|
<strong>
|
||||||
{if $comment->getMark() != null}
|
{if $comment->getMark() === 1}
|
||||||
{if $comment->getMark() === 1}
|
|
||||||
{_support_good_answer_agent}
|
{_support_good_answer_agent}
|
||||||
{elseif $comment->getMark() === 2}
|
{elseif $comment->getMark() === 2}
|
||||||
{_support_bad_answer_agent}
|
{_support_bad_answer_agent}
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
</strong>
|
</strong>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,14 +6,26 @@
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block content}
|
{block content}
|
||||||
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||||
<script>
|
<script>
|
||||||
function markAnswer(id, mark) {
|
function markAnswer(id, mark) {
|
||||||
xhr = new XMLHttpRequest();
|
let url = "/support/comment/" + id + "/rate/" + mark;
|
||||||
xhr.open("POST", "/support/comment/" + id + "/rate/" + mark);
|
$.ajax(url, {
|
||||||
xhr.send();
|
error: errorHandler,
|
||||||
|
success: success(id, mark)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
location.reload();
|
function success(id, mark) {
|
||||||
return false;
|
if(mark == 1) {
|
||||||
|
document.getElementById("markText-" + id).innerHTML = {_support_good_answer_user};
|
||||||
|
} else {
|
||||||
|
document.getElementById("markText-" + id).innerHTML = {_support_bad_answer_user};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function errorHandler(id, mark) {
|
||||||
|
document.getElementById("markText" + id).innerHTML = {_error};
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{if $ticket->isDeleted() == 0 }
|
{if $ticket->isDeleted() == 0 }
|
||||||
|
@ -107,20 +119,20 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{if $comment->getUType() === 1}
|
{if $comment->getUType() === 1 && $comment->getMark() != null}}
|
||||||
<div class="post-menu">
|
<div class="post-menu">
|
||||||
{if $comment->getMark() != null}
|
<strong id="markText-{$comment->getId()}">
|
||||||
<strong>
|
|
||||||
{if $comment->getMark() === 1}
|
{if $comment->getMark() === 1}
|
||||||
{_support_good_answer_user}
|
{_support_good_answer_user}
|
||||||
{elseif $comment->getMark() === 2}
|
{elseif $comment->getMark() === 2}
|
||||||
{_support_bad_answer_user}
|
{_support_bad_answer_user}
|
||||||
{/if}
|
{/if}
|
||||||
</strong>
|
</strong>
|
||||||
{else}
|
{if $comment->getMark() === 0}
|
||||||
<a onClick="markAnswer({$comment->getId()}, 1)">{_support_rate_good_answer}</a>
|
<a onClick="markAnswer({$comment->getId()}, 1)">{_support_rate_good_answer}</a>
|
||||||
|
|
|
|
||||||
<a onClick="markAnswer({$comment->getId()}, 2)">{_support_rate_bad_answer}</a>
|
<a onClick="markAnswer({$comment->getId()}, 2)">{_support_rate_bad_answer}</a>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in a new issue