1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

#47 - Adds comment level permissions to the front-end.

This commit is contained in:
Abijeet
2017-06-04 11:17:14 +05:30
parent 6ff440e677
commit 2fd421b115
7 changed files with 41 additions and 15 deletions

View 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
];
}