diff options
-rw-r--r-- | app/models/sip_account.rb | 10 |
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 |