mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +03:00
Groups: Add the ability to write comments on behalf of the group
This commit is contained in:
parent
7591c1082b
commit
021971289d
7 changed files with 33 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
<?php declare(strict_types=1);
|
||||
namespace openvk\Web\Models\Entities;
|
||||
use openvk\Web\Models\Repositories\Clubs;
|
||||
use openvk\Web\Models\RowModel;
|
||||
|
||||
class Comment extends Post
|
||||
{
|
||||
|
@ -24,4 +26,19 @@ class Comment extends Post
|
|||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* May return fake owner (group), if flags are [1, (*)]
|
||||
*
|
||||
* @param bool $honourFlags - check flags
|
||||
*/
|
||||
function getOwner(bool $honourFlags = true, bool $real = false): RowModel
|
||||
{
|
||||
if($honourFlags && $this->isPostedOnBehalfOfGroup()) {
|
||||
if($this->getTarget() instanceof Post)
|
||||
return (new Clubs)->get(abs($this->getTarget()->getTargetWall()));
|
||||
}
|
||||
|
||||
return parent::getOwner($honourFlags, $real);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@ final class CommentPresenter extends OpenVKPresenter
|
|||
$entity = $repo->get($eId);
|
||||
if(!$entity) $this->notFound();
|
||||
|
||||
$flags = 0;
|
||||
if($this->postParam("as_group") === "on")
|
||||
$flags |= 0b10000000;
|
||||
|
||||
$photo = NULL;
|
||||
if($_FILES["_pic_attachment"]["error"] === UPLOAD_ERR_OK) {
|
||||
try {
|
||||
|
@ -75,6 +79,7 @@ final class CommentPresenter extends OpenVKPresenter
|
|||
$comment->setTarget($entity->getId());
|
||||
$comment->setContent($this->postParam("text"));
|
||||
$comment->setCreated(time());
|
||||
$comment->setFlags($flags);
|
||||
$comment->save();
|
||||
|
||||
if(!is_null($photo))
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{var author = $comment->getOwner()}
|
||||
{var $Club = openvk\Web\Models\Entities\Club::class}
|
||||
|
||||
<a name="cid={$comment->getId()}"></a>
|
||||
<table border="0" style="font-size: 11px;" class="post comment" id="_comment{$comment->getId()}" data-comment-id="{$comment->getId()}" data-owner-id="{$author->getId()}">
|
||||
<table border="0" style="font-size: 11px;" class="post comment" id="_comment{$comment->getId()}" data-comment-id="{$comment->getId()}" data-owner-id="{$author->getId()}" data-from-group="{$comment->getOwner() instanceof $Club}">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="30" valign="top">
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
<div n:ifset="$thisUser">
|
||||
{var commentsURL = "/al_comments.pl/create/$model/" . $parent->getId()}
|
||||
{include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti")}
|
||||
{var club = $parent instanceof \openvk\Web\Models\Entities\Post && $parent->getTargetWall() < 0 ? (new openvk\Web\Models\Repositories\Clubs)->get(abs($parent->getTargetWall())) : NULL}
|
||||
{include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club}
|
||||
</div>
|
||||
|
||||
{if sizeof($comments) > 0}
|
||||
|
|
|
@ -42,6 +42,11 @@
|
|||
<input type="checkbox" name="nsfw" /> {_"contains_nsfw"}
|
||||
</label>
|
||||
</div>
|
||||
<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"}
|
||||
</label>
|
||||
</div>
|
||||
<input type="file" class="postFileSel" id="postFilePic" name="_pic_attachment" accept="image/*" style="display:none;" />
|
||||
<input type="file" class="postFileSel" id="postFileVid" name="_vid_attachment" accept="video/*" style="display:none;" />
|
||||
<input type="hidden" name="type" value="1" />
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
|
||||
"attachment" = "Attachment";
|
||||
"post_as_group" = "Post as group";
|
||||
"comment_as_group" = "Comment as group";
|
||||
"add_signature" = "Add signature";
|
||||
/* ^ can be translated as "author's signature". ^ */
|
||||
"contains_nsfw" = "Contains NSFW content";
|
||||
|
|
|
@ -132,6 +132,7 @@
|
|||
|
||||
"attachment" = "Вложение";
|
||||
"post_as_group" = "От имени сообщества";
|
||||
"comment_as_group" = "От имени сообщества";
|
||||
"add_signature" = "Подпись автора";
|
||||
"contains_nsfw" = "Содержит NSFW-контент";
|
||||
"nsfw_warning" = "Данный пост может содержать 18+ контент";
|
||||
|
|
Loading…
Reference in a new issue