mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-01 22:39:13 +08:00
Merge branch 'feature-613' of git://github.com/Abijeet/BookStack into Abijeet-feature-613
This commit is contained in:
@ -46,7 +46,7 @@ class BookController extends Controller
|
||||
'books' => $books,
|
||||
'recents' => $recents,
|
||||
'popular' => $popular,
|
||||
'new' => $new,
|
||||
'new' => $new,
|
||||
'booksViewType' => $booksViewType
|
||||
]);
|
||||
}
|
||||
|
@ -249,4 +249,27 @@ class UserController extends Controller
|
||||
'assetCounts' => $assetCounts
|
||||
]);
|
||||
}
|
||||
|
||||
public function switchBookView($id, Request $request) {
|
||||
$this->checkPermissionOr('users-manage', function () use ($id) {
|
||||
return $this->currentUser->id == $id;
|
||||
});
|
||||
$viewType = $request->get('book_view_type');
|
||||
|
||||
if (!in_array($viewType, ['grid', 'list'])) {
|
||||
$viewType = 'list';
|
||||
}
|
||||
|
||||
$user = $this->user->findOrFail($id);
|
||||
setting()->putUser($user, 'books_view_type', $viewType);
|
||||
|
||||
$previousUrl = url()->previous();
|
||||
if (empty($previousUrl)) {
|
||||
// if no previous URL, redirect to settings
|
||||
return redirect("/settings/users/$id");
|
||||
} else {
|
||||
// redirect to the previous page.
|
||||
return redirect($previousUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user