diff --git a/Web/Models/Entities/Comment.php b/Web/Models/Entities/Comment.php index ebbfccc3..1afd0126 100644 --- a/Web/Models/Entities/Comment.php +++ b/Web/Models/Entities/Comment.php @@ -1,5 +1,7 @@ isPostedOnBehalfOfGroup()) { + if($this->getTarget() instanceof Post) + return (new Clubs)->get(abs($this->getTarget()->getTargetWall())); + } + + return parent::getOwner($honourFlags, $real); + } } diff --git a/Web/Presenters/CommentPresenter.php b/Web/Presenters/CommentPresenter.php index eef84b6d..90be5222 100644 --- a/Web/Presenters/CommentPresenter.php +++ b/Web/Presenters/CommentPresenter.php @@ -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", "Не удалось опубликовать комментарий", "Комментарий пустой или слишком большой."); - $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->save(); + 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); diff --git a/Web/Presenters/OpenVKPresenter.php b/Web/Presenters/OpenVKPresenter.php index d53b23c8..93675004 100755 --- a/Web/Presenters/OpenVKPresenter.php +++ b/Web/Presenters/OpenVKPresenter.php @@ -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")))); diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index b634a770..32d298f4 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -172,7 +172,11 @@ Админ-панель {/if} {if $canAccessHelpdesk} - Helpdesk + Helpdesk + {if $helpdeskTicketAnsweredCount > 0} + ({$helpdeskTicketAnsweredCount}) + {/if} + {/if} {include "../components/paginator.xml", conf => (object) [ - "page" => $page, - "count" => $count, - "amount" => sizeof($gifts), - "perPage" => OPENVK_DEFAULT_PER_PAGE, - "atBottom" => true, + "page" => $page, + "count" => $count, + "amount" => sizeof($gifts), + "perPage" => OPENVK_DEFAULT_PER_PAGE, ]} {/block} diff --git a/Web/Presenters/templates/components/comment.xml b/Web/Presenters/templates/components/comment.xml index fb67c566..cfea3148 100644 --- a/Web/Presenters/templates/components/comment.xml +++ b/Web/Presenters/templates/components/comment.xml @@ -1,7 +1,8 @@ {var author = $comment->getOwner()} +{var $Club = openvk\Web\Models\Entities\Club::class} -
diff --git a/Web/Presenters/templates/components/comments.xml b/Web/Presenters/templates/components/comments.xml
index eae83fad..cfc103c7 100644
--- a/Web/Presenters/templates/components/comments.xml
+++ b/Web/Presenters/templates/components/comments.xml
@@ -2,7 +2,8 @@
{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}
{if sizeof($comments) > 0}
diff --git a/Web/Presenters/templates/components/textArea.xml b/Web/Presenters/templates/components/textArea.xml
index 6192f6f5..9dce51ac 100644
--- a/Web/Presenters/templates/components/textArea.xml
+++ b/Web/Presenters/templates/components/textArea.xml
@@ -42,6 +42,11 @@
{_"contains_nsfw"}
+
+
+
diff --git a/Web/static/js/al_comments.js b/Web/static/js/al_comments.js
index 03875a39..111b558c 100644
--- a/Web/static/js/al_comments.js
+++ b/Web/static/js/al_comments.js
@@ -1,9 +1,12 @@
u(".comment-reply").on("click", function(e) {
- let inputbox = u("#write textarea");
- 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 inputbox = u("#write textarea");
+ 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");
});
diff --git a/locales/en.strings b/locales/en.strings
index e4b617df..4619f1c1 100644
--- a/locales/en.strings
+++ b/locales/en.strings
@@ -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";
diff --git a/locales/ru.strings b/locales/ru.strings
index 07746993..0109646b 100644
--- a/locales/ru.strings
+++ b/locales/ru.strings
@@ -132,6 +132,7 @@
"attachment" = "Вложение";
"post_as_group" = "От имени сообщества";
+"comment_as_group" = "От имени сообщества";
"add_signature" = "Подпись автора";
"contains_nsfw" = "Содержит NSFW-контент";
"nsfw_warning" = "Данный пост может содержать 18+ контент";
|