X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/492e2f173e13e63bd3914ebee11c300ce9c9757b..refs/pull/360/head:/app/Services/PermissionService.php diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php index 72a810b6b..8b47e1246 100644 --- a/app/Services/PermissionService.php +++ b/app/Services/PermissionService.php @@ -474,11 +474,13 @@ class PermissionService /** * Get the children of a book in an efficient single query, Filtered by the permission system. * @param integer $book_id - * @param bool $filterDrafts + * @param bool $filterDrafts + * @param bool $fetchPageContent * @return \Illuminate\Database\Query\Builder */ - public function bookChildrenQuery($book_id, $filterDrafts = false) { - $pageSelect = $this->db->table('pages')->selectRaw("'BookStack\\\\Page' as entity_type, id, slug, name, text, '' as description, book_id, priority, chapter_id, draft")->where('book_id', '=', $book_id)->where(function($query) use ($filterDrafts) { + public function bookChildrenQuery($book_id, $filterDrafts = false, $fetchPageContent = false) { + $pageContentSelect = $fetchPageContent ? 'html' : "''"; + $pageSelect = $this->db->table('pages')->selectRaw("'BookStack\\\\Page' as entity_type, id, slug, name, text, {$pageContentSelect} as description, book_id, priority, chapter_id, draft")->where('book_id', '=', $book_id)->where(function($query) use ($filterDrafts) { $query->where('draft', '=', 0); if (!$filterDrafts) { $query->orWhere(function($query) {