Commit 5cec15e9 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Split off protected ref access scopes

parent d29a3e9d
......@@ -25,8 +25,22 @@ module EE
# Returns access levels that grant the specified access type to the given user / group.
access_level_class = const_get("#{type}_access_level".classify)
protected_type = self.model_name.singular
scope :"#{type}_access_by_user", -> (user) { access_level_class.joins(protected_type.to_sym).where("#{protected_type}_id" => self.ids).merge(access_level_class.by_user(user)) }
scope :"#{type}_access_by_group", -> (group) { access_level_class.joins(protected_type.to_sym).where("#{protected_type}_id" => self.ids).merge(access_level_class.by_group(group)) }
scope(
:"#{type}_access_by_user",
-> (user) do
access_level_class.joins(protected_type.to_sym)
.where("#{protected_type}_id" => self.ids)
.merge(access_level_class.by_user(user))
end
)
scope(
:"#{type}_access_by_group",
-> (group) do
access_level_class.joins(protected_type.to_sym)
.where("#{protected_type}_id" => self.ids)
.merge(access_level_class.by_group(group))
end
)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment