Anonymous comments

This commit is contained in:
n1rwana 2022-12-06 19:18:20 +03:00
parent c77f8fdb49
commit 340920cfd3
3 changed files with 10 additions and 3 deletions

View file

@ -48,6 +48,8 @@ final class CommentPresenter extends OpenVKPresenter
else if($entity instanceof Topic)
$club = $entity->getClub();
$anon = OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["enable"] && $this->postParam("anon") === "on";
$flags = 0;
if($this->postParam("as_group") === "on" && !is_null($club) && $club->canBeModifiedBy($this->user->identity))
$flags |= 0b10000000;
@ -89,9 +91,10 @@ final class CommentPresenter extends OpenVKPresenter
$comment->setModel(get_class($entity));
$comment->setTarget($entity->getId());
$comment->setContent($this->postParam("text"));
$comment->setAnonymous($anon);
$comment->setCreated(time());
$comment->setFlags($flags);
$comment->save();
$comment->save();
} catch (\LengthException $ex) {
$this->flashFail("err", "Не удалось опубликовать комментарий", "Комментарий слишком большой.");
}

View file

@ -4,7 +4,7 @@
{var $commentsURL = "/al_comments/create/$model/" . $parent->getId()}
{var $club = $parent instanceof \openvk\Web\Models\Entities\Post && $parent->getTargetWall() < 0 ? (new openvk\Web\Models\Repositories\Clubs)->get(abs($parent->getTargetWall())) : $club}
{if !$readOnly}
{include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club}
{include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club, isComment => true}
{/if}
</div>

View file

@ -14,8 +14,8 @@
<div class="post-has-poll">
{_poll}
</div>
{var $anonEnabled = OPENVK_ROOT_CONF['openvk']['preferences']['wall']['anonymousPosting']['enable']}
<div n:if="$postOpts ?? true" class="post-opts">
{var $anonEnabled = OPENVK_ROOT_CONF['openvk']['preferences']['wall']['anonymousPosting']['enable']}
{if !is_null($thisUser) && !is_null($club ?? NULL) && $owner < 0}
{if $club->canBeModifiedBy($thisUser)}
<script>
@ -46,6 +46,10 @@
</label>
</div>
<label n:if="$isComment && $anonEnabled" id="octoberAnonOpt">
<input type="checkbox" name="anon" /> {_as_anonymous}
</label>
<div n:if="!($postOpts ?? true) && !is_null($thisUser) && !is_null($club ?? NULL) && $club->canBeModifiedBy($thisUser)" class="post-opts">
<label>
<input type="checkbox" name="as_group" /> {_comment_as_group}