namespace BookStack\Users\Controllers;
+use BookStack\Activity\Models\Watch;
use BookStack\Http\Controller;
+use BookStack\Permissions\PermissionApplicator;
use BookStack\Settings\UserNotificationPreferences;
use BookStack\Settings\UserShortcutMap;
use BookStack\Users\UserRepo;
) {
}
+ /**
+ * Show the overview for user preferences.
+ */
+ public function index()
+ {
+ return view('users.preferences.index');
+ }
+
/**
* Show the user-specific interface shortcuts.
*/
$shortcuts = UserShortcutMap::fromUserPreferences();
$enabled = setting()->getForCurrentUser('ui-shortcuts-enabled', false);
+ $this->setPageTitle(trans('preferences.shortcuts_interface'));
+
return view('users.preferences.shortcuts', [
'shortcuts' => $shortcuts,
'enabled' => $enabled,
/**
* Show the notification preferences for the current user.
*/
- public function showNotifications()
+ public function showNotifications(PermissionApplicator $permissions)
{
+ $this->checkPermission('receive-notifications');
+ $this->preventGuestAccess();
+
$preferences = (new UserNotificationPreferences(user()));
+ $query = Watch::query()->where('user_id', '=', user()->id);
+ $query = $permissions->restrictEntityRelationQuery($query, 'watches', 'watchable_id', 'watchable_type');
+ $watches = $query->with('watchable')->paginate(20);
+
+ $this->setPageTitle(trans('preferences.notifications'));
return view('users.preferences.notifications', [
'preferences' => $preferences,
+ 'watches' => $watches,
]);
}
*/
public function updateNotifications(Request $request)
{
+ $this->checkPermission('receive-notifications');
+ $this->preventGuestAccess();
$data = $this->validate($request, [
'preferences' => ['required', 'array'],
'preferences.*' => ['required', 'string'],