0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-17 13:52:04 +00:00

Updated view toggle to store date

Also added test for user list order preferences
This commit is contained in:
Dan Brown 2019-04-14 13:01:51 +01:00
parent 01be72d5e2
commit 9406b4d4c9
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
11 changed files with 155 additions and 20 deletions
app/Http/Controllers

View file

@ -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