]> BookStack Code Mirror - bookstack/blobdiff - app/Activity/Tools/CommentTree.php
respective book and chapter structure added.
[bookstack] / app / Activity / Tools / CommentTree.php
index 559edccf3218c8f0cfc18e8c10658b6912a932d1..16f6804ea4244358568c7a5bdc957953c6c93c2d 100644 (file)
@@ -41,6 +41,17 @@ class CommentTree
         return $this->tree;
     }
 
+    public function canUpdateAny(): bool
+    {
+        foreach ($this->comments as $comment) {
+            if (userCan('comment-update', $comment)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     /**
      * @param Comment[] $comments
      */
@@ -65,7 +76,7 @@ class CommentTree
         }
 
         $tree = [];
-        foreach ($childMap[0] as $childId) {
+        foreach ($childMap[0] ?? [] as $childId) {
             $tree[] = $this->createTreeForId($childId, 0, $byId, $childMap);
         }