summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/group.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 993d274..6c65f70 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -16,6 +16,11 @@ class Group < ActiveRecord::Base
group_permissions.where(:permission => permission).pluck(:target_group_id)
end
+ def has_permission(target_type, target_id, permission)
+ target_group_ids = GroupMembership.where(:item_id => target_id, :item_type => target_type).pluck(:group_id)
+ return group_permissions.where(:permission => permission, :target_group_id => target_group_ids).first != nil
+ end
+
def self.union(sets=[])
group_ids = []
sets.each do |set|