summaryrefslogtreecommitdiff
path: root/app/models/sip_account.rb
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-07 07:18:46 -0500
committerPeter Kozak <spag@golwen.net>2013-03-07 07:18:46 -0500
commit3cf3b921ee398472f2663cc1210932429f7710d9 (patch)
tree33ec12e142e22fa3ca945b1cfb71d0a78ecbd42d /app/models/sip_account.rb
parent88785c0ca2189c47b0a994473ef73a542ed36688 (diff)
target_group_ids_by_permission method added
Diffstat (limited to 'app/models/sip_account.rb')
-rw-r--r--app/models/sip_account.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb
index 81b9c1c..3340a76 100644
--- a/app/models/sip_account.rb
+++ b/app/models/sip_account.rb
@@ -155,12 +155,16 @@ class SipAccount < ActiveRecord::Base
);
end
-
- def target_sip_accounts_by_permission(permission)
+ def target_group_ids_by_permission(permission)
target_groups = Group.union(self.groups.collect{|g| g.permission_targets(permission)})
target_groups = target_groups + Group.union(self.sip_accountable.groups.collect{|g| g.permission_targets(permission)})
+
+ return target_groups
+ end
+
+ def target_sip_accounts_by_permission(permission)
sip_accounts = []
- GroupMembership.where(:group_id => target_groups).each do |group_membership|
+ GroupMembership.where(:group_id => target_group_ids_by_permission(permission)).each do |group_membership|
if group_membership.item.class == User || group_membership.item.class == Tenant
sip_accounts = sip_accounts + group_membership.item.sip_accounts
elsif group_membership.item.class == SipAccount