2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-07 09:43:09 +08:00
|
|
|
module SiteSettings
|
|
|
|
end
|
|
|
|
|
|
|
|
module SiteSettings::DeprecatedSettings
|
2018-11-20 11:59:38 +08:00
|
|
|
SETTINGS = [
|
2022-02-07 11:26:06 +08:00
|
|
|
# [<old setting>, <new_setting>, <override>, <version to drop>]
|
2022-01-26 15:24:11 +08:00
|
|
|
["search_tokenize_chinese_japanese_korean", "search_tokenize_chinese", true, "2.9"],
|
2022-06-20 11:49:33 +08:00
|
|
|
["default_categories_regular", "default_categories_normal", true, "3.0"],
|
2023-10-25 09:45:10 +08:00
|
|
|
["anonymous_posting_min_trust_level", "anonymous_posting_allowed_groups", false, "3.3"],
|
2023-11-07 12:03:25 +08:00
|
|
|
["shared_drafts_min_trust_level", "shared_drafts_allowed_groups", false, "3.3"],
|
2023-11-09 10:07:01 +08:00
|
|
|
["min_trust_level_for_here_mention", "here_mention_allowed_groups", false, "3.3"],
|
2023-11-22 02:31:42 +08:00
|
|
|
["approve_unless_trust_level", "approve_unless_allowed_groups", false, "3.3"],
|
2023-11-23 01:44:59 +08:00
|
|
|
[
|
|
|
|
"approve_new_topics_unless_trust_level",
|
|
|
|
"approve_new_topics_unless_allowed_groups",
|
|
|
|
false,
|
|
|
|
"3.3",
|
|
|
|
],
|
2023-11-23 09:03:28 +08:00
|
|
|
["email_in_min_trust", "email_in_allowed_groups", false, "3.3"],
|
2023-12-12 12:20:37 +08:00
|
|
|
["min_trust_to_edit_wiki_post", "edit_wiki_post_allowed_groups", false, "3.3"],
|
2023-12-13 07:53:19 +08:00
|
|
|
["allow_uploaded_avatars", "uploaded_avatars_allowed_groups", false, "3.3"],
|
2023-12-13 11:50:13 +08:00
|
|
|
["min_trust_to_create_topic", "create_topic_allowed_groups", false, "3.3"],
|
2023-12-13 13:25:13 +08:00
|
|
|
["min_trust_to_edit_post", "edit_post_allowed_groups", false, "3.3"],
|
2023-12-13 17:18:42 +08:00
|
|
|
["min_trust_to_flag_posts", "flag_post_allowed_groups", false, "3.3"],
|
2023-12-14 09:56:42 +08:00
|
|
|
["tl4_delete_posts_and_topics", "delete_all_posts_and_topics_allowed_groups", false, "3.3"],
|
2017-08-07 09:43:09 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
def setup_deprecated_methods
|
2018-11-20 11:59:38 +08:00
|
|
|
SETTINGS.each do |old_setting, new_setting, override, version|
|
2018-11-14 18:07:04 +08:00
|
|
|
unless override
|
|
|
|
SiteSetting.singleton_class.public_send(
|
|
|
|
:alias_method,
|
|
|
|
:"_#{old_setting}",
|
|
|
|
:"#{old_setting}",
|
|
|
|
)
|
|
|
|
end
|
2018-11-14 17:32:32 +08:00
|
|
|
|
2018-11-14 16:09:26 +08:00
|
|
|
define_singleton_method old_setting do |warn: true|
|
|
|
|
if warn
|
2021-12-14 00:36:19 +08:00
|
|
|
Discourse.deprecate(
|
|
|
|
"`SiteSetting.#{old_setting}` has been deprecated. Please use `SiteSetting.#{new_setting}` instead.",
|
|
|
|
drop_from: version,
|
2018-11-14 16:09:26 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-11-14 17:32:32 +08:00
|
|
|
self.public_send(override ? new_setting : "_#{old_setting}")
|
2017-08-07 09:43:09 +08:00
|
|
|
end
|
|
|
|
|
2018-11-14 18:07:04 +08:00
|
|
|
unless override
|
|
|
|
SiteSetting.singleton_class.public_send(
|
|
|
|
:alias_method,
|
|
|
|
:"_#{old_setting}?",
|
|
|
|
:"#{old_setting}?",
|
|
|
|
)
|
|
|
|
end
|
2018-11-14 17:32:32 +08:00
|
|
|
|
2018-11-14 16:09:26 +08:00
|
|
|
define_singleton_method "#{old_setting}?" do |warn: true|
|
|
|
|
if warn
|
2021-12-14 00:36:19 +08:00
|
|
|
Discourse.deprecate(
|
|
|
|
"`SiteSetting.#{old_setting}?` has been deprecated. Please use `SiteSetting.#{new_setting}?` instead.",
|
|
|
|
drop_from: version,
|
2018-11-14 16:09:26 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-11-14 17:32:32 +08:00
|
|
|
self.public_send("#{override ? new_setting : "_" + old_setting}?")
|
2017-08-07 09:43:09 +08:00
|
|
|
end
|
|
|
|
|
2018-11-14 18:07:04 +08:00
|
|
|
unless override
|
|
|
|
SiteSetting.singleton_class.public_send(
|
|
|
|
:alias_method,
|
|
|
|
:"_#{old_setting}=",
|
|
|
|
:"#{old_setting}=",
|
|
|
|
)
|
|
|
|
end
|
2018-11-14 17:32:32 +08:00
|
|
|
|
2018-11-14 16:09:26 +08:00
|
|
|
define_singleton_method "#{old_setting}=" do |val, warn: true|
|
|
|
|
if warn
|
2021-12-14 00:36:19 +08:00
|
|
|
Discourse.deprecate(
|
|
|
|
"`SiteSetting.#{old_setting}=` has been deprecated. Please use `SiteSetting.#{new_setting}=` instead.",
|
|
|
|
drop_from: version,
|
2018-11-14 16:09:26 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-11-14 17:32:32 +08:00
|
|
|
self.public_send("#{override ? new_setting : "_" + old_setting}=", val)
|
2017-08-07 09:43:09 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|