From 9698447e892a9efb8392e61d4fbf3d08aa12d09a Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 3 Mar 2015 17:51:01 +1100 Subject: [PATCH] FEATURE: support staff only custom user fields --- config/locales/server.en.yml | 1 + config/site_settings.yml | 3 +++ lib/topic_view.rb | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d5f28d34606..52705befb2c 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1078,6 +1078,7 @@ en: detect_custom_avatars: "Whether or not to check that users have uploaded custom avatars." max_daily_gravatar_crawls: "Maximum number of times Discourse will check Gravatar for custom avatars in a day" public_user_custom_fields: "A whitelist of custom fields for a user that can be shown publically." + staff_user_custom_fields: "A whitelist of custom fields for a user that can be shown to staff." allow_profile_backgrounds: "Allow users to upload profile backgrounds." diff --git a/config/site_settings.yml b/config/site_settings.yml index 85c043ec062..7b464a84b80 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -299,6 +299,9 @@ users: public_user_custom_fields: type: list default: '' + staff_user_custom_fields: + type: list + default: '' posting: min_post_length: diff --git a/lib/topic_view.rb b/lib/topic_view.rb index b9ffd643414..a53fc0f4080 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -42,6 +42,11 @@ class TopicView @user_custom_fields = User.custom_fields_for_ids(@posts.map(&:user_id), SiteSetting.public_user_custom_fields.split('|')) end + if @guardian.is_staff? && SiteSetting.staff_user_custom_fields.present? && @posts + @user_custom_fields ||= {} + @user_custom_fields.deep_merge!(User.custom_fields_for_ids(@posts.map(&:user_id), SiteSetting.staff_user_custom_fields.split('|'))) + end + @draft_key = @topic.draft_key @draft_sequence = DraftSequence.current(@user, @draft_key) end