mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-06 12:02:45 +03:00
Updated view toggle to store date
Also added test for user list order preferences
This commit is contained in:
@@ -299,7 +299,6 @@ class UserController extends Controller
|
||||
*/
|
||||
public function changeSort(string $id, string $type, Request $request)
|
||||
{
|
||||
// TODO - Test this endpoint
|
||||
$validSortTypes = ['books', 'bookshelves'];
|
||||
if (!in_array($type, $validSortTypes)) {
|
||||
return redirect()->back(500);
|
||||
@@ -307,6 +306,28 @@ class UserController extends Controller
|
||||
return $this->changeListSort($id, $request, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the stored section expansion preference for the given user.
|
||||
* @param string $id
|
||||
* @param string $key
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function updateExpansionPreference(string $id, string $key, Request $request)
|
||||
{
|
||||
$this->checkPermissionOrCurrentUser('users-manage', $id);
|
||||
$keyWhitelist = ['home-details'];
|
||||
if (!in_array($key, $keyWhitelist)) {
|
||||
return response("Invalid key", 500);
|
||||
}
|
||||
|
||||
$newState = $request->get('expand', 'false');
|
||||
|
||||
$user = $this->user->findOrFail($id);
|
||||
setting()->putUser($user, 'section_expansion#' . $key, $newState);
|
||||
return response("", 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changed the stored preference for a list sort order.
|
||||
* @param int $userId
|
||||
|
@@ -67,6 +67,17 @@ class SettingService
|
||||
return $this->get($this->userKey($user->id, $key), $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value for the current logged-in user.
|
||||
* @param $key
|
||||
* @param bool $default
|
||||
* @return bool|string
|
||||
*/
|
||||
public function getForCurrentUser($key, $default = false)
|
||||
{
|
||||
return $this->getUser(auth()->user(), $key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a setting value from the cache or database.
|
||||
* Looks at the system defaults if not cached or in database.
|
||||
|
Reference in New Issue
Block a user