diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/config_snom_controller.rb | 38 | ||||
-rw-r--r-- | app/models/tenant.rb | 14 |
2 files changed, 34 insertions, 18 deletions
diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 40f0c4e..74a117d 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -2,17 +2,17 @@ class ConfigSnomController < ApplicationController MAX_SIP_ACCOUNTS_COUNT = 11 MAX_SOFTKEYS_COUNT = 12 + (42 * 3) - 1 MAX_DIRECTORY_ENTRIES = 20 - KEYPAD_TO_CHAR = { - '0' => [' ','-','.',',','0'], - '1' => [' ','-','.',',','1'], - '2' => ['a','b','c','2'], - '3' => ['d','e','f','3'], - '4' => ['g','h','i','4'], - '5' => ['j','k','l','5'], - '6' => ['m','n','o','6'], - '7' => ['p','q','r','s','7'], - '8' => ['t','u','v','8'], - '9' => ['w','x','y','z','9'], + KEY_REGEXP = { + '0' => "[ -.,_0]+", + '1' => "[ -.,_1]+", + '2' => "[abc2]", + '3' => "[def3]", + '4' => "[ghi4]", + '5' => "[jkl5]", + '6' => "[mno6]", + '7' => "[pqrs7]", + '8' => "[tuv8]", + '9' => "[wxyz9]", } skip_authorization_check @@ -727,6 +727,14 @@ AAAA' :softkeys => [], } + key_regexp = '' + if !@dialpad_keys.blank? + @dialpad_keys.to_s.each_char do |dialpad_key| + key_regexp.concat(KEY_REGEXP[dialpad_key].to_s) + end + key_regexp = '^' + key_regexp + end + phone_books = Array.new() phone_books = phone_books + @sip_account.sip_accountable.try(:phone_books).all if @sip_account.sip_accountable.class == User @@ -738,7 +746,13 @@ AAAA' phone_book_ids << phone_book.id end - PhoneBookEntry.where(:phone_book_id => phone_book_ids).order(:last_name).order(:first_name).limit(MAX_DIRECTORY_ENTRIES).each do |phone_book_entry| + if key_regexp.blank? + phone_book_entries = PhoneBookEntry.where(:phone_book_id => phone_book_ids).order(:last_name).order(:first_name).limit(MAX_DIRECTORY_ENTRIES) + else + phone_book_entries = PhoneBookEntry.where(:phone_book_id => phone_book_ids).order(:last_name).order(:first_name).where('last_name REGEXP ? OR first_name REGEXP ? OR organization REGEXP ?', key_regexp, key_regexp, key_regexp).limit(MAX_DIRECTORY_ENTRIES) + end + + 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 } end diff --git a/app/models/tenant.rb b/app/models/tenant.rb index 6f98603..dda94d8 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -223,15 +223,17 @@ class Tenant < ActiveRecord::Base amooma = general_phone_book.phone_book_entries.create( :organization => 'AMOOMA GmbH', :is_organization => true, - :description => "Hersteller von Gemeinschaft. Rufen Sie uns an, falls Sie kommerziellen Support oder Consulting für Gemeinschaft benötigen.", - :homepage_organization => 'http://www.amooma.de', + :description => "Hersteller von Gemeinschaft. Kommerziellen Support und Consulting für Gemeinschaft.", + :homepage_organization => 'http://amooma.de', :twitter_account => 'amooma_de', :facebook_account => 'https://www.facebook.com/AMOOMA.GmbH', ) - amooma.phone_numbers.create( - :name => 'Office', - :number => '+492622706480' - ) + # This is the new 2013 phone number. + # + # amooma.phone_numbers.create( + # :name => 'Office', + # :number => '+4926228998900' + # ) amooma.addresses.create( :street => 'Bachstr. 124', :zip_code => '56566', |