diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 737ad506bc..b99dd19535 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -106,6 +106,13 @@ class PreferencesController extends Controller $fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr; $tjOptionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data; + // notification preferences (single value for each): + + $notifications = []; + foreach (config('firefly.available_notifications') as $notification) { + $notifications[$notification] = app('preferences')->get(sprintf('notification_%s', $notification), true)->data; + } + ksort($languages); // list of locales also has "equal" which makes it equal to whatever the language is. @@ -131,6 +138,7 @@ class PreferencesController extends Controller 'isDocker', 'frontPageAccounts', 'languages', + 'notifications', 'locales', 'locale', 'tjOptionalFields', @@ -163,6 +171,18 @@ class PreferencesController extends Controller app('preferences')->set('frontPageAccounts', $frontPageAccounts); } + // extract notifications: + $all = $request->all(); + foreach(config('firefly.available_notifications') as $option) { + $key = sprintf('notification_%s', $option); + if(array_key_exists($key, $all)) { + app('preferences')->set($key, true); + } + if(!array_key_exists($key, $all)) { + app('preferences')->set($key, false); + } + } + // view range: app('preferences')->set('viewRange', $request->get('viewRange')); // forget session values: diff --git a/config/firefly.php b/config/firefly.php index 273b65db53..736a469bec 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -144,6 +144,9 @@ return [ 'update_endpoint' => 'https://version.firefly-iii.org/index.json', 'update_minimum_age' => 7, + // notifications + 'available_notifications' => ['bill_reminder', 'new_access_token', 'transaction_creation', 'user_login'], + // enabled languages 'languages' => [ // currently enabled languages diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 28c8d5ef4c..2f4a2f6c87 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -1014,6 +1014,7 @@ return [ 'preferences_frontpage' => 'Home screen', 'preferences_security' => 'Security', 'preferences_layout' => 'Layout', + 'preferences_notifications' => 'Notifications', 'pref_home_show_deposits' => 'Show deposits on the home screen', 'pref_home_show_deposits_info' => 'The home screen already shows your expense accounts. Should it also show your revenue accounts?', 'pref_home_do_show_deposits' => 'Yes, show them', @@ -1044,7 +1045,12 @@ return [ 'optional_field_attachments' => 'Attachments', 'optional_field_meta_data' => 'Optional meta data', 'external_url' => 'External URL', - + 'pref_notification_bill_reminder' => 'Reminder about expiring bills', + 'pref_notification_new_access_token' => 'Alert when a new API access token is created', + 'pref_notification_transaction_creation' => 'Alert when a transaction is created automatically', + 'pref_notification_user_login' => 'Alert when you login from a new location', + 'pref_notifications' => 'Notifications', + 'pref_notifications_help' => 'Indicate if these are notifications you would like to get. Some notifications may contain sensitive financial information.', // profile: 'delete_stuff_header' => 'Delete data', 'permanent_delete_stuff' => 'Be careful with these buttons. Deleting stuff is permanent.', diff --git a/resources/views/preferences/index.twig b/resources/views/preferences/index.twig index ee8130ae8b..e8d3c73c48 100644 --- a/resources/views/preferences/index.twig +++ b/resources/views/preferences/index.twig @@ -5,7 +5,8 @@ {% endblock %} {% block content %} -
{% endblock %} {% block scripts %} - + - + {% endblock %} {% block styles %} - - + + {% endblock %}