diff --git a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 index add60e7..4a136cd 100644 --- a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 +++ b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 @@ -12,7 +12,7 @@ function initialize(api) { api.modifyClass('component:flagged-post', { @computed('flaggedPost.topic.assigned_to_user_id', 'filter') canAct(assignedToUserId, filter) { - if (assignedToUserId && this.currentUser.id !== assignedToUserId) { + if (this.siteSettings.assign_locks_flags && assignedToUserId && this.currentUser.id !== assignedToUserId) { return false; } diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 93f5453..8b730b6 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -9,6 +9,7 @@ en: assign_other_regex: "Regex that needs to pass for assigning topics to others via mention. Example 'your list'." unassign_on_group_archive: "When a message is archived by a group, unassign message (reassign if moved back to inbox)" unassign_on_close: "When a topic is closed unassign topic" + assign_locks_flags: "When a topic is assigned to a staff member, its flags can only be handled by that person" discourse_assign: assigned_to: "Topic assigned to @%{username}" unassigned: "Topic was unassigned" diff --git a/config/settings.yml b/config/settings.yml index d0da05b..ab5c385 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -12,3 +12,6 @@ plugins: assigns_user_url_path: client: true default: "/latest?assigned={username}" + assign_locks_flags: + default: true + client: true diff --git a/plugin.rb b/plugin.rb index 7badd29..bcaa16c 100644 --- a/plugin.rb +++ b/plugin.rb @@ -20,14 +20,16 @@ after_initialize do # Raise an invalid access error if a user tries to act on something # not assigned to them DiscourseEvent.on(:before_staff_flag_action) do |args| - if custom_fields = args[:post].topic.custom_fields - if assigned_to_id = custom_fields['assigned_to_id'] - unless assigned_to_id.to_i == args[:user].id - raise Discourse::InvalidAccess.new( - "That flag has been assigned to another user", - nil, - custom_message: 'discourse_assign.flag_assigned' - ) + if SiteSetting.assign_locks_flags? + if custom_fields = args[:post].topic.custom_fields + if assigned_to_id = custom_fields['assigned_to_id'] + unless assigned_to_id.to_i == args[:user].id + raise Discourse::InvalidAccess.new( + "That flag has been assigned to another user", + nil, + custom_message: 'discourse_assign.flag_assigned' + ) + end end end end