summaryrefslogtreecommitdiff
path: root/app/models/softkey.rb
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-07 03:44:36 -0500
committerPeter Kozak <spag@golwen.net>2013-03-07 03:44:36 -0500
commit1bcb85853b282606f28f1c9cd7f4e13d494a7290 (patch)
treef395fe0afd5f64cae4280951925b25c0b5ff95ef /app/models/softkey.rb
parent2964ebf277568536ac215f3a651e1841a73d68f8 (diff)
presence permissions for softkeys added
Diffstat (limited to 'app/models/softkey.rb')
-rw-r--r--app/models/softkey.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/models/softkey.rb b/app/models/softkey.rb
index 470605c..6063017 100644
--- a/app/models/softkey.rb
+++ b/app/models/softkey.rb
@@ -42,6 +42,10 @@ class Softkey < ActiveRecord::Base
return call_forwards
end
+ def possible_blf_sip_accounts
+ self.sip_account.target_sip_accounts_by_permission('presence')
+ end
+
def to_s
if self.softkeyable.blank?
if ['log_out', 'log_in'].include?(self.softkey_function.name)
@@ -77,7 +81,29 @@ class Softkey < ActiveRecord::Base
if self.softkey_function_id != nil
case self.softkey_function.name
when 'blf'
+ has_permission = false
self.softkeyable = PhoneNumber.where(:number => self.number, :phone_numberable_type => 'SipAccount').first.try(:phone_numberable)
+ if self.softkeyable
+ self.sip_account.groups.each do |group|
+ if group.has_permission(self.softkeyable.class.name, self.softkeyable.id, :presence)
+ has_permission = true
+ break
+ end
+ end
+ if !has_permission && self.sip_account.sip_accountable
+ self.sip_account.sip_accountable.groups.each do |group|
+ if group.has_permission(self.softkeyable.class.name, self.softkeyable.id, :presence)
+ has_permission = true
+ break
+ end
+ end
+ end
+ end
+
+ if !has_permission
+ self.softkeyable = nil
+ self.number = nil
+ end
when 'conference'
self.softkeyable = PhoneNumber.where(:number => self.number, :phone_numberable_type => 'Conference').first.try(:phone_numberable)
when 'call_forwarding'