X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/6063ac4a119f6defaf06b282540d815df7b040ae..refs/pull/1314/head:/app/Http/Controllers/SearchController.php diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 0faeb0dec..d8f2dc4d7 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -1,8 +1,8 @@ searchService->searchEntities($searchTerm, 'all', $page, 20); - $hasNextPage = $this->searchService->searchEntities($searchTerm, 'all', $page+1, 20)['count'] > 0; return view('search/all', [ 'entities' => $results['results'], 'totalResults' => $results['total'], 'searchTerm' => $searchTerm, - 'hasNextPage' => $hasNextPage, + 'hasNextPage' => $results['has_more'], 'nextPageLink' => $nextPageLink ]); } @@ -90,21 +89,19 @@ class SearchController extends Controller { $entityTypes = $request->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]); } - } - -