Add new SiteSetting to disable locking of flags when assigned

This commit is contained in:
Robin Ward 2017-10-13 10:46:35 -04:00
parent a69bd40401
commit 246de40653
4 changed files with 15 additions and 9 deletions

View File

@ -12,7 +12,7 @@ function initialize(api) {
api.modifyClass('component:flagged-post', { api.modifyClass('component:flagged-post', {
@computed('flaggedPost.topic.assigned_to_user_id', 'filter') @computed('flaggedPost.topic.assigned_to_user_id', 'filter')
canAct(assignedToUserId, filter) { canAct(assignedToUserId, filter) {
if (assignedToUserId && this.currentUser.id !== assignedToUserId) { if (this.siteSettings.assign_locks_flags && assignedToUserId && this.currentUser.id !== assignedToUserId) {
return false; return false;
} }

View File

@ -9,6 +9,7 @@ en:
assign_other_regex: "Regex that needs to pass for assigning topics to others via mention. Example 'your list'." 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_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" 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: discourse_assign:
assigned_to: "Topic assigned to @%{username}" assigned_to: "Topic assigned to @%{username}"
unassigned: "Topic was unassigned" unassigned: "Topic was unassigned"

View File

@ -12,3 +12,6 @@ plugins:
assigns_user_url_path: assigns_user_url_path:
client: true client: true
default: "/latest?assigned={username}" default: "/latest?assigned={username}"
assign_locks_flags:
default: true
client: true

View File

@ -20,14 +20,16 @@ after_initialize do
# Raise an invalid access error if a user tries to act on something # Raise an invalid access error if a user tries to act on something
# not assigned to them # not assigned to them
DiscourseEvent.on(:before_staff_flag_action) do |args| DiscourseEvent.on(:before_staff_flag_action) do |args|
if custom_fields = args[:post].topic.custom_fields if SiteSetting.assign_locks_flags?
if assigned_to_id = custom_fields['assigned_to_id'] if custom_fields = args[:post].topic.custom_fields
unless assigned_to_id.to_i == args[:user].id if assigned_to_id = custom_fields['assigned_to_id']
raise Discourse::InvalidAccess.new( unless assigned_to_id.to_i == args[:user].id
"That flag has been assigned to another user", raise Discourse::InvalidAccess.new(
nil, "That flag has been assigned to another user",
custom_message: 'discourse_assign.flag_assigned' nil,
) custom_message: 'discourse_assign.flag_assigned'
)
end
end end
end end
end end