summaryrefslogtreecommitdiff
path: root/app/models/group.rb
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-28 14:26:17 +0100
committerPeter Kozak <spag@golwen.net>2013-03-28 14:26:17 +0100
commitd8a6f81af4d1752c9c28c6560fb9bc1c52e7ab9c (patch)
treeffe6f30999ddf3d3ca3261154d56b07270cd79f3 /app/models/group.rb
parent735518861ed7a0a400298be0b951d2b4086a5e22 (diff)
target_group_ids_by_permission method added
Diffstat (limited to 'app/models/group.rb')
-rw-r--r--app/models/group.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 6c65f70..849fa71 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -29,4 +29,12 @@ class Group < ActiveRecord::Base
return group_ids.uniq
end
+
+ def self.target_group_ids_by_permission(permission, *group_sets)
+ target_groups = []
+ group_sets.each do |groups|
+ target_groups = target_groups + Group.union(groups.collect{|g| g.permission_targets(permission)})
+ end
+ return target_groups.uniq
+ end
end