]> BookStack Code Mirror - bookstack/blobdiff - app/Users/Controllers/UserPreferencesController.php
Test comment creator name truncation
[bookstack] / app / Users / Controllers / UserPreferencesController.php
index faa99629b349db365b1f39918f7d91944657bc7c..9c38ff2af750fd7542102d7ae744b8aecf2649ec 100644 (file)
@@ -3,6 +3,7 @@
 namespace BookStack\Users\Controllers;
 
 use BookStack\Http\Controller;
+use BookStack\Permissions\PermissionApplicator;
 use BookStack\Settings\UserNotificationPreferences;
 use BookStack\Settings\UserShortcutMap;
 use BookStack\Users\UserRepo;
@@ -15,6 +16,14 @@ class UserPreferencesController extends Controller
     ) {
     }
 
+    /**
+     * Show the overview for user preferences.
+     */
+    public function index()
+    {
+        return view('users.preferences.index');
+    }
+
     /**
      * Show the user-specific interface shortcuts.
      */
@@ -23,6 +32,8 @@ class UserPreferencesController extends Controller
         $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,
@@ -49,12 +60,22 @@ class UserPreferencesController extends Controller
     /**
      * 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 = user()->watches()->getQuery();
+        $query = $permissions->restrictEntityRelationQuery($query, 'watches', 'watchable_id', 'watchable_type');
+        $query = $permissions->filterDeletedFromEntityRelationQuery($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,
         ]);
     }
 
@@ -63,6 +84,8 @@ class UserPreferencesController extends Controller
      */
     public function updateNotifications(Request $request)
     {
+        $this->checkPermission('receive-notifications');
+        $this->preventGuestAccess();
         $data = $this->validate($request, [
            'preferences' => ['required', 'array'],
            'preferences.*' => ['required', 'string'],