mirror of
https://github.com/openvk/openvk
synced 2024-12-23 09:01:15 +03:00
Merge branch 'master' of github.com:openvk/openvk
This commit is contained in:
commit
534265bb3a
11 changed files with 63 additions and 20 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 {
|
||||
|
@ -69,13 +73,18 @@ final class CommentPresenter extends OpenVKPresenter
|
|||
if(empty($this->postParam("text")) && !$photo && !$video)
|
||||
$this->flashFail("err", "Не удалось опубликовать комментарий", "Комментарий пустой или слишком большой.");
|
||||
|
||||
try {
|
||||
$comment = new Comment;
|
||||
$comment->setOwner($this->user->id);
|
||||
$comment->setModel(get_class($entity));
|
||||
$comment->setTarget($entity->getId());
|
||||
$comment->setContent($this->postParam("text"));
|
||||
$comment->setCreated(time());
|
||||
$comment->setFlags($flags);
|
||||
$comment->save();
|
||||
} catch (\LengthException $ex) {
|
||||
$this->flashFail("err", "Не удалось опубликовать комментарий", "Комментарий слишком большой.");
|
||||
}
|
||||
|
||||
if(!is_null($photo))
|
||||
$comment->attach($photo);
|
||||
|
|
|
@ -208,6 +208,8 @@ abstract class OpenVKPresenter extends SimplePresenter
|
|||
}
|
||||
|
||||
$this->template->ticketAnsweredCount = (new Tickets)->getTicketsCountByuId($this->user->id, 1);
|
||||
if($user->can("write")->model('openvk\Web\Models\Entities\TicketReply')->whichBelongsTo(0))
|
||||
$this->template->helpdeskTicketAnsweredCount = (new Tickets)->getTicketCount(0);
|
||||
}
|
||||
|
||||
setlocale(LC_TIME, ...(explode(";", tr("__locale"))));
|
||||
|
|
|
@ -172,7 +172,11 @@
|
|||
<a href="/admin" class="link">Админ-панель</a>
|
||||
{/if}
|
||||
{if $canAccessHelpdesk}
|
||||
<a href="/support/tickets" class="link">Helpdesk</a>
|
||||
<a href="/support/tickets" class="link">Helpdesk
|
||||
{if $helpdeskTicketAnsweredCount > 0}
|
||||
(<b>{$helpdeskTicketAnsweredCount}</b>)
|
||||
{/if}
|
||||
</a>
|
||||
{/if}
|
||||
<a
|
||||
n:foreach="OPENVK_ROOT_CONF['openvk']['preferences']['menu']['links'] as $menuItem"
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
"count" => $count,
|
||||
"amount" => sizeof($gifts),
|
||||
"perPage" => OPENVK_DEFAULT_PER_PAGE,
|
||||
"atBottom" => true,
|
||||
]}
|
||||
</div>
|
||||
{/block}
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -3,7 +3,10 @@ u(".comment-reply").on("click", function(e) {
|
|||
let comment = u(e.target).closest(".post");
|
||||
let authorId = comment.data("owner-id");
|
||||
let authorNm = u(".post-author > a > b", comment.first()).text().trim();
|
||||
let fromGroup = Boolean(comment.data("from-group"));
|
||||
let postId = comment.data("post-id");
|
||||
console.log(postId)
|
||||
|
||||
inputbox.text("[id" + authorId + "|" + authorNm + "], ");
|
||||
inputbox.text("[" + (fromGroup ? "club" : "id") + authorId + "|" + authorNm + "], ");
|
||||
inputbox.trigger("focusin");
|
||||
});
|
||||
|
|
|
@ -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