X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/03ee3d21bab5ef1b8fc09de27f3aa8115d947dd1..refs/pull/1143/head:/app/Http/Controllers/SearchController.php diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index ddc92f705..d8f2dc4d7 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -1,8 +1,8 @@ filled('types') ? collect(explode(',', $request->get('types'))) : collect(['page', 'chapter', 'book']); $searchTerm = $request->get('term', false); + $permission = $request->get('permission', 'view'); // Search for entities otherwise show most popular if ($searchTerm !== false) { $searchTerm .= ' {type:'. implode('|', $entityTypes->toArray()) .'}'; - $entities = $this->searchService->searchEntities($searchTerm)['results']; + $entities = $this->searchService->searchEntities($searchTerm, 'all', 1, 20, $permission)['results']; } else { $entityNames = $entityTypes->map(function ($type) { - return 'BookStack\\' . ucfirst($type); + return 'BookStack\\' . ucfirst($type); // TODO - Extract this elsewhere, too specific and stringy })->toArray(); - $entities = $this->viewService->getPopular(20, 0, $entityNames); + $entities = $this->viewService->getPopular(20, 0, $entityNames, $permission); } return view('search/entity-ajax-list', ['entities' => $entities]);