Add new SiteSetting to disable locking of flags when assigned
This commit is contained in:
parent
a69bd40401
commit
246de40653
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -12,3 +12,6 @@ plugins:
|
|||
assigns_user_url_path:
|
||||
client: true
|
||||
default: "/latest?assigned={username}"
|
||||
assign_locks_flags:
|
||||
default: true
|
||||
client: true
|
||||
|
|
18
plugin.rb
18
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
|
||||
|
|
Loading…
Reference in New Issue