diff --git a/app/models/user.rb b/app/models/user.rb index c4eb54a9046..938a9ab3077 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -63,6 +63,7 @@ class User < ActiveRecord::Base before_save :ensure_password_is_hashed after_initialize :add_trust_level after_initialize :set_default_email_digest + after_initialize :set_default_external_links_in_new_tab after_save :update_tracked_topics @@ -596,6 +597,12 @@ class User < ActiveRecord::Base end end + def set_default_external_links_in_new_tab + if has_attribute?(:external_links_in_new_tab) && self.external_links_in_new_tab.nil? + self.external_links_in_new_tab = !SiteSetting.default_external_links_in_new_tab.blank? + end + end + private def previous_visit_at_update_required?(timestamp) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d87eba7b1ae..2190379c04f 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -752,6 +752,7 @@ en: allow_uploaded_avatars: "Allow users to upload their custom avatars" allow_animated_avatars: "Allow users to use animated gif for avatars. WARNING: it is highly recommended to run the avatars:regenerate rake task after changing that setting." default_digest_email_frequency: "How often users receive digest emails by default. They can change this setting in their preferences." + default_external_links_in_new_tab: "Open external links in a new tab. Users can change this in their preferences." detect_custom_avatars: "Whether or not to check that users have uploaded custom avatars" max_daily_gravatar_crawls: "The maximum amount of times Discourse will check gravatar for custom avatars in a day" diff --git a/config/site_settings.yml b/config/site_settings.yml index f3cf61009a3..f118f60e356 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -126,6 +126,7 @@ users: client: true default: 14 delete_all_posts_max: 15 + default_external_links_in_new_tab: false posting: min_post_length: diff --git a/db/migrate/20140102194802_remove_default_from_external_links_in_new_tab.rb b/db/migrate/20140102194802_remove_default_from_external_links_in_new_tab.rb new file mode 100644 index 00000000000..b18afe4c757 --- /dev/null +++ b/db/migrate/20140102194802_remove_default_from_external_links_in_new_tab.rb @@ -0,0 +1,9 @@ +class RemoveDefaultFromExternalLinksInNewTab < ActiveRecord::Migration + def up + change_column_default :users, :external_links_in_new_tab, nil + end + + def down + change_column_default :users, :external_links_in_new_tab, false + end +end