diff options
-rw-r--r-- | app/controllers/call_forwards_controller.rb | 3 | ||||
-rw-r--r-- | app/models/call_forward.rb | 27 | ||||
-rw-r--r-- | app/models/hunt_group.rb | 2 | ||||
-rw-r--r-- | app/models/voicemail_account.rb | 8 | ||||
-rw-r--r-- | app/views/call_forwards/_form_core.html.haml | 4 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/dialplan.lua | 3 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/session.lua | 10 |
7 files changed, 40 insertions, 17 deletions
diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb index 1721aa3..f9d2faa 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -29,8 +29,8 @@ class CallForwardsController < ApplicationController @call_forward.depth = GsParameter.get('DEFAULT_CALL_FORWARD_DEPTH') @call_forward.active = true @call_forwarding_destinations = call_forwarding_destination_types() + @call_forward.destinationable_type = 'PhoneNumber' @call_forward.destination = GsParameter.get('CALLFORWARD_DESTINATION_DEFAULT').to_s if defined?(GsParameter.get('CALLFORWARD_DESTINATION_DEFAULT')) - @destination_phone_number = @call_forward.destination @available_call_forward_cases = [] CallForwardCase.all.each do |available_call_forward_case| @@ -66,7 +66,6 @@ class CallForwardsController < ApplicationController @available_call_forward_cases = CallForwardCase.all @call_forwarding_destinations = call_forwarding_destination_types() @available_greetings = available_greetings() - @destination_phone_number = @call_forward.destination if @call_forward.call_forwarding_destination == ':PhoneNumber' end def update diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index a4bfbb5..0df2a35 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -7,7 +7,8 @@ class CallForward < ActiveRecord::Base :hunt_group_id, :call_forwardable_type, :call_forwardable_id, :call_forwarding_destination, :position, :uuid, - :destinationable_type, :destinationable_id + :destinationable_type, :destinationable_id, + :destination_phone_number, :destination_greeting belongs_to :call_forwardable, :polymorphic => true belongs_to :destinationable, :polymorphic => true @@ -88,6 +89,30 @@ class CallForward < ActiveRecord::Base self.destinationable_id, delimeter, self.destinationable_type = destination_record.to_s.partition(':') end + def destination_phone_number + if self.destinationable_type.to_s.downcase == 'phonenumber' + return self.destination + end + end + + def destination_phone_number=(destination_number) + if self.destinationable_type.to_s.downcase == 'phonenumber' + self.destination = destination_number + end + end + + def destination_greeting + if self.destinationable_type.to_s.downcase == 'voicemailaccount' + return self.destination + end + end + + def destination_greeting=(destination_file) + if self.destinationable_type.to_s.downcase == 'voicemailaccount' + self.destination = destination_file + end + end + def toggle self.active = ! self.active return self.save diff --git a/app/models/hunt_group.rb b/app/models/hunt_group.rb index 93279ae..fac0cc5 100644 --- a/app/models/hunt_group.rb +++ b/app/models/hunt_group.rb @@ -2,7 +2,7 @@ class HuntGroup < ActiveRecord::Base attr_accessible :name, :strategy, :seconds_between_jumps, :phone_numbers_attributes belongs_to :tenant, :touch => true - has_many :destrination_call_forwards, :as => :destinationable, :dependent => :destroy + has_many :destrination_call_forwards, :class_name => 'CallForward', :as => :destinationable, :dependent => :destroy has_many :call_forwards, :as => :call_forwardable, :dependent => :destroy validates_uniqueness_of :name, :scope => :tenant_id, diff --git a/app/models/voicemail_account.rb b/app/models/voicemail_account.rb index 8ec181f..298516e 100644 --- a/app/models/voicemail_account.rb +++ b/app/models/voicemail_account.rb @@ -21,9 +21,9 @@ class VoicemailAccount < ActiveRecord::Base def notify_to send_notification = nil - if self.voicemail_settings.where(:name => 'notify', :value => true).first + if self.voicemail_settings.where(:name => 'notify', :value => 'true').first send_notification = true - elsif self.voicemail_settings.where(:name => 'notify', :value => false).first + elsif self.voicemail_settings.where(:name => 'notify', :value => 'false').first send_notification = false end @@ -49,9 +49,9 @@ class VoicemailAccount < ActiveRecord::Base def notification_setting(name) setting = nil - if self.voicemail_settings.where(:name => name, :value => true).first + if self.voicemail_settings.where(:name => name, :value => 'true').first setting = true - elsif self.voicemail_settings.where(:name => name, :value => false).first + elsif self.voicemail_settings.where(:name => name, :value => 'false').first setting = false end diff --git a/app/views/call_forwards/_form_core.html.haml b/app/views/call_forwards/_form_core.html.haml index b730941..1c9ec30 100644 --- a/app/views/call_forwards/_form_core.html.haml +++ b/app/views/call_forwards/_form_core.html.haml @@ -7,11 +7,11 @@ = f.input :call_forwarding_destination , :as => :select, :collection => @call_forwarding_destinations, :label => t('call_forwards.form.call_forwarding_destination.label'), :hint => conditional_hint('call_forwards.form.call_forwarding_destination.hint'), :include_blank => false %div{:id => 'destination_phone_number_div'} - = f.input :destination, :label => t('call_forwards.form.destination_phone_number.label'), :hint => conditional_hint('call_forwards.form.destination_phone_number.hint'), :input_html => { :id => 'destination_phone_number', :value => @destination_phone_number } + = f.input :destination_phone_number, :label => t('call_forwards.form.destination_phone_number.label'), :hint => conditional_hint('call_forwards.form.destination_phone_number.hint'), :input_html => { :id => 'destination_phone_number' } - if @available_greetings.any? %div{:id => 'destination_greeting_div'} - = f.input :destination, :as => :select, :collection => @available_greetings, :label => t('call_forwards.form.destination_greeting.label'), :hint => conditional_hint('call_forwards.form.destination_greeting.hint'), :input_html => { :id => 'destination_greeting' } + = f.input :destination_greeting, :as => :select, :collection => @available_greetings, :label => t('call_forwards.form.destination_greeting.label'), :hint => conditional_hint('call_forwards.form.destination_greeting.hint'), :input_html => { :id => 'destination_greeting' } = f.input :active, :label => t('call_forwards.form.active.label'), :hint => conditional_hint('call_forwards.form.active.hint') diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 370aa0b..ac8a07d 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -896,9 +896,10 @@ function Dialplan.run(self, destination) self.caller:set_variable('sound_prefix', common.array.try(self.config, 'sounds.' .. tostring(self.caller.language))); self.log:info('DIALPLAN start - caller_id: ',self.caller.caller_id_number, ' "', self.caller.caller_id_name, '" , number: ', destination.number, ', language: ', self.caller.language); - self.caller.static_caller_id_number = self.caller.caller_id_number; self.caller.static_caller_id_name = self.caller.caller_id_name; + self.caller:set_variable('gs_caller_id_number', self.caller.caller_id_number); + self.caller:set_variable('gs_caller_id_name', self.caller.caller_id_name); local result = { continue = false }; local loop = self.caller.loop_count; diff --git a/misc/freeswitch/scripts/dialplan/session.lua b/misc/freeswitch/scripts/dialplan/session.lua index 1d907c5..7023c5e 100644 --- a/misc/freeswitch/scripts/dialplan/session.lua +++ b/misc/freeswitch/scripts/dialplan/session.lua @@ -8,6 +8,8 @@ Session = {} -- create session object function Session.new(self, arg) + require 'common.str'; + arg = arg or {} object = arg.object or {} setmetatable(object, self); @@ -29,8 +31,8 @@ function Session.init_channel_variables(self) self.destination_number = self:expand_variables(self:to_s('destination_number')); self.called_number = self.destination_number; - self.caller_id_number = self:to_s('caller_id_number'); - self.caller_id_name = self:to_s('caller_id_name'); + self.caller_id_number = self.session:getVariable('gs_caller_id_number') or self:to_s('caller_id_number'); + self.caller_id_name = self.session:getVariable('gs_caller_id_name') or self:to_s('caller_id_name'); self.caller_phone_number = self.caller_id_number; self.caller_phone_numbers = {self.caller_id_number}; @@ -93,25 +95,21 @@ end -- Cast channel variable to string function Session.to_s(self, variable_name) - require 'common.str' return common.str.to_s(self.session:getVariable(variable_name)); end -- Cast channel variable to integer function Session.to_i(self, variable_name) - require 'common.str' return common.str.to_i(self.session:getVariable(variable_name)); end -- Cast channel variable to boolean function Session.to_b(self, variable_name) - require 'common.str' return common.str.to_b(self.session:getVariable(variable_name)); end -- Split channel variable to table function Session.to_a(self, variable_name) - require 'common.str' return common.str.to_a(self.session:getVariable(variable_name)); end |