From ad8a529c8dbef45a499b262134c501d014ccab5e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 13 Dec 2015 15:21:48 +0000 Subject: [PATCH] Option to show email adresses by default for new users (#21447). git-svn-id: http://svn.redmine.org/redmine/trunk@14974 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/user_preference.rb | 3 +++ app/views/settings/_authentication.html.erb | 8 ++++++++ config/locales/en.yml | 1 + config/locales/fr.yml | 1 + config/settings.yml | 2 ++ test/unit/user_preference_test.rb | 7 +++++++ 6 files changed, 22 insertions(+) diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 80b3e6b9d..6e7876abb 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -25,6 +25,9 @@ class UserPreference < ActiveRecord::Base def initialize(attributes=nil, *args) super + if new_record? && !(attributes && attributes.key?(:hide_mail)) + self.hide_mail = Setting.default_users_hide_mail? + end self.others ||= {} end diff --git a/app/views/settings/_authentication.html.erb b/app/views/settings/_authentication.html.erb index f9c569cb8..35aa66425 100644 --- a/app/views/settings/_authentication.html.erb +++ b/app/views/settings/_authentication.html.erb @@ -36,5 +36,13 @@

<%= l(:text_session_expiration_settings) %>

+
+ <%= l(:label_default_values_for_new_users) %> + +
+

<%= setting_check_box :default_users_hide_mail, :label => :field_hide_mail %>

+
+
+ <%= submit_tag l(:button_save) %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 24d5fe7c4..7d98034f6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -975,6 +975,7 @@ en: label_create_missing_values: Create missing values label_api: API label_field_format_enumeration: Key/value list + label_default_values_for_new_users: Default values for new users button_login: Login button_submit: Submit diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 4ec1d3368..43873caf3 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -993,6 +993,7 @@ fr: label_create_missing_values: Créer les valeurs manquantes label_api: API label_field_format_enumeration: Liste clé/valeur + label_default_values_for_new_users: Valeurs par défaut pour les nouveaux utilisateurs button_login: Connexion button_submit: Soumettre diff --git a/config/settings.yml b/config/settings.yml index 7180dac3f..5031b68d3 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -217,6 +217,8 @@ sequential_project_identifiers: default: 0 # encodings used to convert repository files content to UTF-8 # multiple values accepted, comma separated +default_users_hide_mail: + default: 1 repositories_encodings: default: '' # encoding used to convert commit logs to UTF-8 diff --git a/test/unit/user_preference_test.rb b/test/unit/user_preference_test.rb index c76862408..bfdcd185a 100644 --- a/test/unit/user_preference_test.rb +++ b/test/unit/user_preference_test.rb @@ -25,6 +25,13 @@ class UserPreferenceTest < ActiveSupport::TestCase assert_equal true, preference.hide_mail end + def test_hide_mail_should_default_to_false_with_setting + with_settings :default_users_hide_mail => '0' do + preference = UserPreference.new + assert_equal false, preference.hide_mail + end + end + def test_create user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo") user.login = "newuser" -- 2.39.5