diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 37b73b4..e519718 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -859,8 +859,7 @@ module ApplicationHelper def profile_field_privacy_selector(profile, name) return '' unless profile.public? - content_tag('div', labelled_check_box(_('Public'), 'profile_data[fields_privacy]['+name+']', 'public', profile.public_fields.include?(name)), :class => 'field-privacy-selector') - end + content_tag('div', labelled_check_box(_('Public'), 'profile_data[fields_privacy]['+name+']', 'public', profile.public_optional_field?(name) ), :class => 'field-privacy-selector') end def login_url options = Noosfero.url_options.merge({ :controller => 'account', :action => 'login' }) diff --git a/app/models/profile.rb b/app/models/profile.rb index b5540c4..5e1e89d 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -958,7 +958,9 @@ private :generate_url, :url_options if not self.active_fields.include? field.to_s self.send "may_display_#{field}_to?", user rescue true else - not (!self.public_fields.include? field.to_s and (!user or (user != self and !user.is_a_friend?(self)))) + if public_optional_field?(field) + not (!self.public_fields.include? field.to_s and (!user or (user != self and !user.is_a_friend?(self)))) + end end end @@ -974,6 +976,11 @@ private :generate_url, :url_options self.data[:fields_privacy] end + def public_optional_field?(field) + return true if fields_privacy.nil? + fields_privacy[field.to_s] != "0" + end + def public_fields self.active_fields end -- libgit2 0.21.2