diff --git a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars index 1d683ba80e4..f5406e2dad2 100644 --- a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars @@ -167,6 +167,9 @@ {{preference-checkbox labelKey="user.enable_quoting" checked=enable_quoting}} {{preference-checkbox labelKey="user.dynamic_favicon" checked=dynamic_favicon}} {{preference-checkbox labelKey="user.disable_jump_reply" checked=disable_jump_reply}} + {{#unless Discourse.SiteSettings.edit_history_available_to_public}} + {{preference-checkbox labelKey="user.edit_history_public" checked=edit_history_public}} + {{/unless}} {{plugin-outlet "user_custom_preferences"}} diff --git a/app/models/user.rb b/app/models/user.rb index bbeb787adde..988e3ea0296 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -778,6 +778,7 @@ end # registration_ip_address :inet # last_redirected_to_top_at :datetime # disable_jump_reply :boolean default(FALSE), not null +# edit_history_public :boolean default(FALSE), not null # # Indexes # diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index 3968dc2b717..b2bde1321a5 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -43,7 +43,8 @@ class UserSerializer < BasicUserSerializer :suspended_till, :uploaded_avatar_id, :badge_count, - :has_title_badges + :has_title_badges, + :edit_history_public has_one :invited_by, embed: :object, serializer: BasicUserSerializer has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer @@ -236,4 +237,7 @@ class UserSerializer < BasicUserSerializer object.badges.where(allow_title: true).count > 0 end + def include_edit_history_public? + can_edit && !SiteSetting.edit_history_visible_to_public + end end diff --git a/app/services/user_updater.rb b/app/services/user_updater.rb index f1f7a24412e..dce86dccf24 100644 --- a/app/services/user_updater.rb +++ b/app/services/user_updater.rb @@ -15,7 +15,8 @@ class UserUpdater :enable_quoting, :dynamic_favicon, :mailing_list_mode, - :disable_jump_reply + :disable_jump_reply, + :edit_history_public ] PROFILE_ATTR = [ diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index bc696866cf5..95b768431d0 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -271,6 +271,7 @@ en: notifications: "Notifications" disable_jump_reply: "Don't jump to your new post after replying" dynamic_favicon: "Show incoming message notifications on favicon (experimental)" + edit_history_public: "Let other users view my post revisions" external_links_in_new_tab: "Open all external links in a new tab" enable_quoting: "Enable quote reply for highlighted text" change: "change" diff --git a/db/migrate/20140727030954_add_edit_history_public_to_users.rb b/db/migrate/20140727030954_add_edit_history_public_to_users.rb new file mode 100644 index 00000000000..61d571aeb79 --- /dev/null +++ b/db/migrate/20140727030954_add_edit_history_public_to_users.rb @@ -0,0 +1,5 @@ +class AddEditHistoryPublicToUsers < ActiveRecord::Migration + def change + add_column :users, :edit_history_public, :boolean, default: false, null: false + end +end diff --git a/lib/guardian/post_guardian.rb b/lib/guardian/post_guardian.rb index 64ef1937e38..6c0c5aefd46 100644 --- a/lib/guardian/post_guardian.rb +++ b/lib/guardian/post_guardian.rb @@ -145,7 +145,7 @@ module PostGuardian return false unless post if !post.hidden - return true if post.wiki || SiteSetting.edit_history_visible_to_public + return true if post.wiki || SiteSetting.edit_history_visible_to_public || post.user.try(:edit_history_public) end authenticated? && diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb index b1c59d46b91..fcc004822c8 100644 --- a/spec/components/guardian_spec.rb +++ b/spec/components/guardian_spec.rb @@ -404,6 +404,12 @@ describe Guardian do it 'is true when logged in' do Guardian.new(Fabricate(:user)).can_see?(post_revision).should == true end + + it 'is true if the author has public edit history' do + public_post_revision = Fabricate(:post_revision) + public_post_revision.post.user.edit_history_public = true + Guardian.new.can_see?(public_post_revision).should == true + end end context 'edit_history_visible_to_public is false' do @@ -421,6 +427,12 @@ describe Guardian do it 'is false for trust level lower than 4' do Guardian.new(Fabricate(:leader)).can_see?(post_revision).should == false end + + it 'is true if the author has public edit history' do + public_post_revision = Fabricate(:post_revision) + public_post_revision.post.user.edit_history_public = true + Guardian.new.can_see?(public_post_revision).should == true + end end end end