From afb1c91c115ac567883e8ee30bcc7a3d33ef9ece Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 31 Mar 2016 12:06:03 +1100 Subject: [PATCH] Allow TL4 users to accept answers (configurable via site setting) --- config/locales/server.en.yml | 1 + config/settings.yml | 3 +++ plugin.rb | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index c75340c..ce4e25f 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1,6 +1,7 @@ en: site_settings: allow_solved_on_all_topics: "Allow users to select solutions on all topics (by default you control this by editing categories)" + accept_all_solutions_trust_level: "Minimum trust level required to accept solutions on any topic (even when not OP)" reports: accepted_solutions: title: "Accepted solutions" diff --git a/config/settings.yml b/config/settings.yml index 0e0bb07..9f46b5c 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -2,3 +2,6 @@ plugins: allow_solved_on_all_topics: default: false client: true + accept_all_solutions_trust_level: + default: 4 + client: true diff --git a/plugin.rb b/plugin.rb index 6adb14e..9b1a407 100644 --- a/plugin.rb +++ b/plugin.rb @@ -193,7 +193,8 @@ after_initialize do def can_accept_answer?(topic) allow_accepted_answers_on_category?(topic.category_id) && ( is_staff? || ( - authenticated? && !topic.closed? && topic.user_id == current_user.id + authenticated? && ((!topic.closed? && topic.user_id == current_user.id) || + (current_user.trust_level >= SiteSetting.accept_all_solutions_trust_level)) ) ) end