Two extra options (#138)

Two extra options (#138)

  • Make it possible to disallow topic starters to accept a solution

  • Make adding QAPage schema markup optional

  • Address @eviltrout’s comments

Co-authored-by: Richard richard@communiteq.com

diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index cdf3b79..697ee04 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -9,6 +9,8 @@ en:
     show_filter_by_solved_status: "Show a dropdown to filter a topic list by solved status."
     notify_on_staff_accept_solved: "Send notification to the topic creator when a post is marked as solution by a staff."
     disable_solved_education_message: "Disable education message for solved topics."
+    accept_solutions_topic_author: "Allow the topic author to accept a solution."
+    solved_add_schema_markup: "Add QAPage schema markup to HTML."
   reports:
     accepted_solutions:
       title: "Accepted solutions"
diff --git a/config/settings.yml b/config/settings.yml
index 4b73877..335cdf5 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -25,3 +25,13 @@ plugins:
     default: false
   disable_solved_education_message:
     default: false
+  accept_solutions_topic_author:
+    default: true
+  solved_add_schema_markup:
+    type: enum
+    default: "always"
+    choices:
+      - "never"
+      - "always"
+      - "answered only"
+
diff --git a/plugin.rb b/plugin.rb
index 01f5e14..78e4405 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -282,6 +282,7 @@ SQL
     # it can get confusing to have this on every page and it should make page 1
     # a bit more prominent + cut down on pointless work
 
+    return "" if SiteSetting.solved_add_schema_markup == "never"
     return "" if !controller.guardian.allow_accepted_answers_on_category?(topic.category_id)
 
     first_post = topic_view.posts&.first
@@ -313,6 +314,8 @@ SQL
           'name' => accepted_answer.user&.username
         }
       }
+    else
+      return "" if SiteSetting.solved_add_schema_markup == "answered only"
     end
 
     ['<script type="application/ld+json">', MultiJson.dump(
@@ -483,7 +486,7 @@ SQL
         return true if can_perform_action_available_to_group_moderators?(topic)
       end
 
-      topic.user_id == current_user.id && !topic.closed
+      topic.user_id == current_user.id && !topic.closed && SiteSetting.accept_solutions_topic_author
     end
   end
 

GitHub sha: ca0dbd6d4c99958b88a1c9ec0661728ddac468b1

This commit appears in #138 which was approved by eviltrout. It was merged by eviltrout.