From 13a4045047845f81b5a6113fc36730f73929f079 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 7 Aug 2020 13:55:49 +0200 Subject: [PATCH] Implement isContentAuthor for article comments --- .../files/lib/page/AbstractArticlePage.class.php | 3 ++- .../manager/ArticleCommentManager.class.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/page/AbstractArticlePage.class.php b/wcfsetup/install/files/lib/page/AbstractArticlePage.class.php index 32befc7cde..95340a1824 100644 --- a/wcfsetup/install/files/lib/page/AbstractArticlePage.class.php +++ b/wcfsetup/install/files/lib/page/AbstractArticlePage.class.php @@ -7,6 +7,7 @@ use wcf\data\article\ArticleAction; use wcf\data\article\ArticleEditor; use wcf\data\article\ViewableArticle; use wcf\data\tag\Tag; +use wcf\system\cache\runtime\ViewableArticleRuntimeCache; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\IllegalLinkException; use wcf\system\exception\PermissionDeniedException; @@ -83,7 +84,7 @@ abstract class AbstractArticlePage extends AbstractPage { throw new IllegalLinkException(); } - $this->article = ViewableArticle::getArticle($this->articleContent->articleID, false); + $this->article = ViewableArticleRuntimeCache::getInstance()->getObject($this->articleContent->articleID); $this->article->getDiscussionProvider()->setArticleContent($this->articleContent->getDecoratedObject()); $this->category = $this->article->getCategory(); diff --git a/wcfsetup/install/files/lib/system/comment/manager/ArticleCommentManager.class.php b/wcfsetup/install/files/lib/system/comment/manager/ArticleCommentManager.class.php index de8632b0f4..cb1592b260 100644 --- a/wcfsetup/install/files/lib/system/comment/manager/ArticleCommentManager.class.php +++ b/wcfsetup/install/files/lib/system/comment/manager/ArticleCommentManager.class.php @@ -5,8 +5,11 @@ use wcf\data\article\content\ArticleContentList; use wcf\data\article\ArticleEditor; use wcf\data\comment\response\CommentResponseList; use wcf\data\comment\CommentList; +use wcf\data\comment\response\CommentResponse; +use wcf\data\DatabaseObjectDecorator; use wcf\data\object\type\ObjectTypeCache; use wcf\system\cache\runtime\UserProfileRuntimeCache; +use wcf\system\cache\runtime\ViewableArticleRuntimeCache; use wcf\system\like\IViewableLikeProvider; use wcf\system\WCF; @@ -208,4 +211,17 @@ class ArticleCommentManager extends AbstractCommentManager implements IViewableL } } } + + /** + * @inheritDoc + */ + public function isContentAuthor($commentOrResponse) { + if ($commentOrResponse instanceof CommentResponse || ($commentOrResponse instanceof DatabaseObjectDecorator && $commentOrResponse->getDecoratedObject() instanceof CommentResponse)) { + $article = ViewableArticleRuntimeCache::getInstance()->getObject($commentOrResponse->getComment()->objectID); + } + else { + $article = ViewableArticleRuntimeCache::getInstance()->getObject($commentOrResponse->objectID); + } + return $article->userID == $commentOrResponse->userID; + } } -- 2.20.1