Allow TL4 users to accept answers (configurable via site setting)

This commit is contained in:
Sam 2016-03-31 12:06:03 +11:00
parent 11a0c293b8
commit afb1c91c11
3 changed files with 6 additions and 1 deletions

View File

@ -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"

View File

@ -2,3 +2,6 @@ plugins:
allow_solved_on_all_topics:
default: false
client: true
accept_all_solutions_trust_level:
default: 4
client: true

View File

@ -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