summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/v1/calls_controller.rb41
-rw-r--r--app/controllers/api/v1/phone_book_entries_controller.rb77
-rw-r--r--app/controllers/api/v1/switchboards_controller.rb12
-rw-r--r--app/controllers/call_forwards_controller.rb17
-rw-r--r--app/controllers/call_histories_controller.rb13
-rw-r--r--app/controllers/cdrs_controller.rb43
-rw-r--r--app/controllers/config_snom_controller.rb777
-rw-r--r--app/controllers/extension_modules_controller.rb73
-rw-r--r--app/controllers/gateway_headers_controller.rb57
-rw-r--r--app/controllers/sip_accounts_controller.rb1
-rw-r--r--app/controllers/switchboard_entries_controller.rb2
-rw-r--r--app/controllers/switchboards_controller.rb4
-rw-r--r--app/controllers/trigger_controller.rb2
-rw-r--r--app/controllers/voicemail_settings_controller.rb3
14 files changed, 855 insertions, 267 deletions
diff --git a/app/controllers/api/v1/calls_controller.rb b/app/controllers/api/v1/calls_controller.rb
new file mode 100644
index 0000000..329bd94
--- /dev/null
+++ b/app/controllers/api/v1/calls_controller.rb
@@ -0,0 +1,41 @@
+module Api
+ module V1
+ class CallsController < ApplicationController
+ respond_to :json
+
+ def index
+ @calls = Call.limit(10)
+
+ respond_with @calls
+ end
+
+ def show
+ @call = Call.find(params[:id])
+
+ if params[:transfer_blind]
+ @call.transfer_blind(params[:transfer_blind])
+ else
+ if params[:transfer_attended] && @call.b_sip_account.phones.first.phone_model.manufacturer.name == 'SNOM Technology AG'
+ phone = @call.b_sip_account.phones.first
+ ip_address = phone.ip_address
+ http_user = phone.http_user
+ http_password = phone.http_password
+
+ # Hold
+ open("http://#{ip_address}/command.htm?key=F_HOLD", :http_basic_authentication=>[http_user, http_password])
+
+ # Call the other party
+ (0..(params[:transfer_attended].length - 1)).each do |i|
+ digit = params[:transfer_attended][i]
+ open("http://#{ip_address}/command.htm?key=#{digit}", :http_basic_authentication=>[http_user, http_password])
+ end
+ open("http://#{ip_address}/command.htm?key=ENTER", :http_basic_authentication=>[http_user, http_password])
+ end
+ end
+
+ respond_with @call
+ end
+
+ end
+ end
+end
diff --git a/app/controllers/api/v1/phone_book_entries_controller.rb b/app/controllers/api/v1/phone_book_entries_controller.rb
new file mode 100644
index 0000000..6a39623
--- /dev/null
+++ b/app/controllers/api/v1/phone_book_entries_controller.rb
@@ -0,0 +1,77 @@
+module Api
+ module V1
+ class PhoneBookEntriesController < ApplicationController
+ respond_to :json
+
+ def index
+ query = params[:query]
+ switchboard = Switchboard.find(params[:switchboard_id])
+
+ return nil if query.blank?
+
+ current_ability = Ability.new(current_user)
+ phone_book_entries = PhoneBookEntry.accessible_by(current_ability)
+
+ if query.match(/^\+?\d+$/) != nil && switchboard && switchboard.reverse_lookup_activated
+ # Find by phone number
+ phone_book_entries_ids = phone_book_entries.map{|entry| entry.id}
+ found_phone_numbers = PhoneNumber.
+ where(:phone_numberable_type => 'PhoneBookEntry', :phone_numberable_id => phone_book_entries_ids).
+ where('number LIKE ?', "#{query}%")
+ search_result = phone_book_entries.where(:id => found_phone_numbers.map{|entry| entry.phone_numberable_id})
+ elsif query.match(/^[\"\'](.*)[\"\']$/) != nil
+ # The User searched for =>'example'<= so he wants an EXACT search for that.
+ # This is the fasted and most accurate way of searching.
+ # The order to search is: last_name, first_name and organization.
+ # It stops searching as soon as it finds results.
+ #
+ query = $1
+ search_result = phone_book_entries.where(:last_name => query)
+ search_result = phone_book_entries.where(:first_name => query) if search_result.blank?
+ search_result = phone_book_entries.where(:organization => query) if search_result.blank?
+
+ exact_search = true
+ else
+ # Search with SQL LIKE
+ #
+ search_result = phone_book_entries.
+ where( '( ( last_name LIKE ? ) OR ( first_name LIKE ? ) OR ( organization LIKE ? ) )',
+ "#{query}%", "#{query}%", "#{query}%" )
+
+ exact_search = false
+ end
+
+ # Let's have a run with our phonetic search.
+ #
+ phonetic_query = PhoneBookEntry.koelner_phonetik(query)
+ phonetic_search_result = phone_book_entries.where(:last_name_phonetic => phonetic_query)
+ phonetic_search_result = phone_book_entries.where(:first_name_phonetic => phonetic_query) if phonetic_search_result.blank?
+ phonetic_search_result = phone_book_entries.where(:organization_phonetic => phonetic_query) if phonetic_search_result.blank?
+
+ if phonetic_search_result.blank?
+ # Let's try the search with SQL LIKE. Just in case.
+ #
+ phonetic_search_result = phone_book_entries.where( 'last_name_phonetic LIKE ?', "#{phonetic_query}%" )
+ phonetic_search_result = phone_book_entries.where( 'first_name_phonetic LIKE ?', "#{phonetic_query}%" ) if phonetic_search_result.blank?
+ phonetic_search_result = phone_book_entries.where( 'organization_phonetic LIKE ?', "#{phonetic_query}%" ) if phonetic_search_result.blank?
+ end
+
+ phonetic_search = true if phonetic_search_result.any?
+
+ phone_book_entries = search_result
+
+ if phone_book_entries.count == 0 && exact_search == false && phonetic_search
+ phone_book_entries = phonetic_search_result
+ end
+
+ # Let's sort the results and do pagination.
+ #
+ phone_book_entries = phone_book_entries.
+ order([ :last_name, :first_name, :organization ]).limit(20)
+
+ respond_with phone_book_entries
+ end
+
+ end
+ end
+end
diff --git a/app/controllers/api/v1/switchboards_controller.rb b/app/controllers/api/v1/switchboards_controller.rb
index e6996ca..4d6607a 100644
--- a/app/controllers/api/v1/switchboards_controller.rb
+++ b/app/controllers/api/v1/switchboards_controller.rb
@@ -5,16 +5,20 @@ module Api
def index
@user = current_user
- @switchboards = @user.switchboards
+ @switchboards = Switchboard.all
- respond_with @switchboards
+ if can? :read, @switchboards
+ respond_with @switchboards
+ end
end
def show
@user = current_user
- @switchboard = @user.switchboards.find(params[:id])
+ @switchboard = Switchboard.find(params[:id])
- respond_with @switchboard
+ if can? :read, @switchboard
+ respond_with @switchboard
+ end
end
end
end
diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb
index 1721aa3..0d0f946 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
@@ -118,7 +117,7 @@ class CallForwardsController < ApplicationController
add_breadcrumb @parent, sip_account_phone_number_path(@sip_account, @parent)
elsif @parent.class == SipAccount
add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
- add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user)
+ add_breadcrumb @user, tenant_user_path(@user.current_tenant, @user)
add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user)
end
end
@@ -188,6 +187,18 @@ class CallForwardsController < ApplicationController
end
end
+ if @parent.class == HuntGroup && @parent.tenant
+ @parent.tenant.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}"
+ if !destinations_hash[call_forwards_destination.id]
+ destinations_hash[call_forwards_destination.id] = true
+ call_forwarding_destinations << call_forwards_destination
+ end
+ end
+ end
+
if @parent.class == PhoneNumber
if @parent.phone_numberable.class == SipAccount
sip_account = @parent.phone_numberable
diff --git a/app/controllers/call_histories_controller.rb b/app/controllers/call_histories_controller.rb
index a4d0c21..edd19cb 100644
--- a/app/controllers/call_histories_controller.rb
+++ b/app/controllers/call_histories_controller.rb
@@ -71,8 +71,17 @@ class CallHistoriesController < ApplicationController
@call_history = CallHistory.where(:id => params[:id]).first
if can?(:call, @call_history) && @sip_account.registration
phone_number = @call_history.display_number
- if ! phone_number.blank?
- @sip_account.call(phone_number)
+ caller_id_number = phone_number
+ if ! phone_number.blank?
+ if @sip_account.clir != @call_history.clir
+ if @call_history.clir == true
+ phone_number = 'f-dcliron-' + phone_number
+ elsif call.clir == false
+ phone_number = 'f-dcliroff-' + phone_number
+ end
+ end
+
+ @sip_account.call(phone_number, caller_id_number, @call_history.display_name)
end
end
redirect_to(:back)
diff --git a/app/controllers/cdrs_controller.rb b/app/controllers/cdrs_controller.rb
new file mode 100644
index 0000000..3815f52
--- /dev/null
+++ b/app/controllers/cdrs_controller.rb
@@ -0,0 +1,43 @@
+class CdrsController < ApplicationController
+ load_and_authorize_resource :tenant
+
+ before_filter :set_and_authorize_parent
+ before_filter :spread_breadcrumbs
+
+ helper_method :sort_column, :sort_descending
+
+ def index
+ @cdrs = Cdr.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate(
+ :page => params[:page],
+ :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE')
+ )
+ end
+
+ def show
+ end
+
+ def destroy
+ @cdr.destroy
+ m = method( :"#{@parent.class.name.underscore}_cdrs_url" )
+ redirect_to m.(@parent), :notice => t('cdrs.controller.successfuly_destroyed')
+ end
+
+ private
+ def set_and_authorize_parent
+ @parent = @user || @tenant
+ authorize! :read, @parent
+ end
+
+ def spread_breadcrumbs
+ add_breadcrumb t("cdrs.index.page_title"), tenant_cdrs_path(@tenant)
+ end
+
+ def sort_descending
+ params[:desc].to_s == 'true'
+ end
+
+ def sort_column
+ Cdr.column_names.include?(params[:sort]) ? params[:sort] : 'start_stamp'
+ end
+
+end
diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb
index 4b9489b..1cac4b2 100644
--- a/app/controllers/config_snom_controller.rb
+++ b/app/controllers/config_snom_controller.rb
@@ -1,6 +1,6 @@
class ConfigSnomController < ApplicationController
- MAX_SIP_ACCOUNTS_COUNT = 11
- MAX_SOFTKEYS_COUNT = 12 + (42 * 3) - 1
+ MAX_SIP_ACCOUNTS_COUNT = 11
+ MAX_SOFTKEYS_COUNT = 12 + (42 * 3) - 1
MAX_DIRECTORY_ENTRIES = 20
KEY_REGEXP = {
'0' => "[ -.,_0]+",
@@ -15,12 +15,115 @@ class ConfigSnomController < ApplicationController
'9' => "[wxyz9]",
}
- skip_authorization_check
-
- before_filter { |controller|
+ SNOM_PHONE_DEFAULTS = {
+ 'Snom 300' => {
+ :softkeys_physical => 6,
+ :softkeys_logical => 6,
+ },
+ 'Snom 320' => {
+ :softkeys_physical => 12,
+ :softkeys_logical => 12,
+ },
+ 'Snom 360' => {
+ :softkeys_physical => 12,
+ :softkeys_logical => 12,
+ },
+ 'Snom 360' => {
+ :softkeys_physical => 12,
+ :softkeys_logical => 12,
+ },
+ 'Snom 370' => {
+ :softkeys_physical => 12,
+ :softkeys_logical => 12,
+ },
+ 'Snom 820' => {
+ :softkeys_physical => 4,
+ :softkeys_logical => 16,
+ },
+ 'Snom 821' => {
+ :softkeys_physical => 4,
+ :softkeys_logical => 12,
+ },
+ 'Snom 870' => {
+ :softkeys_physical => 0,
+ :softkeys_logical => 16,
+ },
+ 'Snom vision' => {
+ :softkeys_physical => 16,
+ :softkeys_logical => 48,
+ :pages => 3,
+ },
+ }
+
+ skip_authorization_check
+
+ before_filter { |controller|
@mac_address = params[:mac_address].to_s.upcase.gsub(/[^0-9A-F]/,'')
@provisioning_authenticated = false
+ if !params[:phone].blank?
+ @phone = Phone.where({ :id => params[:phone].to_i }).first
+ if !params[:sip_account].blank?
+ @sip_account = @phone.sip_accounts.where({ :id => params[:sip_account].to_i }).first
+ end
+ end
+
+ @type = params[:type].blank? ? nil : params[:type].to_s.strip.downcase
+ @dialpad_keys = params[:keys].blank? ? nil : params[:keys].to_s.strip
+ }
+
+ def show
+ if @mac_address.blank?
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Phone not found -->",
+ )
+ return
+ end
+
+ mac_address_to_model = {
+ '00041325' => 'Snom 300',
+ '00041328' => 'Snom 300',
+ '0004132D' => 'Snom 300',
+ '0004132F' => 'Snom 300',
+ '00041334' => 'Snom 300',
+ '00041350' => 'Snom 300',
+ '0004133B' => 'Snom 300',
+ '00041337' => 'Snom 300',
+ '00041324' => 'Snom 320',
+ '00041327' => 'Snom 320',
+ '0004132C' => 'Snom 320',
+ '00041331' => 'Snom 320',
+ '00041335' => 'Snom 320',
+ '00041338' => 'Snom 320',
+ '00041351' => 'Snom 320',
+ '00041323' => 'Snom 360',
+ '00041329' => 'Snom 360',
+ '0004132B' => 'Snom 360',
+ '00041339' => 'Snom 360',
+ '00041390' => 'Snom 360',
+ '00041326' => 'Snom 370',
+ '0004132E' => 'Snom 370',
+ '0004133A' => 'Snom 370',
+ '00041352' => 'Snom 370',
+ '00041340' => 'Snom 820',
+ '00041345' => 'Snom 821',
+ '00041348' => 'Snom 821',
+ '00041341' => 'Snom 870',
+ '00041332' => 'Snom meetingPoint',
+ '00041343' => 'Snom vision',
+ }
+ phone_model_str = mac_address_to_model[@mac_address[0, 8]]
+ if phone_model_str == 'Snom vision'
+ snom_vision
+ elsif !phone_model_str.blank?
+ snom_phone
+ end
+ end
+
+ def snom_phone
if !params[:provisioning_key].blank?
@phone = Phone.where({ :provisioning_key => params[:provisioning_key] }).first
if @phone
@@ -154,6 +257,7 @@ class ConfigSnomController < ApplicationController
:content_type => 'text/plain',
:text => "<!-- Phone not found -->",
)
+ return
end
if ! params[:sip_account].blank?
@@ -171,17 +275,16 @@ class ConfigSnomController < ApplicationController
end
end
- if ! params[:type].blank?
- @type = params[:type].to_s.strip.downcase
+ if ! @phone
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Phone not found -->",
+ )
+ return
end
- if ! params[:keys].blank?
- @dialpad_keys = params[:keys].to_s.strip
- end
- }
-
-
- def show
send_sensitve = @provisioning_authenticated || !@phone.provisioning_key_active
@phone_settings = Hash.new()
@@ -230,15 +333,15 @@ class ConfigSnomController < ApplicationController
end
end
- if ! request.env['HTTP_USER_AGENT'].index('snom')
- Rails.logger.info "---> User-Agent indicates not a Snom phone (#{request.env['HTTP_USER_AGENT'].inspect})"
- else
- Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request_remote_ip.inspect}"
- @phone.update_attributes({ :ip_address => request_remote_ip })
- end
+ if ! request.env['HTTP_USER_AGENT'].index('snom')
+ Rails.logger.info "---> User-Agent indicates not a Snom phone (#{request.env['HTTP_USER_AGENT'].inspect})"
+ else
+ Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request_remote_ip.inspect}"
+ @phone.update_attributes({ :ip_address => request_remote_ip })
+ end
@softkeys = Array.new()
- @sip_accounts = Array.new()
+ @sip_accounts = Array.new()
phone_sip_accounts = Array.new()
if send_sensitve
@@ -252,16 +355,16 @@ class ConfigSnomController < ApplicationController
phone_sip_accounts.each do |sip_account|
if (sip_account.sip_accountable_type == @phone.phoneable_type) and (sip_account.sip_accountable_id == @phone.phoneable_id)
- snom_sip_account = {
+ snom_sip_account = {
:id => sip_account.id,
:active => 'on',
- :pname => sip_account.auth_name,
- :pass => sip_account.password,
- :host => sip_account.host,
- :outbound => sip_account.host,
- :name => sip_account.auth_name,
- :realname => 'Call',
- :user_idle_text => sip_account.caller_name,
+ :pname => sip_account.auth_name,
+ :pass => sip_account.password,
+ :host => sip_account.host,
+ :outbound => sip_account.host,
+ :name => sip_account.auth_name,
+ :realname => 'Call',
+ :user_idle_text => sip_account.caller_name,
:expiry => expiry_seconds,
}
@@ -282,217 +385,11 @@ class ConfigSnomController < ApplicationController
@sip_accounts.push(snom_sip_account)
sip_account_index = @sip_accounts.length
sip_account.softkeys.order(:position).each do |softkey|
- if softkey.softkey_function
- softkey_function = softkey.softkey_function.name
- end
- case softkey_function
- when 'blf'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "blf <sip:#{softkey.number}@#{sip_account.host}>|f-ia-"})
- when 'speed_dial'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "speed #{softkey.number}"})
- when 'dtmf'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "dtmf #{softkey.number}"})
- when 'log_out'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "speed f-lo"})
- when 'log_in'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "speed f-li-#{softkey.number}"})
- when 'conference'
- conference = softkey.softkeyable
- if conference.class == Conference
- @softkeys.push({
- :context => sip_account_index,
- :function => softkey.softkey_function.name,
- :label => softkey.label,
- :softkey => softkey,
- :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
- :subscription => {
- :to => "sip:conference#{conference.id}@#{sip_account.host}",
- :for => "sip:conference#{conference.id}@#{sip_account.host}",
- },
- :actions => [{
- :type => :dial,
- :target => "f-ta-#{softkey.number}",
- :when => 'on press',
- :states => 'connected,holding',
- },{
- :type => :dial,
- :target => softkey.number,
- :when => 'on press',
- }],
- })
- end
- when 'parking_stall'
- parking_stall = softkey.softkeyable
- if parking_stall.class == ParkingStall
- @softkeys.push({
- :context => sip_account_index,
- :function => softkey.softkey_function.name,
- :label => softkey.label,
- :softkey => softkey,
- :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
- :subscription => {
- :to => "sip:park+#{parking_stall.name}@#{sip_account.host}",
- :for => "sip:park+#{parking_stall.name}@#{sip_account.host}",
- },
- :actions => [{
- :type => :dial,
- :target => "f-cpa-#{parking_stall.name}",
- :when => 'on press',
- :states => 'connected,holding',
- },{
- :type => :dial,
- :target => "f-cpa-#{parking_stall.name}",
- :when => 'on press',
- }],
- })
- end
- when 'call_forwarding'
- if softkey.softkeyable.class == CallForward then
- @softkeys.push({
- :context => sip_account_index,
- :function => softkey.softkey_function.name,
- :label => softkey.label,
- :softkey => softkey,
- :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
- :subscription => {
- :to => "sip:f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}",
- :for => "sip:f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}"
- },
- :actions => [{
- :type => :url,
- :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/call_forwarding.xml?id=#{softkey.softkeyable_id}&function=toggle",
- :when => 'on press',
- }],
- })
- end
- when 'call_forwarding_always'
- phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'SipAccount').first
- if phone_number
- account_param = (phone_number.phone_numberable_id != snom_sip_account[:id] ? "&account=#{phone_number.phone_numberable_id}" : '')
- else
- phone_number = sip_account.phone_numbers.first
- account_param = ''
- end
-
- @softkeys.push({
- :context => sip_account_index,
- :function => softkey.softkey_function.name,
- :label => softkey.label,
- :softkey => softkey,
- :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
- :subscription => {
- :to => "f-cfutg-#{phone_number.id}@#{sip_account.host}",
- :for => "#{sip_account.auth_name}@#{sip_account.host}"
- },
- :actions => [{
- :type => :url,
- :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/call_forwarding.xml?type=always&function=toggle#{account_param}",
- :when => 'on press',
- }],
- })
- when 'call_forwarding_assistant'
- phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'SipAccount').first
- if phone_number
- account_param = (phone_number.phone_numberable_id != snom_sip_account[:id] ? "&account=#{phone_number.phone_numberable_id}" : '')
- else
- phone_number = sip_account.phone_numbers.first
- account_param = ''
- end
-
- @softkeys.push({
- :context => sip_account_index,
- :function => softkey.softkey_function.name,
- :label => softkey.label,
- :softkey => softkey,
- :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
- :subscription => {
- :to => "f-cfatg-#{phone_number.id}@#{sip_account.host}",
- :for => "#{sip_account.auth_name}@#{sip_account.host}"
- },
- :actions => [{
- :type => :url,
- :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/call_forwarding.xml?type=assistant&function=toggle#{account_param}",
- :when => 'on press',
- }],
- })
- when 'hunt_group_membership'
- phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'HuntGroup').first
- if phone_number
- hunt_group = HuntGroup.where(:id => phone_number.phone_numberable_id).first
- end
-
- sip_account_phone_numbers = Array.new()
- SipAccount.where(:id => @sip_accounts.first[:id]).first.phone_numbers.each do |phone_number|
- sip_account_phone_numbers.push(phone_number.number)
- end
-
- hunt_group_member_numbers = PhoneNumber.where(:number => sip_account_phone_numbers, :phone_numberable_type => 'HuntGroupMember')
-
- hunt_group_member = nil
- if hunt_group and hunt_group_member_numbers
- hunt_group_member_numbers.each do |hunt_group_member_number|
- hunt_group_member = hunt_group.hunt_group_members.where(:id => hunt_group_member_number.phone_numberable_id).first
- if hunt_group_member
- break
- end
- end
- end
-
- if hunt_group_member
- @softkeys.push({
- :context => sip_account_index,
- :function => softkey.softkey_function.name,
- :label => softkey.label,
- :softkey => softkey,
- :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
- :subscription => {
- :to => "f-hgmtg-#{hunt_group_member.id}@#{sip_account.host}",
- :for => "#{sip_account.auth_name}@#{sip_account.host}"
- },
- :actions => [{
- :type => :url,
- :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/hunt_group.xml?group=#{hunt_group.id}&account=#{hunt_group_member.id}&function=toggle",
- :when => 'on press',
- }],
- })
- else
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => 'none'})
- end
- when 'acd_membership'
- acd_agent = nil
- phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'AutomaticCallDistributor').first
- if phone_number
- acd = AutomaticCallDistributor.where(:id => phone_number.phone_numberable_id).first
- if acd
- acd_agent = acd.acd_agents.where(:destination_type => 'SipAccount', :destination_id => sip_account.id).first
- end
- end
-
- if acd_agent
- @softkeys.push({
- :context => sip_account_index,
- :function => softkey.softkey_function.name,
- :label => softkey.label,
- :softkey => softkey,
- :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
- :subscription => {
- :to => "f-acdmtg-#{acd_agent.id}@#{sip_account.host}",
- :for => "#{sip_account.auth_name}@#{sip_account.host}"
- },
- :actions => [{
- :type => :url,
- :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/acd.xml?acd=#{acd.id}&agent=#{acd_agent.id}&function=toggle",
- :when => 'on press',
- }],
- })
- else
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => 'none'})
- end
- when 'hold'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "keyevent F_R"})
- else
- @softkeys.push({:label => softkey.label, :data => 'none'})
- end
+ @softkeys.push(format_key(softkey, sip_account_index))
+ end
+ if @softkeys.any? && @phone.extension_modules.any?
+ phone_defaults = SNOM_PHONE_DEFAULTS[@phone.phone_model.name]
+ @softkeys = @softkeys.first(phone_defaults[:softkeys_physical])
end
end
end
@@ -544,23 +441,22 @@ class ConfigSnomController < ApplicationController
'41' => 'SWI', # Switzerland
}
+ set_language
+
if @phone.phoneable
if @phone.phoneable_type == 'Tenant'
tenant = @phone.phoneable
- language = tenant.language.code
elsif @phone.phoneable_type == 'User'
tenant = @phone.phoneable.current_tenant
- language = @phone.phoneable.language.code
end
end
if tenant && tenant.country
tone_scheme = tenant.country.country_code
+ @phone_settings[:tone_scheme] = tone_schemes_map.include?(tone_scheme.to_s) ? tone_schemes_map[tone_scheme.to_s] : 'USA'
end
+ @phone_settings[:language] = languages_map.include?(I18n.locale.to_s) ? languages_map[I18n.locale.to_s] : 'English'
- @phone_settings[:tone_scheme] = tone_schemes_map.include?(tone_scheme.to_s) ? tone_schemes_map[tone_scheme.to_s] : 'USA'
- @phone_settings[:language] = languages_map.include?(language.to_s) ? languages_map[language.to_s] : 'English'
-
xml_applications_url = "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{(@sip_accounts.blank? ? '0' : @sip_accounts.first[:id])}"
@dkeys = {
:menu => 'keyevent F_SETTINGS',
@@ -603,18 +499,132 @@ class ConfigSnomController < ApplicationController
end
@softkeys.length().upto(MAX_SOFTKEYS_COUNT) do |index|
- @softkeys.push({:label => "", :data => "none"})
+ @softkeys.push({:label => "", :type => 'none', :value => ''})
end
@state_settings_url = "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/state_settings.xml"
- respond_to { |format|
- format.any {
- self.formats = [ :xml ]
- render
- }
- }
- end
+ extension_module = @phone.extension_modules.where(:active => true, :model => 'snom_vision').first
+ if extension_module
+ @phone_settings[:vision_mac_address] = extension_module.mac_address
+ @phone_settings[:vision_provisioning_url] = "#{provisioning_protocol}#{request.host_with_port}/settings-#{extension_module.mac_address}.xml"
+ end
+
+ respond_to { |format|
+ format.any {
+ self.formats = [ :xml ]
+ render :snom_phone
+ }
+ }
+ end
+
+ def snom_vision
+ if !params[:provisioning_key].blank?
+ @extension_module = ExtensionModule.where({ :provisioning_key => params[:provisioning_key] }).first
+ if @extension_module
+ @provisioning_authenticated = true
+ @mac_address = @extension_module.mac_address
+ end
+ elsif @mac_address
+ @extension_module = ExtensionModule.where({ :mac_address => @mac_address }).first
+ end
+
+
+ if !@extension_module
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Extension module not found -->",
+ )
+ return
+ end
+
+ if ! request.env['HTTP_USER_AGENT'].index('snom')
+ Rails.logger.info "---> User-Agent indicates not a Snom Vision (#{request.env['HTTP_USER_AGENT'].inspect})"
+ else
+ Rails.logger.info "---> Extension module #{@mac_address.inspect}, IP address #{request_remote_ip.inspect}"
+ @extension_module.update_attributes({ :ip_address => request_remote_ip })
+ end
+
+ @phone = @extension_module.phone
+
+ set_language
+
+ provisioning_protocol = request.protocol
+
+ @settings = {
+ :auth_type => 'basic',
+ :provisioning_server => "#{provisioning_protocol}#{request.host_with_port}/settings-#{@extension_module.mac_address}.xml",
+ :user => '',
+ :passwd => '',
+ :phone_ip => '',
+ }
+
+ @buttons = Array.new()
+ softkeys = Array.new()
+ send_sensitve = @provisioning_authenticated || !@extension_module.provisioning_key_active
+
+ if send_sensitve && @phone
+ if @provisioning_authenticated && !@extension_module.provisioning_key_active
+ @extension_module.update_attributes({ :provisioning_key_active => true })
+ end
+
+ @settings[:user] = @phone.http_user
+ @settings[:passwd] = @phone.http_password
+ @settings[:phone_ip] = @phone.ip_address
+
+ if !GsParameter.get('PROVISIONING_KEY_LENGTH').nil? && GsParameter.get('PROVISIONING_KEY_LENGTH') > 0 && !@extension_module.provisioning_key.blank?
+ @settings[:provisioning_server] = "#{provisioning_protocol}#{request.host_with_port}/snom_vision-#{@extension_module.provisioning_key}.xml"
+ end
+
+ @phone.sip_accounts.each do |sip_account|
+ softkeys.concat(sip_account.softkeys.order(:position))
+ end
+
+ phone_defaults = SNOM_PHONE_DEFAULTS[@phone.phone_model.name]
+ softkeys.shift(phone_defaults[:softkeys_physical] * @extension_module.position)
+
+ else
+ @buttons << {
+ :imageurl => '',
+ :label => 'No provisioning key!',
+ :type => 'none',
+ :value => '',
+ }
+ end
+
+ softkeys.each do |softkey|
+ image_url = nil
+ if softkey.softkeyable.class == SipAccount
+ if softkey.softkeyable.sip_accountable.class == User
+ user = softkey.softkeyable.sip_accountable
+ if user.image?
+ image_url = "#{provisioning_protocol}#{request.host_with_port}#{user.image_url(:small)}"
+ end
+ end
+ elsif softkey.softkeyable.class == PhoneBookEntry
+ entry = softkey.softkeyable
+ if entry.image?
+ image_url = "#{provisioning_protocol}#{request.host_with_port}#{entry.image_url(:small)}"
+ end
+ end
+
+ button = format_key(softkey)
+ if button
+ button[:imageurl] = image_url
+ end
+ @buttons.push(button)
+ end
+
+ respond_to { |format|
+ format.any {
+ self.formats = [ :xml ]
+ render :snom_vision
+ }
+ }
+ end
+
def idle_screen
@@ -669,7 +679,7 @@ AAAA'
end
def log_in
-
+ set_language
base_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.split("?")[0]}"
exit_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.rpartition("/")[0]}/exit.xml"
@@ -758,6 +768,8 @@ AAAA'
return
end
+ set_language
+
exit_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.rpartition("/")[0]}/exit.xml"
if @phone.user_logout()
@@ -800,6 +812,8 @@ AAAA'
return
end
+ set_language
+
@phone_xml_object = {
:name => 'snom_phone_directory',
:title => "#{t('config_snom.phone_book.title')} #{@dialpad_keys}".strip,
@@ -834,7 +848,7 @@ AAAA'
phone_book_entries.each do |phone_book_entry|
if phone_book_entry.phone_numbers.count > 1
- @phone_xml_object[:entries] << { :text => phone_book_entry.to_s, :number => phone_book_entry.phone_numbers.first }
+ @phone_xml_object[:entries] << { :text => phone_book_entry.to_s, :number => phone_book_entry.phone_numbers.first.number.to_s }
end
phone_book_entry.phone_numbers.each do |phone_number|
if phone_book_entry.phone_numbers.count > 1
@@ -875,6 +889,8 @@ AAAA'
return
end
+ set_language
+
if ['dialed', 'missed', 'received', 'forwarded'].include? @type
@phone_xml_object = {
:name => "snom_phone_directory",
@@ -893,11 +909,24 @@ AAAA'
calls.each do |call|
display_name = call.display_name
phone_number = call.display_number
+
+ if phone_number.blank?
+ next
+ end
+
phone_book_entry = call.phone_book_entry_by_number(phone_number)
if display_name.blank?
display_name = phone_book_entry.to_s
end
+ if @sip_account.clir != call.clir
+ if call.clir == true
+ phone_number = 'f-dcliron-' + phone_number
+ elsif call.clir == false
+ phone_number = 'f-dcliroff-' + phone_number
+ end
+ end
+
@phone_xml_object[:entries].push({
:selected => false,
:number => phone_number,
@@ -947,6 +976,7 @@ AAAA'
return
end
+ set_language
account = @sip_account.voicemail_account
if ['read', 'unread'].include? @type
@@ -1013,6 +1043,8 @@ AAAA'
end
end
+ set_language
+
respond_to { |format|
format.any {
self.formats = [ :xml ]
@@ -1053,6 +1085,7 @@ AAAA'
return
end
+ set_language
exit_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.rpartition("/")[0]}/exit.xml"
if @function == 'toggle'
@@ -1168,6 +1201,7 @@ AAAA'
return
end
+ set_language
exit_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.rpartition("/")[0]}/exit.xml"
if @function == 'toggle'
@@ -1265,6 +1299,7 @@ AAAA'
return
end
+ set_language
exit_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.rpartition("/")[0]}/exit.xml"
if @function == 'toggle'
@@ -1329,4 +1364,236 @@ AAAA'
return date.strftime('%d.%m %H:%M')
end
+ def format_key(softkey, sip_account_index = nil)
+ if !softkey.softkey_function
+ return nil
+ end
+
+ sip_account = softkey.sip_account
+
+ case softkey.softkey_function.name
+ when 'blf'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'blf', :value => "<sip:#{softkey.number}@#{sip_account.host}>|f-ia-"}
+ when 'speed_dial'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'speed', :value => softkey.number.to_s}
+ when 'dtmf'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'dtmf', :value => softkey.number.to_s}
+ when 'log_out'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'speed', :value => 'f-lo'}
+ when 'log_in'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'speed', :value => "f-li-#{softkey.number}"}
+ when 'conference'
+ conference = softkey.softkeyable
+ if conference.class == Conference
+ return {
+ :context => sip_account_index,
+ :function => softkey.softkey_function.name,
+ :label => softkey.label,
+ :softkey => softkey,
+ :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
+ :subscription => {
+ :to => "sip:conference#{conference.id}@#{sip_account.host}",
+ :for => "sip:conference#{conference.id}@#{sip_account.host}",
+ },
+ :actions => [{
+ :type => :dial,
+ :target => "f-ta-#{softkey.number}",
+ :when => 'on press',
+ :states => 'connected,holding',
+ },{
+ :type => :dial,
+ :target => softkey.number,
+ :when => 'on press',
+ }],
+ }
+ end
+ when 'parking_stall'
+ parking_stall = softkey.softkeyable
+ if parking_stall.class == ParkingStall
+ return {
+ :context => sip_account_index,
+ :function => softkey.softkey_function.name,
+ :label => softkey.label,
+ :softkey => softkey,
+ :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
+ :subscription => {
+ :to => "sip:park+#{parking_stall.name}@#{sip_account.host}",
+ :for => "sip:park+#{parking_stall.name}@#{sip_account.host}",
+ },
+ :actions => [{
+ :type => :dial,
+ :target => "f-cpa-#{parking_stall.name}",
+ :when => 'on press',
+ :states => 'connected,holding',
+ },{
+ :type => :dial,
+ :target => "f-cpa-#{parking_stall.name}",
+ :when => 'on press',
+ }],
+ }
+ end
+ when 'call_forwarding'
+ if softkey.softkeyable.class == CallForward then
+ return {
+ :context => sip_account_index,
+ :function => softkey.softkey_function.name,
+ :label => softkey.label,
+ :softkey => softkey,
+ :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
+ :subscription => {
+ :to => "sip:f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}",
+ :for => "sip:f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}"
+ },
+ :actions => [{
+ :type => :url,
+ :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{sip_account.id}/call_forwarding.xml?id=#{softkey.softkeyable_id}&function=toggle",
+ :when => 'on press',
+ }],
+ }
+ end
+ when 'call_forwarding_always'
+ phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'SipAccount').first
+ if phone_number
+ account_param = (phone_number.phone_numberable_id != sip_account.id ? "&account=#{phone_number.phone_numberable_id}" : '')
+ else
+ phone_number = sip_account.phone_numbers.first
+ account_param = ''
+ end
+
+ return {
+ :context => sip_account_index,
+ :function => softkey.softkey_function.name,
+ :label => softkey.label,
+ :softkey => softkey,
+ :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
+ :subscription => {
+ :to => "sip:f-cfutg-#{phone_number.id}@#{sip_account.host}",
+ :for => "sip:f-cfutg-#{phone_number.id}@#{sip_account.host}",
+ },
+ :actions => [{
+ :type => :url,
+ :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{sip_account.id}/call_forwarding.xml?type=always&function=toggle#{account_param}",
+ :when => 'on press',
+ }],
+ }
+ when 'call_forwarding_assistant'
+ phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'SipAccount').first
+ if phone_number
+ account_param = (phone_number.phone_numberable_id != sip_account.id ? "&account=#{phone_number.phone_numberable_id}" : '')
+ else
+ phone_number = sip_account.phone_numbers.first
+ account_param = ''
+ end
+
+ return {
+ :context => sip_account_index,
+ :function => softkey.softkey_function.name,
+ :label => softkey.label,
+ :softkey => softkey,
+ :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
+ :subscription => {
+ :to => "sip:f-cfatg-#{phone_number.id}@#{sip_account.host}",
+ :for => "sip:f-cfatg-#{phone_number.id}@#{sip_account.host}",
+ },
+ :actions => [{
+ :type => :url,
+ :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{sip_account.id}/call_forwarding.xml?type=assistant&function=toggle#{account_param}",
+ :when => 'on press',
+ }],
+ }
+ when 'hunt_group_membership'
+ phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'HuntGroup').first
+ if phone_number
+ hunt_group = HuntGroup.where(:id => phone_number.phone_numberable_id).first
+ end
+
+ sip_account_phone_numbers = Array.new()
+ SipAccount.where(:id => @sip_accounts.first[:id]).first.phone_numbers.each do |phone_number|
+ sip_account_phone_numbers.push(phone_number.number)
+ end
+
+ hunt_group_member_numbers = PhoneNumber.where(:number => sip_account_phone_numbers, :phone_numberable_type => 'HuntGroupMember')
+
+ hunt_group_member = nil
+ if hunt_group and hunt_group_member_numbers
+ hunt_group_member_numbers.each do |hunt_group_member_number|
+ hunt_group_member = hunt_group.hunt_group_members.where(:id => hunt_group_member_number.phone_numberable_id).first
+ if hunt_group_member
+ break
+ end
+ end
+ end
+
+ if hunt_group_member
+ return {
+ :context => sip_account_index,
+ :function => softkey.softkey_function.name,
+ :label => softkey.label,
+ :softkey => softkey,
+ :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
+ :subscription => {
+ :to => "sip:f-hgmtg-#{hunt_group_member.id}@#{sip_account.host}",
+ :for => "sip:f-hgmtg-#{hunt_group_member.id}@#{sip_account.host}",
+ },
+ :actions => [{
+ :type => :url,
+ :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{sip_account.id}/hunt_group.xml?group=#{hunt_group.id}&account=#{hunt_group_member.id}&function=toggle",
+ :when => 'on press',
+ }],
+ }
+ else
+ return {:context => sip_account_index, :label => softkey.label, :type => 'none', :value => ''}
+ end
+ when 'acd_membership'
+ acd_agent = nil
+ phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'AutomaticCallDistributor').first
+ if phone_number
+ acd = AutomaticCallDistributor.where(:id => phone_number.phone_numberable_id).first
+ if acd
+ acd_agent = acd.acd_agents.where(:destination_type => 'SipAccount', :destination_id => sip_account.id).first
+ end
+ end
+
+ if acd_agent
+ return {
+ :context => sip_account_index,
+ :function => softkey.softkey_function.name,
+ :label => softkey.label,
+ :softkey => softkey,
+ :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
+ :subscription => {
+ :to => "sip:f-acdmtg-#{acd_agent.id}@#{sip_account.host}",
+ :for => "sip:f-acdmtg-#{acd_agent.id}@#{sip_account.host}",
+ },
+ :actions => [{
+ :type => :url,
+ :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{sip_account.id}/acd.xml?acd=#{acd.id}&agent=#{acd_agent.id}&function=toggle",
+ :when => 'on press',
+ }],
+ }
+ else
+ return {:context => sip_account_index, :label => softkey.label, :type => 'none', :value => ''}
+ end
+ when 'hold'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'keyevent', :value => 'F_R'}
+ else
+ return {:label => softkey.label, :type => 'none', :value => ''}
+ end
+ end
+
+ private
+ def set_language
+ if @sip_account && !@sip_account.language_code.blank?
+ I18n.locale = @sip_account.language_code
+ elsif @phone
+ sip_account = @phone.sip_accounts.first
+ if sip_account && !sip_account.language_code.blank?
+ I18n.locale = sip_account.language_code
+ @locale = sip_account.language_code
+ elsif @phone.phoneable && @phone.phoneable.respond_to?('language') && @phone.phoneable.language
+ I18n.locale = @phone.phoneable.language.code
+ end
+ end
+ end
+
end
diff --git a/app/controllers/extension_modules_controller.rb b/app/controllers/extension_modules_controller.rb
new file mode 100644
index 0000000..3f8fe98
--- /dev/null
+++ b/app/controllers/extension_modules_controller.rb
@@ -0,0 +1,73 @@
+class ExtensionModulesController < ApplicationController
+ load_resource :phone
+ load_and_authorize_resource :extension_module, :through => [:phone]
+
+ before_filter :spread_breadcrumbs
+
+ def index
+ @extension_modules = @phone.extension_modules.all
+ end
+
+ def show
+ @extension_module = @phone.extension_modules.find(params[:id])
+ end
+
+ def new
+ @extension_module = @phone.extension_modules.build()
+ end
+
+ def create
+ @extension_module = @phone.extension_modules.build(params[:extension_module])
+ if @extension_module.save
+ redirect_to phone_extension_module_path(@phone, @extension_module), :notice => t('extension_modules.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @extension_module = @phone.extension_modules.find(params[:id])
+ end
+
+ def update
+ @extension_module = @phone.extension_modules.find(params[:id])
+ if @extension_module.update_attributes(params[:extension_module])
+ redirect_to phone_extension_module_path(@phone, @extension_module), :notice => t('extension_modules.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @extension_module = @phone.extension_modules.find(params[:id])
+ @extension_module.destroy
+ redirect_to phone_extension_modules_url(@phone), :notice => t('extension_modules.controller.successfuly_destroyed')
+ end
+
+ def restart
+ if @extension_module.resync
+ redirect_to phone_extension_module_path(@phone, @extension_module), :notice => t('extension_modules.controller.restart_invoked')
+ else
+ redirect_to phone_extension_module_path(@phone, @extension_module), :error => t('extension_modules.controller.restart_failed')
+ end
+ end
+
+ private
+ def spread_breadcrumbs
+ if @phone.phoneable.class == User
+ add_breadcrumb t('users.index.page_title'), tenant_users_path(@phone.phoneable.current_tenant)
+ add_breadcrumb @phone.phoneable, tenant_user_path(@phone.phoneable.current_tenant, @phone.phoneable)
+ add_breadcrumb t('phones.index.page_title'), user_phones_path(@phone.phoneable)
+ elsif @phone.phoneable.class == Tenant
+ add_breadcrumb t('phones.index.page_title'), tenant_phones_path(@phone.phoneable)
+ end
+
+ add_breadcrumb @phone, method( :"#{@phone.phoneable.class.name.underscore}_phone_path" ).(@phone.phoneable, @phone)
+ add_breadcrumb t("extension_modules.index.page_title"), phone_extension_modules_path(@phone)
+
+ if @extension_module && !@extension_module.new_record?
+ add_breadcrumb @extension_module
+ end
+
+ end
+end
diff --git a/app/controllers/gateway_headers_controller.rb b/app/controllers/gateway_headers_controller.rb
new file mode 100644
index 0000000..60c16c4
--- /dev/null
+++ b/app/controllers/gateway_headers_controller.rb
@@ -0,0 +1,57 @@
+class GatewayHeadersController < ApplicationController
+ load_and_authorize_resource :gateway
+ load_and_authorize_resource :gateway_header, :through => [:gateway]
+
+ before_filter :spread_breadcrumbs
+
+ def index
+ @gateway_headers = @gateway.gateway_headers
+ end
+
+ def show
+ @gateway_header = @gateway.gateway_headers.find(params[:id])
+ end
+
+ def new
+ @gateway_header = @gateway.gateway_headers.build
+ end
+
+ def create
+ @gateway_header = @gateway.gateway_headers.build(params[:gateway_header])
+ if @gateway_header.save
+ redirect_to @gateway, :notice => t('gateway_headers.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @gateway_header = @gateway.gateway_headers.find(params[:id])
+ end
+
+ def update
+ @gateway_header = @gateway.gateway_headers.find(params[:id])
+ if @gateway_header.update_attributes(params[:gateway_header])
+ redirect_to @gateway, :notice => t('gateway_headers.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @gateway_header = @gateway.gateway_headers.find(params[:id])
+ @gateway_header.destroy
+ redirect_to gateway_path(@gateway), :notice => t('gateway_headers.controller.successfuly_destroyed')
+ end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("gateways.index.page_title"), gateways_path
+ add_breadcrumb @gateway, @gateway
+ add_breadcrumb t("gateway_headers.index.page_title"), gateway_gateway_headers_url(@gateway)
+
+ if @gateway_header && !@gateway_header.new_record?
+ add_breadcrumb @gateway_header
+ end
+ end
+end
diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb
index cd34953..3dc5a54 100644
--- a/app/controllers/sip_accounts_controller.rb
+++ b/app/controllers/sip_accounts_controller.rb
@@ -85,6 +85,7 @@ class SipAccountsController < ApplicationController
m = method( :"#{@parent.class.name.underscore}_sip_account_path" )
redirect_to m.( @parent, @sip_account ), :notice => t('sip_accounts.controller.successfuly_updated')
else
+ possible_voicemail_accounts
render :edit
end
end
diff --git a/app/controllers/switchboard_entries_controller.rb b/app/controllers/switchboard_entries_controller.rb
index ef6c72e..5b41816 100644
--- a/app/controllers/switchboard_entries_controller.rb
+++ b/app/controllers/switchboard_entries_controller.rb
@@ -58,7 +58,7 @@ class SwitchboardEntriesController < ApplicationController
private
def switchboard_entry_params
- params.require(:switchboard_entry).permit(:name, :sip_account_id)
+ params.require(:switchboard_entry).permit(:name, :sip_account_id, :switchable)
end
def spread_breadcrumbs
diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb
index 3e2f8d6..03fd73e 100644
--- a/app/controllers/switchboards_controller.rb
+++ b/app/controllers/switchboards_controller.rb
@@ -19,6 +19,8 @@ class SwitchboardsController < ApplicationController
@switchboard.entry_width = 2
@switchboard.reload_interval = 2000
@switchboard.amount_of_displayed_phone_numbers = 1
+ @switchboard.blind_transfer_activated = true
+ @switchboard.attended_transfer_activated = false
spread_breadcrumbs
end
@@ -56,7 +58,7 @@ class SwitchboardsController < ApplicationController
private
def switchboard_params
- params.require(:switchboard).permit(:name, :reload_interval, :show_avatars, :entry_width, :amount_of_displayed_phone_numbers)
+ params.require(:switchboard).permit(:name, :reload_interval, :show_avatars, :entry_width, :amount_of_displayed_phone_numbers, :blind_transfer_activated, :attended_transfer_activated, :search_activated)
end
def spread_breadcrumbs
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb
index 290a1fc..ee4ddca 100644
--- a/app/controllers/trigger_controller.rb
+++ b/app/controllers/trigger_controller.rb
@@ -178,7 +178,7 @@ class TriggerController < ApplicationController
if errors.count == 0
# Indicate a new fax in the navigation bar.
#
- if @last_fax_document.fax_account.fax_accountable.class == User
+ if @last_fax_document && @last_fax_document.fax_account.fax_accountable.class == User
user = @last_fax_document.fax_account.fax_accountable
PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_or_fax_indicator').hide('fast').show('slow');")
PrivatePub.publish_to("/users/#{user.id}/messages/new", "document.title = '* ' + document.title.replace( '* ' , '');")
diff --git a/app/controllers/voicemail_settings_controller.rb b/app/controllers/voicemail_settings_controller.rb
index f270c3d..ca3ae86 100644
--- a/app/controllers/voicemail_settings_controller.rb
+++ b/app/controllers/voicemail_settings_controller.rb
@@ -42,6 +42,9 @@ class VoicemailSettingsController < ApplicationController
@voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id])
@input_type = VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:input, 'String')
@input_html = VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:html, {})
+ if @input_type == :boolean && @voicemail_setting.value == 'true'
+ @input_html[:checked] = true
+ end
end
def update