]> BookStack Code Mirror - bookstack/blobdiff - app/Repos/CommentRepo.php
#47 - Adds comment level permissions to the front-end.
[bookstack] / app / Repos / CommentRepo.php
index 7d0c4ebd7b419ad11035cb680dfa03995dcc1f13..83847239f1be6e10bb45992b17aa87e3b2ae6c5b 100644 (file)
@@ -43,11 +43,14 @@ class CommentRepo {
         $comments = $this->comment->getAllPageComments($pageId);
         $index = [];
         $totalComments = count($comments);
+        $finalCommentList = [];
+
         // normalizing the response.
-        foreach($comments as &$comment) {
-            $comment = $this->normalizeComment($comment);
+        for ($i = 0; $i < count($comments); ++$i) {
+            $comment = $this->normalizeComment($comments[$i]);
             $parentId = $comment->parent_id;
             if (empty($parentId)) {
+                $finalCommentList[] = $comment;
                 $index[$comment->id] = $comment;
                 continue;
             }
@@ -63,7 +66,7 @@ class CommentRepo {
             $index[$comment->id] = $comment;
         }
         return [
-            'comments' => $comments,
+            'comments' => $finalCommentList,
             'total' => $totalComments
         ];
     }