diff options
author | spag <spag@golwen.net> | 2012-12-31 08:50:27 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2012-12-31 08:50:27 +0100 |
commit | aed84444142604a62e37e57acfaaf957219e2c8d (patch) | |
tree | e00b1f5844590393171e0bc839ab516d39f5144d /app/controllers | |
parent | c24bd3a8212e85894b2f7c26e190fe5e89fbaaf2 (diff) | |
parent | 12c8f4c82770ded6ea6b519e4451ed6757419ddf (diff) |
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/config_siemens_sort_controller.rb | 371 | ||||
-rw-r--r-- | app/controllers/config_snom_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/page_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/phones_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/tenants_controller.rb | 21 | ||||
-rw-r--r-- | app/controllers/user_groups_controller.rb | 6 |
6 files changed, 27 insertions, 380 deletions
diff --git a/app/controllers/config_siemens_sort_controller.rb b/app/controllers/config_siemens_sort_controller.rb deleted file mode 100644 index c0739e5..0000000 --- a/app/controllers/config_siemens_sort_controller.rb +++ /dev/null @@ -1,371 +0,0 @@ -require 'nokogiri' -#doc.search('Message/ItemList').each do |a| puts a.children end -class ConfigSiemensController < ApplicationController -#TODO Authentication - # No access for admins though as this contains personal data. - - # We can't use load_and_authorize_resource() here because - # ConfigSiemensController isn't a resource. - # We can try client certificates - - skip_authorization_check - - - def index - os40_keys=7 - os60_keys=8 - os80_keys=9 - doc = Nokogiri::XML(request.body.read) - #logger.debug("#{params[:WorkpointMessage].to_xml}") - #logger.debug("#{params[:WorkpointMessage][:Message][:ItemList].to_xml}") - @phone_items=Hash.new - contact_reason = params[:WorkpointMessage][:Message][:ReasonForContact] - reply_status = doc.search('Message/ReasonForContact').first[:status] - reply_action = doc.search('Message/ReasonForContact').first[:action] - - doc.search('Message/ItemList/Item').each do |post_item| - @phone_items[post_item[:name]]=post_item.children.to_s - end - - mac_address = @phone_items['mac-addr'] - phone_type = @phone_items['device-type'] - if phone_type == "OpenStage 40" - max_keys = (os40_keys) * 2 - elsif phone_type == "OpenStage 60" - max_keys = (os60_keys) * 2 - elsif phone_type == "OpenStage 80" - max_keys = (os80_keys) * 2 - else - max_keys = 0 - end - - blf_keys_max = max_keys / 2 - shift_key_position = blf_keys_max - 1 - - #logger.debug(request.body.read) - @phone = Phone.find_by_mac_address(mac_address.gsub(':','').upcase) - if ! @phone.nil? - @phone.update_attributes(:ip_address => request.remote_ip) - sip_account = SipAccount.where(:sip_accountable_type == @phone.phoneable_type, - :sip_accountable_id == @phone.phoneable_id).first - end - - if ! @phone.nil? && ! sip_account.nil? - #logger.debug(@phone_items) - @my_nonce = params[:WorkpointMessage][:Message][:nonce] - @new_settings = Array.new - - @new_settings << ['dhcp', nil, 'true'] - @new_settings << ['hostname', nil, mac_address.gsub(':', '') ] - @new_settings << ['e164-hostname', nil, 'false'] - @new_settings << ['mobility-enabled', nil, 'false'] - @new_settings << ['mobility-password-on-logoff', nil, 'false'] - @new_settings << ['e164', nil, sip_account.try(:phone_numbers).first.number] - @new_settings << ['sip-user-id', nil, sip_account.auth_name] - @new_settings << ['reg-id', nil, sip_account.auth_name] - @new_settings << ['reg-number', nil, sip_account.auth_name] - @new_settings << ['fully-qualified-phone-no', nil, sip_account.auth_name] - @new_settings << ['sip-pwd', nil, sip_account.password] - @new_settings << ['sip-name', nil, sip_account.caller_name] - @new_settings << ['register-by-name', nil, 'false'] - #OPTIMIZE Display ID ? - @new_settings << ['display-id', nil, sip_account.try(:phone_numbers).first.number] - @new_settings << ['display-id-unicode', nil, sip_account.caller_name] - @new_settings << ['use-display-id', nil, 'true'] - @new_settings << ['reg-addr', nil, sip_account.sip_domain.host] - @new_settings << ['reg-port', nil, '5060'] - @new_settings << ['registrar-addr', nil, sip_account.sip_domain.host] - @new_settings << ['registrar-port', nil, '5060'] - @new_settings << ['outbound-proxy', nil, sip_account.sip_domain.host] - @new_settings << ['outbound-proxy-user', nil, sip_account.sip_domain.host] - @new_settings << ['sgnl-gateway-addr', nil, sip_account.sip_domain.host] - @new_settings << ['sgnl-gateway-addr-user', nil, sip_account.sip_domain.host] - @new_settings << ['sgnl-gateway-port', nil, '5060' ] - @new_settings << ['sgnl-gateway-port-user', nil, '5060'] - @new_settings << ['sgnl-route', nil, '0' ] - @new_settings << ['mwi-e164', nil, '' ] - @new_settings << ['rtp-base-port', nil, '5004'] - @new_settings << ['default-domain', nil, '' ] - @new_settings << ['sip-transport', nil, '0' ] - @new_settings << ['sip-transport-user', nil, '0' ] - @new_settings << ['server-type', nil, '0' ] - @new_settings << ['session-timer', nil, 'true'] - @new_settings << ['session-duration', nil, '3600' ] - @new_settings << ['reg-ttl', nil, '3600' ] - @new_settings << ['realm', nil, sip_account.sip_domain.realm] - @new_settings << ['emergency-e164', nil, '0110' ] - @new_settings << ['voice-mail-e164', nil, 'voicemail'] - @new_settings << ['auto-answer', nil, 'false'] - @new_settings << ['beep-on-auto-answer', nil, 'true'] - @new_settings << ['auto-reconnect', nil, 'false' ] - @new_settings << ['beep-on-auto-reconnect', nil, 'true'] - @new_settings << ['permit-decline-call', nil, 'true'] - @new_settings << ['transfer-on-ring', nil, 'false' ] - @new_settings << ['join-allowed-in-conference', nil, 'true'] - @new_settings << ['pickup-group-uri', nil, '*8*'] - @new_settings << ['pickup-group-uri', nil, '' ] - @new_settings << ['hot-line-warm-line-digits', nil, '' ] - @new_settings << ['initial-digit-timer', nil, '30' ] - @new_settings << ['conference-factory-uri', nil, ''] - @new_settings << ['callback-busy-allow', nil, 'false'] - @new_settings << ['callback-busy-code', nil, '' ] - @new_settings << ['callback-ring-allow', nil, 'false'] - @new_settings << ['callback-ring-code', nil, ''] - @new_settings << ['callback-cancel-code', nil, ''] - @new_settings << ['park-server', nil, ''] - #OPTIMIZE Callwaiting - @new_settings << ['call-waiting-enabled', nil, 'true'] - @new_settings << ['qos-layer2', nil, 'true'] - @new_settings << ['l2qos-voice', nil, '5' ] - @new_settings << ['l2qos-signalling', nil, '3' ] - @new_settings << ['l2qos-default', nil, '0'] - @new_settings << ['qos-layer3', nil, 'true'] - @new_settings << ['l3qos-voice', nil, '46'] - @new_settings << ['l3qos-signalling', nil, '26'] - @new_settings << ['vlan-method', nil, '1'] - #OPTIMIZE Timezone - @new_settings << ['sntp-tz-offset', nil, ''] - @new_settings << ['daylight-save', nil, ''] - @new_settings << ['daylight-save-minutes', nil, ''] - #OPTIMIZE Use SNMP? - @new_settings << ['snmp-trap-addr', nil, ''] - @new_settings << ['snmp-trap-port', nil, ''] - @new_settings << ['snmp-trap-pwd', nil, 'snmp' ] - @new_settings << ['snmp-traps-active', nil, 'false' ] - @new_settings << ['diagnostic-trap-addr', nil, ''] - @new_settings << ['diagnostic-trap-port', nil, ''] - @new_settings << ['diagnostic-trap-pwd', nil, 'snmp' ] - @new_settings << ['diagnostic-traps-active', nil, 'false' ] - @new_settings << ['diagnostic-snmp-active', nil, 'false'] - @new_settings << ['qdc-collection-unit-addr', nil, ''] - @new_settings << ['qdc-collection-unit-port', nil, '12010'] - - @new_settings << ['qdc-trap-pwd', nil, 'QOSDC'] - @new_settings << ['qdc-snmp-active', nil, 'false'] - @new_settings << ['qdc-qcu-active', nil, 'false'] - @new_settings << ['snmp-queries-allowed', nil, 'false'] - @new_settings << ['snmp-pwd', nil, ''] - @new_settings << ['disable-microphone', nil, 'false'] - @new_settings << ['loudspeech-enabled', nil, 'true'] - @new_settings << ['audio-silence-suppression', nil, 'false'] - - @new_settings << ['port1', nil, '0' ] # 0=Automatic (speed) - @new_settings << ['port2', nil, '0' ] - @new_settings << ['port2-mode', nil, '1' ] - @new_settings << ['port2-auto-mdix-enabled', nil, 'true' ] - @new_settings << ['originating-line-preference', nil, '0'] - @new_settings << ['terminating-line-preference', nil, '0'] - @new_settings << ['line-key-operating-mode', nil, '0'] - @new_settings << ['line-rollover-type', nil, '2'] - @new_settings << ['line-rollover-volume', nil, '5' ]# 1-5 - @new_settings << ['line-registration-leds', nil, 'true'] - @new_settings << ['keyset-use-focus', nil, 'true' ] - @new_settings << ['keyset-remote-forward-ind', nil, 'true'] - @new_settings << ['keyset-reservation-timer', nil, '60' ] # 0-300 - @new_settings << ['dial-plan-enabled', nil, '' ] - @new_settings << ['Canonical-dialing-international-prefix', nil, ''] - @new_settings << ['Canonical-dialing-local-country-code', nil, ''] - @new_settings << ['Canonical-dialing-national-prefix', nil, ''] - @new_settings << ['Canonical-dialing-local-area-code', nil, ''] - @new_settings << ['Canonical-dialing-local-node', nil, ''] - @new_settings << ['Canonical-dialing-external-access', nil, '0'] - @new_settings << ['Canonical-dialing-operator-code', nil, ''] - @new_settings << ['Canonical-dialing-emergency-number', nil, ''] - @new_settings << ['Canonical-dialing-dial-needs-access-code', nil, '0'] - @new_settings << ['Canonical-dialing-dial-needs-intGWcode', nil, '0'] - @new_settings << ['Canonical-dialing-min-local-number-length', nil, '10'] - @new_settings << ['Canonical-dialing-extension-initial-digits', nil, ''] - @new_settings << ['Canonical-dialing-dial-internal-form', nil, '0' ] - @new_settings << ['Canonical-dialing-dial-external-form', nil, '0' ] - @new_settings << ['Canonical-lookup-local-code', nil, '' ] - @new_settings << ['Canonical-lookup-international-code', nil, ''] - @new_settings << ['hot-keypad-dialing', nil, ''] - @new_settings << ['ldap-transport', nil, '0'] - @new_settings << ['ldap-server-address', nil, '' ] - @new_settings << ['ldap-server-port', nil, '389' ] - @new_settings << ['ldap-authentication', nil, '1'] - @new_settings << ['ldap-user', nil, '' ] - @new_settings << ['ldap-pwd', nil, '' ] - @new_settings << ['ldap-max-responses', nil, '25'] - @new_settings << ['backup-addr', nil, ''] - @new_settings << ['backup-registration', nil, 'false'] - @new_settings << ['qdc-qcu-active', nil, 'false' ] - @new_settings << ['min-admin-passw-length', nil, '6' ] - @new_settings << ['default-locked-config-menus', nil, 'true' ] - @new_settings << ['locked-config-menus', nil, 'true' ] - @new_settings << ['default-locked-local-function-menus', nil, 'true' ] - @new_settings << ['locked-local-function-menus', nil, 'true' ] - @new_settings << ['dls-mode-secure', nil, '0' ] - @new_settings << ['dls-chunk-size', nil, '9492'] - @new_settings << ['default-passw-policy', nil, 'false'] - @new_settings << ['deflect-destination', nil, ''] - @new_settings << ['display-skin', nil, ''] - @new_settings << ['enable-bluetooth-interface', nil, 'true'] - @new_settings << ['usb-access-enabled', nil, 'false' ] - @new_settings << ['usb-backup-enabled', nil, 'false' ] - @new_settings << ['line-button-mode', nil, '0' ] - @new_settings << ['lock-forwarding', nil, '' ] - @new_settings << ['loudspeaker-function-mode', nil, '0' ] - @new_settings << ['max-pin-retries', nil, '' ] - @new_settings << ['inactivity-timeout', nil, '30' ] - @new_settings << ['not-used-timeout', nil, '2' ] - @new_settings << ['passw-char-set', nil, '0' ] - @new_settings << ['refuse-call', nil, 'true' ] - @new_settings << ['restart-password', nil, ''] - #OPTIMIZE clock format - @new_settings << ['time-format', nil, '0' ]# 1=12 h - @new_settings << ['uaCSTA-enabled', nil, 'false' ] - @new_settings << ['enable-test-interface', nil, 'false'] - @new_settings << ['enable-WBM', nil, 'true'] - @new_settings << ['pixelsaver-timeout', nil, '2' ]# 2 hours? - @new_settings << ['voice-message-dial-tone', nil, '' ] - @new_settings << ['call-pickup-allowed', nil, 'true' ] - @new_settings << ['group-pickup-tone-allowed', nil, 'true'] - @new_settings << ['group-pickup-as-ringer', nil, 'false'] - @new_settings << ['group-pickup-alert-type', nil, '0' ] - @new_settings << ['default-profile', nil, '' ] - @new_settings << ['count-medium-priority', nil, '5'] - @new_settings << ['timer-medium-priority', nil, '60'] # 1 - 999 - @new_settings << ['timer-high-priority', nil, '5'] # 0 - 999 - @new_settings << ['dss-sip-detect-timer', nil, '10'] - @new_settings << ['dss-sip-deflect', nil, 'false' ] - @new_settings << ['dss-sip-refuse', nil, 'false' ] - @new_settings << ['feature-availability', nil, 'false'] - @new_settings << ['feature-availability', nil, 'true' ] - @new_settings << ['feature-availability', nil, 'true' ] - @new_settings << ['local-control-feature-availability', nil, 'false' ] - @new_settings << ['trace-level', nil, '0' ] # Off - @new_settings << ['default-locked-function-keys', nil, 'true' ]# "unknown item" - #OPTIMIZE Put pickup prefix into database/global constant? - @new_settings << ['blf-code', nil, 'f_ia_'] # pickup prefix for softkey function 59 (BLF) - @new_settings << ['stimulus-feature-code', nil, true] - @new_settings << ['stimulus-led-control-uri', nil, true] - - - @new_settings << ['min-user-passw-length', nil, '6' ]# 6 - 24 - #OPTIMIZE language - @new_settings << ['country-iso', nil, 'DE' ] - @new_settings << ['language-iso', nil, 'de'] - @new_settings << ['date-format', nil, '0' ] # DD.MM.YYYY - #OPTIMIZE ringtones - @new_settings << ['ringer-melody', nil, '1'] - - @new_settings << ['ringer-melody', nil, '2'] - @new_settings << ['ringer-tone-sequence', nil, '2'] - - soft_keys = Array.new - # Getting BLF keys only for the first level - blf_keys = sip_account.softkeys.find( - :all, - :conditions => {:function => ['blf', 'conference']}, - :limit => blf_keys_max) - #Getting other keys - non_blf_keys = sip_account.softkeys.find( - :all, - :conditions => {:function => ['speed_dial']}) - - # Fill softkey array with BLF keys up to shift key - blf_keys.each do |k| - soft_keys << k - end - # Fill sofkey with other keys up to end - non_blf_keys.each do |k| - if soft_keys.length < max_keys - soft_keys << k - end - end - # Delete unset softkeys - while soft_keys.length < max_keys - soft_keys << Softkey.new - end - - key_pos=1 - - #soft_keys.each do |sk| - - while key_pos < shift_key_position - - (1..shift_key_position-1).each do |key_idx| - sk = soft_keys.shift - logger.debug(sk.function, key_idx) - if sk.function == "blf" - @new_settings << ['function-key-def', key_idx, '59'] - @new_settings << ['select-dial', key_idx, sk.number ] - elsif sk.function == "log_out" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, 'f_lo' ] - elsif sk.function == "log_in" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, "f_li_#{sk.number}" ] - elsif sk.function == "dtmf" - @new_settings << ['function-key-def', key_idx, '54'] - @new_settings << ['stimulus-DTMF-sequence', key_idx, sk.number ] - elsif sk.function.nil? - @new_settings << ['function-key-def', key_idx, '0'] - else - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, sk.number ] - end - @new_settings << ['key-label', key_idx, sk.label ] - @new_settings << ['key-label-unicode', key_idx, sk.label ] - key_pos = key_pos+1 - - end - end - if key_pos == shift_key_position - @new_settings << ['function-key-def', shift_key_position, '18'] - @new_settings << ['key-label', shift_key_position, 'Shift'] - @new_settings << ['key-label-unicode', shift_key_position, 'Shift'] - key_pos = key_pos+1 - end - - (1001..1000+shift_key_position-1).each do |key_idx| - sk = soft_keys.shift - if sk.function == "log_out" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, 'f_lo' ] - elsif sk.function == "log_in" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, "f_li_#{sk.number}" ] - elsif sk.function == "dtmf" - @new_settings << ['function-key-def', key_idx, '54'] - @new_settings << ['stimulus-DTMF-sequence', key_idx, sk.number ] - elsif sk.function.nil? - @new_settings << ['function-key-def', key_idx, '0'] - else - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, sk.number ] - end - @new_settings << ['key-label', key_idx, sk.label ] - @new_settings << ['key-label-unicode', key_idx, sk.label ] - key_pos = key_pos+1 - - end - - #end - logger.debug(@new_settings) - end - - if @phone.nil? || sip_account.nil? - respond_to { |format| - format.xml { render :action => "clean-up" } - } - - elsif (reply_status == 'accepted' && contact_reason == 'reply-to' && reply_action == 'ReadAllItems') - respond_to { |format| - format.xml { render :action => "write" } - } - - elsif ["reply-to"].include? contact_reason - respond_to { |format| - format.xml { render :action => "clean-up" } - } - - else - respond_to { |format| - format.xml { render :action => "index" } - } - end - - end -end diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 4d12082..7542415 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -80,6 +80,7 @@ class ConfigSnomController < ApplicationController '00041345' => 'Snom 821', '00041348' => 'Snom 821', '00041341' => 'Snom 870', + '00041332' => 'snom MeetingPoint', } @phone.phone_model = PhoneModel.where(:name => mac_address_to_model[@mac_address[0, 8]]).first diff --git a/app/controllers/page_controller.rb b/app/controllers/page_controller.rb index 1f37449..4ea4d25 100644 --- a/app/controllers/page_controller.rb +++ b/app/controllers/page_controller.rb @@ -7,6 +7,7 @@ class PageController < ApplicationController def index;end def conference;end + def beginners_intro;end private def if_fresh_system_then_go_to_wizard diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb index f1dcd3e..2698465 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -13,9 +13,9 @@ class PhonesController < ApplicationController end def new - set_fallback_sip_accounts - @phone = @phoneable.phones.build() + + set_fallback_sip_accounts # Use the last phone.phone_model as the default. # @@ -80,6 +80,9 @@ class PhonesController < ApplicationController def set_fallback_sip_accounts used_sip_account_ids = Phone.where(:fallback_sip_account_id => SipAccount.pluck(:id)).pluck(:fallback_sip_account_id) @fallback_sip_accounts = SipAccount.where(:sip_accountable_type => 'Tenant').where(:hotdeskable => true) - SipAccount.where(:id => used_sip_account_ids) + if @phone && !@phone.fallback_sip_account_id.blank? && SipAccount.exists?(@phone.fallback_sip_account_id) + @fallback_sip_accounts << SipAccount.where(:id => @phone.fallback_sip_account_id).first + end end end diff --git a/app/controllers/tenants_controller.rb b/app/controllers/tenants_controller.rb index 724d179..7bb8ecd 100644 --- a/app/controllers/tenants_controller.rb +++ b/app/controllers/tenants_controller.rb @@ -58,14 +58,27 @@ class TenantsController < ApplicationController end if Delayed::Job.count > 0 - redirect_to @tenant, :notice => t('tenants.controller.successfuly_created_plus_delayed_jobs', + if SipAccount.any? || Phone.any? + redirect_to @tenant, :notice => t('tenants.controller.successfuly_created_plus_delayed_jobs', :resource => @tenant, :amount_of_numbers => @tenant.array_of_internal_extension_numbers.count + @tenant.array_of_dids.count ) - else - redirect_to @tenant, :notice => t('tenants.controller.successfuly_created', - :resource => @tenant + else + redirect_to page_beginners_intro_path, :notice => t('tenants.controller.successfuly_created_plus_delayed_jobs', + :resource => @tenant, + :amount_of_numbers => @tenant.array_of_internal_extension_numbers.count + @tenant.array_of_dids.count ) + end + else + if SipAccount.any? || Phone.any? + redirect_to @tenant, :notice => t('tenants.controller.successfuly_created', + :resource => @tenant + ) + else + redirect_to page_beginners_intro_path, :notice => t('tenants.controller.successfuly_created', + :resource => @tenant + ) + end end else render :new diff --git a/app/controllers/user_groups_controller.rb b/app/controllers/user_groups_controller.rb index 158abaa..ff3292c 100644 --- a/app/controllers/user_groups_controller.rb +++ b/app/controllers/user_groups_controller.rb @@ -19,7 +19,7 @@ class UserGroupsController < ApplicationController def create @user_group = @parent.user_groups.build(params[:user_group]) if @user_group.save - redirect_to @user_group, :notice => t('user_groups.controller.successfuly_created') + redirect_to [@parent, @user_group], :notice => t('user_groups.controller.successfuly_created') else render :new end @@ -30,7 +30,7 @@ class UserGroupsController < ApplicationController def update if @user_group.update_attributes(params[:user_group]) - redirect_to @user_group, :notice => t('user_groups.controller.successfuly_updated') + redirect_to [@parent, @user_group], :notice => t('user_groups.controller.successfuly_updated') else render :edit end @@ -38,7 +38,7 @@ class UserGroupsController < ApplicationController def destroy @user_group.destroy - redirect_to user_groups_url, :notice => t('user_groups.controller.successfuly_destroyed') + redirect_to method( :"#{@parent.class.name.underscore}_user_groups_path" ).(@parent), :notice => t('user_groups.controller.successfuly_destroyed') end private |