FEATURE: add me and nobody support
This commit is contained in:
parent
48ac8902ef
commit
6d4f7f0f3a
20
plugin.rb
20
plugin.rb
|
@ -265,8 +265,23 @@ SQL
|
||||||
TopicQuery.add_custom_filter(:assigned) do |results, topic_query|
|
TopicQuery.add_custom_filter(:assigned) do |results, topic_query|
|
||||||
if topic_query.guardian.is_staff? || SiteSetting.assigns_public
|
if topic_query.guardian.is_staff? || SiteSetting.assigns_public
|
||||||
username = topic_query.options[:assigned]
|
username = topic_query.options[:assigned]
|
||||||
user_id = User.where(username_lower: username.downcase).pluck(:id).first if username.present? && username != "*"
|
|
||||||
if user_id || username == "*"
|
user_id = topic_query.guardian.user.id if username == "me"
|
||||||
|
|
||||||
|
special = ["*", "nobody"].include?(username)
|
||||||
|
|
||||||
|
if username.present? && !special
|
||||||
|
user_id ||= User.where(username_lower: username.downcase).pluck(:id).first
|
||||||
|
end
|
||||||
|
|
||||||
|
if user_id || special
|
||||||
|
|
||||||
|
if username == "nobody"
|
||||||
|
results = results.joins("LEFT JOIN topic_custom_fields tc_assign ON
|
||||||
|
topics.id = tc_assign.topic_id AND
|
||||||
|
tc_assign.name = 'assigned_to_id'")
|
||||||
|
.where("tc_assign.name IS NULL")
|
||||||
|
else
|
||||||
|
|
||||||
if username == "*"
|
if username == "*"
|
||||||
filter = "AND tc_assign.value IS NOT NULL"
|
filter = "AND tc_assign.value IS NOT NULL"
|
||||||
|
@ -281,6 +296,7 @@ SQL
|
||||||
")
|
")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
results
|
results
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue