X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/7bb336d1a8ea4af156512049abde2e0a35e20aa4..refs/pull/1021/head:/app/Http/Controllers/UserController.php diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 2fe22f1e1..f6bd13e6f 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -93,17 +93,7 @@ class UserController extends Controller $user->roles()->sync($roles); } - // Get avatar from gravatar and save - if (!config('services.disable_services')) { - try { - $avatar = \Images::saveUserGravatar($user); - $user->avatar()->associate($avatar); - $user->save(); - } catch (Exception $e) { - \Log::error('Failed to save user gravatar image'); - } - - } + $this->userRepo->downloadGravatarToUserAvatar($user); return redirect('/settings/users'); } @@ -256,12 +246,13 @@ class UserController extends Controller * @param Request $request * @return \Illuminate\Http\RedirectResponse */ - public function switchBookView($id, Request $request) { + public function switchBookView($id, Request $request) + { $this->checkPermissionOr('users-manage', function () use ($id) { return $this->currentUser->id == $id; }); - $viewType = $request->get('book_view_type'); + $viewType = $request->get('view_type'); if (!in_array($viewType, ['grid', 'list'])) { $viewType = 'list'; } @@ -272,4 +263,26 @@ class UserController extends Controller return redirect()->back(302, [], "/settings/users/$id"); } + /** + * Update the user's preferred shelf-list display setting. + * @param $id + * @param Request $request + * @return \Illuminate\Http\RedirectResponse + */ + public function switchShelfView($id, Request $request) + { + $this->checkPermissionOr('users-manage', function () use ($id) { + return $this->currentUser->id == $id; + }); + + $viewType = $request->get('view_type'); + if (!in_array($viewType, ['grid', 'list'])) { + $viewType = 'list'; + } + + $user = $this->user->findOrFail($id); + setting()->putUser($user, 'bookshelves_view_type', $viewType); + + return redirect()->back(302, [], "/settings/users/$id"); + } }