Show likes when loading comment (responses) via permalink
authorMatthias Schmidt <gravatronics@live.com>
Sun, 27 Jan 2019 14:10:30 +0000 (15:10 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 27 Jan 2019 14:10:30 +0000 (15:10 +0100)
Close  #2836

wcfsetup/install/files/lib/data/comment/CommentAction.class.php

index cb8e21b818e9e384816dfc16feb54e65d4fcbf0c..279b46322302ac5294bb3b85ba0376ff2dd3c005 100644 (file)
@@ -1026,6 +1026,31 @@ class CommentAction extends AbstractDatabaseObjectAction implements IMessageInli
                        'commentManager' => $this->commentProcessor
                ]);
                
+               // load like data
+               if (MODULE_LIKE) {
+                       $likeData = [];
+                       $commentObjectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wcf.comment');
+                       LikeHandler::getInstance()->loadLikeObjects($commentObjectType, [$comment->commentID]);
+                       $likeData['comment'] = LikeHandler::getInstance()->getLikeObjects($commentObjectType);
+                       
+                       $responseIDs = [];
+                       foreach ($comment as $visibleResponse) {
+                               $responseIDs[] = $visibleResponse->responseID;
+                       }
+                       
+                       if ($response !== null) {
+                               $responseIDs[] = $response->responseID;
+                       }
+                       
+                       if (!empty($responseIDs)) {
+                               $responseObjectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wcf.comment.response');
+                               LikeHandler::getInstance()->loadLikeObjects($responseObjectType, $responseIDs);
+                               $likeData['response'] = LikeHandler::getInstance()->getLikeObjects($responseObjectType);
+                       }
+                       
+                       WCF::getTPL()->assign('likeData', $likeData);
+               }
+               
                $template = WCF::getTPL()->fetch('commentList');
                if ($response === null) {
                        return $template;