From d5ac8f72af16fa5487ab1e16bf784e8125a7b450 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:30:12 +0100 Subject: destinationable_type can be a non model string --- app/models/call_forward.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models/call_forward.rb') diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index 195ac36..fcac294 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -2,7 +2,7 @@ class CallForward < ActiveRecord::Base attr_accessor :to_voicemail, :hunt_group_id - attr_accessible :phone_number_id, :call_forward_case_id, :timeout, + attr_accessible :call_forward_case_id, :timeout, :destination, :source, :depth, :active, :to_voicemail, :hunt_group_id, :call_forwardable_type, :call_forwardable_id, @@ -71,7 +71,7 @@ class CallForward < ActiveRecord::Base else destinationable_type = " #{self.destinationable_type}" end - if self.destinationable + if Module.constants.include?(destinationable_type.to_sym) && self.destinationable destination = "#{self.destinationable}#{destinationable_type}" else destination = "#{self.destination}#{destinationable_type}" -- cgit v1.2.3 From b67144bf911dd6e41775bda99646b3010195c8b3 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Mar 2013 09:11:19 +0100 Subject: split method removed --- app/models/call_forward.rb | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'app/models/call_forward.rb') diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index fcac294..de3afc4 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -56,7 +56,6 @@ class CallForward < ActiveRecord::Base end } - before_save :split_and_format_destination_numbers after_save :set_presence after_save :deactivate_concurring_entries, :if => Proc.new { |cf| cf.active == true } before_destroy :deactivate_connected_softkeys @@ -102,19 +101,6 @@ class CallForward < ActiveRecord::Base end private - def split_and_format_destination_numbers - if !self.destination.blank? - destinations = self.destination.gsub(/[^+0-9\,]/,'').gsub(/[\,]+/,',').split(/\,/).delete_if{|x| x.blank?} - self.destination = nil - if destinations.count > 0 - destinations.each do |single_destination| - self.destination = self.destination.to_s + ", #{PhoneNumber.parse_and_format(single_destination)}" - end - end - self.destination = self.destination.to_s.gsub(/[^+0-9\,]/,'').gsub(/[\,]+/,',').split(/\,/).sort.delete_if{|x| x.blank?}.join(', ') - end - end - def set_presence state = 'terminated' -- cgit v1.2.3 From 8968171f9cee1e3c4e5a9267484585a8c99c4c43 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 5 May 2013 09:53:48 +0200 Subject: resolve_prerouting method added --- app/models/call_forward.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/models/call_forward.rb') diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index de3afc4..a4bfbb5 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -56,6 +56,8 @@ class CallForward < ActiveRecord::Base end } + before_validation :resolve_prerouting + after_save :set_presence after_save :deactivate_concurring_entries, :if => Proc.new { |cf| cf.active == true } before_destroy :deactivate_connected_softkeys @@ -135,6 +137,18 @@ class CallForward < ActiveRecord::Base end end + def resolve_prerouting + if self.destinationable_type == 'PhoneNumber' && GsParameter.get('CALLFORWARD_DESTINATION_RESOLVE') != false + if self.call_forwardable.class == PhoneNumber + prerouting = PhoneNumber.resolve_prerouting(self.destination, self.call_forwardable.phone_numberable) + else + prerouting = PhoneNumber.resolve_prerouting(self.destination, self.call_forwardable) + end + if prerouting && !prerouting['destination_number'].blank? && prerouting['type'] == 'phonenumber' + self.destination = prerouting['destination_number'] + end + end + end def send_presence_event(state, call_forwarding_service = nil) dialplan_function = "cftg-#{self.id}" -- cgit v1.2.3