diff --git a/app/Users/Controllers/UserAccountController.php b/app/Users/Controllers/UserAccountController.php new file mode 100644 index 000000000..9152eb5e8 --- /dev/null +++ b/app/Users/Controllers/UserAccountController.php @@ -0,0 +1,105 @@ +isGuest(); + $mfaMethods = $guest ? [] : user()->mfaValues->groupBy('method'); + + return view('users.account.index', [ + 'mfaMethods' => $mfaMethods, + ]); + } + + /** + * Show the user-specific interface shortcuts. + */ + public function showShortcuts() + { + $shortcuts = UserShortcutMap::fromUserPreferences(); + $enabled = setting()->getForCurrentUser('ui-shortcuts-enabled', false); + + $this->setPageTitle(trans('preferences.shortcuts_interface')); + + return view('users.account.shortcuts', [ + 'shortcuts' => $shortcuts, + 'enabled' => $enabled, + ]); + } + + /** + * Update the user-specific interface shortcuts. + */ + public function updateShortcuts(Request $request) + { + $enabled = $request->get('enabled') === 'true'; + $providedShortcuts = $request->get('shortcut', []); + $shortcuts = new UserShortcutMap($providedShortcuts); + + setting()->putForCurrentUser('ui-shortcuts', $shortcuts->toJson()); + setting()->putForCurrentUser('ui-shortcuts-enabled', $enabled); + + $this->showSuccessNotification(trans('preferences.shortcuts_update_success')); + + return redirect('/my-account/shortcuts'); + } + + /** + * Show the notification preferences for the current user. + */ + 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.account.notifications', [ + 'preferences' => $preferences, + 'watches' => $watches, + ]); + } + + /** + * Update the notification preferences for the current user. + */ + public function updateNotifications(Request $request) + { + $this->checkPermission('receive-notifications'); + $this->preventGuestAccess(); + $data = $this->validate($request, [ + 'preferences' => ['required', 'array'], + 'preferences.*' => ['required', 'string'], + ]); + + $preferences = (new UserNotificationPreferences(user())); + $preferences->updateFromSettingsArray($data['preferences']); + $this->showSuccessNotification(trans('preferences.notifications_update_success')); + + return redirect('/my-account/notifications'); + } +} diff --git a/app/Users/Controllers/UserPreferencesController.php b/app/Users/Controllers/UserPreferencesController.php index 08d65743b..3600dc55f 100644 --- a/app/Users/Controllers/UserPreferencesController.php +++ b/app/Users/Controllers/UserPreferencesController.php @@ -16,88 +16,6 @@ class UserPreferencesController extends Controller ) { } - /** - * Show the overview for user preferences. - */ - public function index() - { - return view('users.preferences.index'); - } - - /** - * Show the user-specific interface shortcuts. - */ - public function showShortcuts() - { - $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, - ]); - } - - /** - * Update the user-specific interface shortcuts. - */ - public function updateShortcuts(Request $request) - { - $enabled = $request->get('enabled') === 'true'; - $providedShortcuts = $request->get('shortcut', []); - $shortcuts = new UserShortcutMap($providedShortcuts); - - setting()->putForCurrentUser('ui-shortcuts', $shortcuts->toJson()); - setting()->putForCurrentUser('ui-shortcuts-enabled', $enabled); - - $this->showSuccessNotification(trans('preferences.shortcuts_update_success')); - - return redirect('/preferences/shortcuts'); - } - - /** - * Show the notification preferences for the current user. - */ - 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, - ]); - } - - /** - * Update the notification preferences for the current user. - */ - public function updateNotifications(Request $request) - { - $this->checkPermission('receive-notifications'); - $this->preventGuestAccess(); - $data = $this->validate($request, [ - 'preferences' => ['required', 'array'], - 'preferences.*' => ['required', 'string'], - ]); - - $preferences = (new UserNotificationPreferences(user())); - $preferences->updateFromSettingsArray($data['preferences']); - $this->showSuccessNotification(trans('preferences.notifications_update_success')); - - return redirect('/preferences/notifications'); - } - /** * Update the preferred view format for a list view of the given type. */ diff --git a/lang/en/preferences.php b/lang/en/preferences.php index 118e8ba82..cf1ee2b37 100644 --- a/lang/en/preferences.php +++ b/lang/en/preferences.php @@ -5,10 +5,10 @@ */ return [ - 'preferences' => 'Preferences', + 'my_account' => 'My Account', 'shortcuts' => 'Shortcuts', - 'shortcuts_interface' => 'Interface Keyboard Shortcuts', + 'shortcuts_interface' => 'UI Shortcut Preferences', 'shortcuts_toggle_desc' => 'Here you can enable or disable keyboard system interface shortcuts, used for navigation and actions.', 'shortcuts_customize_desc' => 'You can customize each of the shortcuts below. Just press your desired key combination after selecting the input for a shortcut.', 'shortcuts_toggle_label' => 'Keyboard shortcuts enabled', diff --git a/resources/icons/notifications.svg b/resources/icons/notifications.svg new file mode 100644 index 000000000..52786954d --- /dev/null +++ b/resources/icons/notifications.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/views/layouts/parts/header-user-menu.blade.php b/resources/views/layouts/parts/header-user-menu.blade.php index 8ba750f95..694b7b87a 100644 --- a/resources/views/layouts/parts/header-user-menu.blade.php +++ b/resources/views/layouts/parts/header-user-menu.blade.php @@ -35,9 +35,9 @@
{{ trans('preferences.shortcuts_overview_desc') }}
@@ -20,7 +20,7 @@{{ trans('preferences.notifications_desc') }}
@endif @@ -37,5 +37,26 @@ @endif + @if(!user()->isGuest()) +{{ trans('settings.users_mfa_desc') }}
++ @if ($mfaMethods->count() > 0) + @icon('check-circle') + @else + @icon('cancel') + @endif + {{ trans_choice('settings.users_mfa_x_methods', $mfaMethods->count()) }} +
+{{ trans('preferences.notifications_watched_desc') }}
+ + @if($watches->isEmpty()) +{{ trans('common.no_items') }}
+ @else +{{ trans('preferences.notifications_watched_desc') }}
- - @if($watches->isEmpty()) -{{ trans('common.no_items') }}
- @else -