diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb index b79ee9c..b458401 100644 --- a/app/helpers/profile_helper.rb +++ b/app/helpers/profile_helper.rb @@ -40,4 +40,27 @@ module ProfileHelper end end + def display_custom_field(title, profile, field, force = false) + unless force || profile.may_display_field_to?(field, user) + return + end + value = profile.custom_fields[field][:value] + if !value.blank? + if block_given? + value = yield(value) + end + content_tag('tr', content_tag('td', title, :class => 'field-name') + content_tag('td', value)) + else + '' + end + end + + def display_custom_fields(profile) + fields = [] + profile.custom_fields.each { |key,value| + fields << display_custom_field(value[:label], profile, key) + } + content_tag('tr', content_tag('th', _('Custom Fields'), { :colspan => 2 })) + fields.join.html_safe + end + end diff --git a/app/views/profile/_person_profile.html.erb b/app/views/profile/_person_profile.html.erb index 981b329..41ab9df 100644 --- a/app/views/profile/_person_profile.html.erb +++ b/app/views/profile/_person_profile.html.erb @@ -18,6 +18,8 @@ <% cache_timeout(profile.relationships_cache_key, 4.hours) do %> <%= display_work_info profile %> + <%= display_custom_fields(profile) %> +