summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-07 03:45:05 -0500
committerPeter Kozak <spag@golwen.net>2013-03-07 03:45:05 -0500
commit88785c0ca2189c47b0a994473ef73a542ed36688 (patch)
treeae7fcfd4612f133c87d651b07e8828e03ee4bb91 /app
parent1bcb85853b282606f28f1c9cd7f4e13d494a7290 (diff)
has_permission method added
Diffstat (limited to 'app')
-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|