summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-27 10:33:28 +0100
committerPeter Kozak <spag@golwen.net>2013-03-27 10:33:28 +0100
commit3a20974d9403877ffa9a720efd999df49a1733bf (patch)
treecaefaa748ac57c42ac65ada104dc8f74e87a8e07
parentb9e37bcb2ba1d54ab32dc1185266d7ffa0a0c3b9 (diff)
list possible voicemail accounts
-rw-r--r--app/controllers/call_forwards_controller.rb41
1 files changed, 36 insertions, 5 deletions
diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb
index b30ee9e..858ed12 100644
--- a/app/controllers/call_forwards_controller.rb
+++ b/app/controllers/call_forwards_controller.rb
@@ -131,15 +131,46 @@ class CallForwardsController < ApplicationController
phone_number_destination = CallForwardingDestination.new()
phone_number_destination.id = ':PhoneNumber'
phone_number_destination.label = 'Phone Number'
- voice_mail_destination = CallForwardingDestination.new()
- voice_mail_destination.id = ':Voicemail'
- voice_mail_destination.label = 'Voice Mail'
call_forwarding_destinations = [
phone_number_destination,
- voice_mail_destination,
]
+ if @parent.try(:voicemail_accounts)
+ @parent.voicemail_accounts.each do |voicemail_account|
+ call_forwards_destination = CallForwardingDestination.new()
+ call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount"
+ call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}"
+ call_forwarding_destinations << call_forwards_destination
+ end
+ end
+
+ if @parent.class == SipAccount
+ sip_account = @parent
+ if sip_account.sip_accountable.class == User || sip_account.sip_accountable.class == Tenant
+ sip_account.sip_accountable.voicemail_accounts.each do |voicemail_account|
+ call_forwards_destination = CallForwardingDestination.new()
+ call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount"
+ call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}"
+ call_forwarding_destinations << call_forwards_destination
+ end
+ end
+ end
+
+ if @parent.class == PhoneNumber
+ if @parent.phone_numberable.class == SipAccount
+ sip_account = @parent.phone_numberable
+ if sip_account.sip_accountable.class == User || sip_account.sip_accountable.class == Tenant
+ sip_account.sip_accountable.voicemail_accounts.each do |voicemail_account|
+ call_forwards_destination = CallForwardingDestination.new()
+ call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount"
+ call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}"
+ call_forwarding_destinations << call_forwards_destination
+ end
+ end
+ end
+ end
+
if GuiFunction.display?('huntgroup_in_destination_field_in_call_forward_form', current_user)
HuntGroup.all.each do |hunt_group|
hunt_group_destination = CallForwardingDestination.new()
@@ -149,7 +180,7 @@ class CallForwardsController < ApplicationController
end
end
- return call_forwarding_destinations
+ return call_forwarding_destinations.uniq
end
end