summaryrefslogtreecommitdiff
path: root/config/initializers
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
commitb80bd744ad873f6fc43018bc4bfb90677de167bd (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /config/initializers
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
Start of GS5.
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/backtrace_silencers.rb7
-rw-r--r--config/initializers/connectivity_check.rb23
-rw-r--r--config/initializers/gemeinschaft_parameters.rb81
-rw-r--r--config/initializers/inflections.rb10
-rw-r--r--config/initializers/load_extensions.rb1
-rw-r--r--config/initializers/mime_types.rb9
-rw-r--r--config/initializers/secret_token.rb7
-rw-r--r--config/initializers/session_store.rb8
-rw-r--r--config/initializers/simple_form.rb19
-rw-r--r--config/initializers/validators.rb242
-rw-r--r--config/initializers/wrap_parameters.rb14
11 files changed, 421 insertions, 0 deletions
diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb
new file mode 100644
index 0000000..59385cd
--- /dev/null
+++ b/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/config/initializers/connectivity_check.rb b/config/initializers/connectivity_check.rb
new file mode 100644
index 0000000..583f372
--- /dev/null
+++ b/config/initializers/connectivity_check.rb
@@ -0,0 +1,23 @@
+require 'socket'
+require 'timeout'
+
+module Connectivity
+
+ def self.port_open?( ip_addr, port )
+ begin
+ Timeout::timeout(5) {
+ s = TCPSocket.new( ip_addr, port )
+ s.close
+ return true
+ }
+ rescue Errno::ECONNREFUSED
+ rescue Errno::EHOSTUNREACH
+ rescue Errno::EADDRNOTAVAIL
+ rescue SocketError
+ rescue Timeout::Error
+ end
+
+ return false
+ end
+
+end
diff --git a/config/initializers/gemeinschaft_parameters.rb b/config/initializers/gemeinschaft_parameters.rb
new file mode 100644
index 0000000..6e89abd
--- /dev/null
+++ b/config/initializers/gemeinschaft_parameters.rb
@@ -0,0 +1,81 @@
+# Use this file to set generic parameters for Gemeinschaft
+
+GEMEINSCHAFT_VERSION = '5.0'
+SUPER_TENANT_NAME = 'Super-Tenant'
+
+# System defaults
+MINIMUM_PIN_LENGTH = 4
+MAXIMUM_PIN_LENGTH = 10
+
+# GUI
+GUI_REDIRECT_HTTPS = false
+
+# Phone numbers
+# Only touch this if you know what you are doing!
+STRICT_INTERNAL_EXTENSION_HANDLING = false
+STRICT_DID_HANDLING = false
+
+# SIP defaults
+DEFAULT_LENGTH_SIP_AUTH_NAME = 10
+DEFAULT_LENGTH_SIP_PASSWORD = 15
+CALL_WAITING = false
+DEFAULT_CLIR_SETTING = false
+DEFAULT_CLIP_SETTING = true
+
+TO_S_MAX_CALLER_NAME_LENGTH = 20
+TO_S_MAX_LENGTH_OF_AUTH_NAME = 8
+
+# Pagination defaults
+DEFAULT_PAGINATION_ENTRIES_PER_PAGE = 50
+
+# Conference defaults
+MAXIMUM_NUMBER_OF_PEOPLE_IN_A_CONFERENCE = 100
+DEFAULT_MAX_CONFERENCE_MEMBERS = 10
+
+# Misc defaults
+MAX_EXTENSION_LENGTH = 6
+
+# Fax defaults
+DEFAULT_NUMBER_OF_RETRIES = 3
+DAYS_TILL_AUTO_DELETE = 90
+
+# Names of PhoneNumberRanges
+INTERNAL_EXTENSIONS = 'internal_extensions'
+SERVICE_NUMBERS = 'service_numbers'
+DIRECT_INWARD_DIALING_NUMBERS = 'direct_inward_dialing_numbers'
+
+# Callthrough defaults
+CALLTHROUGH_HAS_WHITELISTS = true
+
+# Hunt groups
+HUNT_GROUP_STRATEGIES = ['ring_all', 'ring_recursively']
+VALID_SECONDS_BETWEEN_JUMPS_VALUES = (1 .. 60).to_a.map{|x| x * 2}
+
+# Callforward
+DEFAULT_CALL_FORWARD_DEPTH = 1
+MAX_CALL_FORWARD_DEPTH = 40
+CALLFORWARD_DESTINATION_DEFAULT = '+49'
+CALLFORWARD_RULES_ACT_PER_SIP_ACCOUNT_DEFAULT = true
+
+# Phone
+PROVISIONING_AUTO_ADD_PHONE = true
+PROVISIONING_AUTO_ADD_SIP_ACCOUNT = true
+PROVISIONING_AUTO_TENANT_ID = 2
+PROVISIONING_AUTO_SIP_ACCOUNT_CALLER_PREFIX = 'Gemeinschaft '
+PROVISIONING_IEEE8021X_EAP_USERNAME = ''
+PROVISIONING_IEEE8021X_EAP_PASSWORD = ''
+NIGHTLY_REBOOT_OF_PHONES = true
+SIEMENS_HISTORY_RELOAD_TIMES = {0..6 => 600, 7..20 => 40, 21..24 => 300}
+
+# API configuration
+DEFAULT_API_TENANT_ID = 2
+REMOTE_IP_ADDRESS_WHITELIST = [] # e.g. ['10.0.0.1']
+IMPORT_CSV_FILE = '/var/tmp/ExampleVoipCsvExport.csv'
+DOUBLE_CHECK_POSITIVE_USERS_CSV = '/var/tmp/ExampleDoubleCheckVoipCsvExport.csv'
+IMPORT_CSV_ENCODING = 'UTF-8'
+USER_NAME_PREFIX = 'dtc'
+CALLTHROUGH_NAME_TO_BE_USED_FOR_DEFAULT_ACTIVATION = 'Callthrough for employees'
+
+# GS Cluster configuration
+WRITE_GS_CLUSTER_SYNC_LOG = true
+HOMEBASE_IP_ADDRESS = '0.0.0.0'
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
new file mode 100644
index 0000000..9e8b013
--- /dev/null
+++ b/config/initializers/inflections.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
diff --git a/config/initializers/load_extensions.rb b/config/initializers/load_extensions.rb
new file mode 100644
index 0000000..d86993c
--- /dev/null
+++ b/config/initializers/load_extensions.rb
@@ -0,0 +1 @@
+require 'activerecord_extensions'
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
new file mode 100644
index 0000000..6c89b3c
--- /dev/null
+++ b/config/initializers/mime_types.rb
@@ -0,0 +1,9 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
+
+# ".htm" file extension for Snom provisioning:
+Mime::Type.register 'text/html', :htm
+Mime::Type.register 'audio/x-wav', :wav
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb
new file mode 100644
index 0000000..6f04f07
--- /dev/null
+++ b/config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+Gemeinschaft42c::Application.config.secret_token = '9a59cac7fe4b23e0253a7beb341d9498d721923e966b45983f441f991e81f758067a6d9a949247d489773288284ab96b5015be52bf7b2834e666d43f864034e4'
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
new file mode 100644
index 0000000..f77495c
--- /dev/null
+++ b/config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# Gemeinschaft42c::Application.config.session_store :cookie_store, key: '_Gemeinschaft42c_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rails generate session_migration")
+Gemeinschaft42c::Application.config.session_store :active_record_store
diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb
new file mode 100644
index 0000000..2e3d9fb
--- /dev/null
+++ b/config/initializers/simple_form.rb
@@ -0,0 +1,19 @@
+# Use this setup block to configure all options available in SimpleForm.
+SimpleForm.setup do |config|
+ config.wrappers :tag => :div, :class => :input,
+ :error_class => :field_with_errors do |b|
+
+ # Form extensions
+ b.use :html5
+ b.optional :pattern
+ b.use :maxlength
+ b.use :placeholder
+ b.use :readonly
+
+ # Form components
+ b.use :label_input
+ b.use :error, :wrap_with => { :tag => :span, :class => :error }
+ b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
+ end
+
+end
diff --git a/config/initializers/validators.rb b/config/initializers/validators.rb
new file mode 100644
index 0000000..4f6c223
--- /dev/null
+++ b/config/initializers/validators.rb
@@ -0,0 +1,242 @@
+ActiveRecord::Base.class_eval do
+
+ def self.validate_mac_address( attr_names, options={} )
+ validates_format_of( attr_names, {
+ :with => /^ [0-9A-F]{2} (?: [0-9A-F]{2} ){5} $/x,
+ :allow_blank => false,
+ :allow_nil => false,
+ }.merge!( options ) )
+ end
+
+ def self.validate_ip_address( attr_names, options={} )
+ validates_format_of( attr_names, {
+ :with => /^
+ (?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)
+ (?:\.(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)){3}
+ $/x, # OPTIMIZE IPv6
+ :allow_blank => false,
+ :allow_nil => false,
+ }.merge!( options ) )
+ end
+
+ def self.validate_ip_port( attr_names, options={} )
+ validates_numericality_of( attr_names, {
+ :only_integer => true,
+ :greater_than => 0,
+ :less_than => 65536,
+ :allow_nil => false,
+ }.merge!( options ) )
+ end
+
+ def self.validate_netmask( attr_names, options={} )
+ configuration = {
+ :allow_nil => false,
+ :allow_blank => false,
+ :with =>
+ /^(
+ ((128|192|224|240|248|252|254)\.0\.0\.0)
+ |(255\.(0|128|192|224|240|248|252|254)\.0\.0)
+ |(255\.255\.(0|128|192|224|240|248|252|254)\.0)
+ |(255\.255\.255\.(0|128|192|224|240|248|252|254))
+ )$/x
+ }
+ configuration.merge!( options )
+ validates_format_of( attr_names, configuration )
+ end
+
+ def self.validate_hostname_or_ip( attr_names, options={} )
+ # Validate the server. This is the "host" rule from RFC 3261
+ # (but the patterns for IPv4 and IPv6 addresses have been fixed here).
+ configuration = {
+ :allow_nil => false,
+ :allow_blank => false,
+ :with =>
+ /^
+ (?:
+ (?:
+ (?:
+ (?:
+ [A-Za-z0-9] |
+ [A-Za-z0-9] [A-Za-z0-9\-]* [A-Za-z0-9]
+ )
+ \.
+ )*
+ (?:
+ [A-Za-z] |
+ [A-Za-z] [A-Za-z0-9\-]* [A-Za-z0-9]
+ )
+ \.?
+ )
+ |
+ (?:
+ (?: 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d )
+ (?: \. (?: 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d ) ){3}
+ )
+ |
+ (
+ (
+ ( [0-9A-Fa-f]{1,4} [:] ){7} ( [0-9A-Fa-f]{1,4} | [:] )
+ )|
+ (
+ ( [0-9A-Fa-f]{1,4} [:] ){6}
+ (
+ [:] [0-9A-Fa-f]{1,4} |
+ (
+ ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d )
+ ( \. ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d ) ){3}
+ ) | [:]
+ )
+ )|
+ (
+ ( [0-9A-Fa-f]{1,4} [:] ){5}
+ (
+ (
+ ( [:] [0-9A-Fa-f]{1,4} ){1,2}
+ )|
+ [:](
+ ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d )
+ ( \. ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d ) ){3}
+ )|
+ [:]
+ )
+ )|
+ (
+ ( [0-9A-Fa-f]{1,4} [:] ){4}
+ (
+ ( ( [:] [0-9A-Fa-f]{1,4} ){1,3} ) |
+ (
+ ( [:] [0-9A-Fa-f]{1,4} )? [:]
+ (
+ ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d )
+ ( \. ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d ) ){3}
+ )
+ ) | [:]
+ )
+ )|
+ (
+ ( [0-9A-Fa-f]{1,4} [:] ){3}
+ (
+ ( ( [:] [0-9A-Fa-f]{1,4} ){1,4} ) |
+ (
+ ( [:] [0-9A-Fa-f]{1,4} ){0,2} [:]
+ (
+ ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d )
+ ( \. ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d ) ){3}
+ )
+ ) | [:]
+ )
+ )|
+ (
+ ( [0-9A-Fa-f]{1,4} [:] ){2}
+ (
+ ( ( [:] [0-9A-Fa-f]{1,4} ){1,5} ) |
+ (
+ ( [:] [0-9A-Fa-f]{1,4} ){0,3} [:]
+ (
+ ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d )
+ ( \. ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d ) ){3}
+ )
+ ) | [:]
+ )
+ )|
+ (
+ ( [0-9A-Fa-f]{1,4} [:] ){1}
+ (
+ ( ( [:] [0-9A-Fa-f]{1,4} ){1,6} ) |
+ (
+ ( [:] [0-9A-Fa-f]{1,4} ){0,4} [:]
+ (
+ ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d )
+ ( \. ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d ) ){3}
+ )
+ ) | [:]
+ )
+ )|
+ (
+ [:]
+ (
+ ( ( [:] [0-9A-Fa-f]{1,4} ){1,7} ) |
+ (
+ ( [:] [0-9A-Fa-f]{1,4} ){0,5} [:]
+ (
+ ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d )
+ ( \. ( 25[0-5] | 2[0-4]\d | 1\d\d | [1-9]?\d ) ){3}
+ )
+ ) | [:]
+ )
+ )
+ )
+ )
+ $/x
+ }
+ configuration.merge!( options )
+ validates_format_of( attr_names, configuration )
+ end
+
+ # Validate SIP username. This is the "user" rule from RFC 3261.
+ def self.validate_username( attr_names, options={} )
+ configuration = {
+ :allow_nil => false,
+ :allow_blank => false,
+ :with =>
+ /^
+ (?:
+ (?:
+ [A-Za-z0-9] |
+ [\-_.!~*'()]
+ ) |
+ %[0-9A-F]{2} |
+ [&=+$,;?\/]
+ ){1,255}
+ $/x
+ }
+ configuration.merge!( options )
+ validates_format_of( attr_names, configuration )
+ end
+
+ # Validate SIP password.
+ def self.validate_sip_password( attr_names, options={} )
+ configuration = {
+ :allow_nil => true,
+ :allow_blank => true,
+ :with =>
+ /^
+ (?:
+ (?:
+ [A-Za-z0-9] |
+ [\-_.!~*'()]
+ ) |
+ %[0-9A-F]{2} |
+ [&=+$,]
+ ){0,255}
+ $/x
+ }
+ configuration.merge!( options )
+ validates_format_of( attr_names, configuration )
+ end
+
+end
+
+
+
+module CustomValidators
+
+ # Validates a URL.
+ # TODO Convert this into a proper ActiveRecord validator.
+ #
+ def self.validate_url( url_str )
+ return false if url_str.blank?
+ require 'uri'
+ begin
+ uri = URI.parse( url_str )
+ return false if ! uri.absolute?
+ return false if ! uri.hierarchical?
+ return false if !( uri.is_a?( URI::HTTP ) || uri.is_a?( URI::HTTPS ) )
+ rescue URI::InvalidURIError
+ return false
+ end
+ return true
+ end
+
+end
+
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
new file mode 100644
index 0000000..999df20
--- /dev/null
+++ b/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# Disable root element in JSON by default.
+ActiveSupport.on_load(:active_record) do
+ self.include_root_in_json = false
+end