summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application_controller.rb63
-rw-r--r--app/controllers/backup_jobs_controller.rb46
-rw-r--r--app/controllers/call_forwards_controller.rb4
-rw-r--r--app/controllers/call_routes_controller.rb93
-rw-r--r--app/controllers/config_polycom_controller.rb69
-rw-r--r--app/controllers/config_siemens_controller.rb12
-rw-r--r--app/controllers/config_snom_controller.rb48
-rw-r--r--app/controllers/fax_documents_controller.rb25
-rw-r--r--app/controllers/gemeinschaft_setups_controller.rb7
-rw-r--r--app/controllers/gui_functions_controller.rb2
-rw-r--r--app/controllers/intruders_controller.rb41
-rw-r--r--app/controllers/page_controller.rb14
-rw-r--r--app/controllers/phone_numbers_controller.rb45
-rw-r--r--app/controllers/route_elements_controller.rb16
-rw-r--r--app/controllers/softkeys_controller.rb23
-rw-r--r--app/controllers/system_messages_controller.rb30
-rw-r--r--app/controllers/tenants_controller.rb9
17 files changed, 351 insertions, 196 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e4165f3..d1d918e 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,26 +2,21 @@ class ApplicationController < ActionController::Base
protect_from_forgery
- before_filter :set_locale
+ before_filter :start_setup_if_new_installation
- before_filter :go_to_setup_if_new_installation
- before_filter :home_breadcrumb
-
+ before_filter :set_locale
helper_method :current_user
-
+
helper_method :guess_local_ip_address
helper_method :guess_local_host
-
+
+ before_filter :home_breadcrumb
+
helper_method :'have_https?'
+ helper_method :'single_sign_on_system?'
helper_method :random_pin
-
- #TODO Add check_authorization. See
- # https://github.com/ryanb/cancan
- # https://github.com/ryanb/cancan/wiki/Ensure-Authorization
- # and Gemeinschaft 4
-
# Generate a new name for an Object
#
def generate_a_new_name(parent, child = nil)
@@ -56,6 +51,8 @@ class ApplicationController < ActionController::Base
def random_pin
if GsParameter.get('MINIMUM_PIN_LENGTH') > 0
(1..GsParameter.get('MINIMUM_PIN_LENGTH')).map{|i| (0 .. 9).to_a.sample}.join
+ else
+ (1..8).map{|i| (0 .. 9).to_a.sample}.join
end
end
@@ -106,33 +103,41 @@ class ApplicationController < ActionController::Base
end
rescue_from CanCan::AccessDenied do |exception|
- if @current_user
+ if current_user
redirect_to root_url, :alert => 'Access denied! Please ask your admin to grant you the necessary rights.'
else
- if Tenant.count == 0 && User.count == 0
- # This is a brand new system. We need to run a setup first.
- redirect_to wizards_new_initial_setup_path
- else
- # You need to login first.
- redirect_to log_in_path, :alert => 'Access denied! You need to login first.'
- end
+ # You need to login first.
+ redirect_to log_in_path, :alert => 'Access denied! You need to login first.'
end
end
private
- def current_user
- begin
- @current_user ||= User.find(session[:user_id]) if session[:user_id]
- rescue ActiveRecord::RecordNotFound
- session[:user_id] = nil
+ def current_user
+ if session[:user_id].nil? && single_sign_on_system?
+ auth_user = User.where(:user_name => request.env[GsParameter.get('SingleSignOnEnvUserNameKey')]).first
+ else
+ if session[:user_id] && User.where(:id => session[:user_id]).any?
+ auth_user = User.where(:id => session[:user_id]).first
+ else
+ auth_user = nil
+ end
+ end
+ session[:user_id] = auth_user.try(:id)
+ return auth_user
+ end
+
+ def single_sign_on_system?
+ if GsParameter.get('SingleSignOnEnvUserNameKey').blank?
+ false
+ else
+ true
end
- @current_user
- end
+ end
- def go_to_setup_if_new_installation
+ def start_setup_if_new_installation
if Rails.env != 'test'
- if GemeinschaftSetup.all.count == 0
+ if GemeinschaftSetup.count == 0
redirect_to new_gemeinschaft_setup_path
end
end
diff --git a/app/controllers/backup_jobs_controller.rb b/app/controllers/backup_jobs_controller.rb
new file mode 100644
index 0000000..31b9c21
--- /dev/null
+++ b/app/controllers/backup_jobs_controller.rb
@@ -0,0 +1,46 @@
+class BackupJobsController < ApplicationController
+ load_and_authorize_resource :backup_job
+
+ before_filter :spread_breadcrumbs
+
+ def index
+ end
+
+ def show
+ end
+
+ def new
+ # Do the same as create.
+ #
+ @backup_job = BackupJob.new(:started_at => Time.now)
+
+ if @backup_job.save
+ redirect_to backup_jobs_path, :notice => t('backup_jobs.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def create
+ @backup_job = BackupJob.new(:started_at => Time.now)
+
+ if @backup_job.save
+ redirect_to backup_jobs_path, :notice => t('backup_jobs.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def destroy
+ @backup_job.destroy
+ redirect_to backup_jobs_url, :notice => t('backup_jobs.controller.successfuly_destroyed')
+ end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("backup_jobs.index.page_title"), backup_jobs_path
+ if @backup_job && !@backup_job.new_record?
+ add_breadcrumb @backup_job, @backup_job
+ end
+ end
+end
diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb
index 001ed60..b1ced87 100644
--- a/app/controllers/call_forwards_controller.rb
+++ b/app/controllers/call_forwards_controller.rb
@@ -28,7 +28,7 @@ class CallForwardsController < ApplicationController
@available_call_forward_cases = []
CallForwardCase.all.each do |available_call_forward_case|
- if GuiFunction.display?("call_forward_case_#{available_call_forward_case.value}_field_in_call_forward_form", @current_user)
+ if GuiFunction.display?("call_forward_case_#{available_call_forward_case.value}_field_in_call_forward_form", current_user)
@available_call_forward_cases << available_call_forward_case
end
end
@@ -112,7 +112,7 @@ class CallForwardsController < ApplicationController
voice_mail_destination,
]
- if GuiFunction.display?('huntgroup_in_destination_field_in_call_forward_form', @current_user)
+ if GuiFunction.display?('huntgroup_in_destination_field_in_call_forward_form', current_user)
HuntGroup.all.each do |hunt_group|
hunt_group_destination = CallForwardingDestination.new()
hunt_group_destination.id = "#{hunt_group.id}:HuntGroup"
diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb
index 0259a10..2dcd648 100644
--- a/app/controllers/call_routes_controller.rb
+++ b/app/controllers/call_routes_controller.rb
@@ -1,5 +1,11 @@
class CallRoutesController < ApplicationController
- authorize_resource :call_route
+ authorize_resource :call_route, :except => [:sort]
+
+ before_filter { |controller|
+ if !params[:call_route].blank? && !params[:call_route][:endpoint_str].blank?
+ params[:call_route][:endpoint_type], delimeter, params[:call_route][:endpoint_id] = params[:call_route][:endpoint_str].partition('=')
+ end
+ }
def index
@call_routes = CallRoute.order([:routing_table, :position])
@@ -14,6 +20,11 @@ class CallRoutesController < ApplicationController
def new
@call_route = CallRoute.new
+ @endpoints = Gateway.all.collect {|r| [ "gateway: #{r.to_s}", "gateway=#{r.id}" ] }
+ @endpoints << [ 'phonenumber', 'phonenumber=' ]
+ @endpoints << [ 'dialplanfunction', 'dialplanfunction=' ]
+ @endpoints << [ 'hangup', 'hangup=' ]
+ @endpoints << [ 'unknown', 'unknown=' ]
spread_breadcrumbs
end
@@ -29,12 +40,18 @@ class CallRoutesController < ApplicationController
def edit
@call_route = CallRoute.find(params[:id])
+ @endpoints = Gateway.all.collect {|r| [ "gateway: #{r.to_s}", "gateway=#{r.id}" ] }
+ @endpoints << [ 'phonenumber', 'phonenumber=' ]
+ @endpoints << [ 'dialplanfunction', 'dialplanfunction=' ]
+ @endpoints << [ 'hangup', 'hangup=' ]
+ @endpoints << [ 'unknown', 'unknown=' ]
spread_breadcrumbs
end
def update
@call_route = CallRoute.find(params[:id])
spread_breadcrumbs
+
if @call_route.update_attributes(call_route_parameter_params)
redirect_to @call_route, :notice => t('call_routes.controller.successfuly_updated')
else
@@ -48,21 +65,31 @@ class CallRoutesController < ApplicationController
redirect_to call_routes_url, :notice => t('call_routes.controller.successfuly_destroyed')
end
- def move_higher
- @call_route = CallRoute.find(params[:id])
- @call_route.move_higher
- redirect_to :back
+ def sort
+ params[:call_route].each_with_index do |id, index|
+ CallRoute.update_all({position: index+1}, {id: id})
+ #CallRoute.find(:id).move_to_bottom
+ end
+ render nothing: true
end
- def move_lower
- @call_route = CallRoute.find(params[:id])
- @call_route.move_lower
- redirect_to :back
+ def show_variables
+ @channel_variables = Hash.new()
+ file_name = '/var/log/freeswitch/variables'
+ if File.readable?(file_name)
+ File.readlines(file_name).each do |line|
+ key, delimeter, value = line.partition(': ')
+ key = to_channel_variable_name(key)
+ if !key.blank?
+ @channel_variables[key] = URI.unescape(value.gsub(/\n/, ''));
+ end
+ end
+ end
end
private
def call_route_parameter_params
- params.require(:call_route).permit(:routing_table, :name, :endpoint_type, :endpoint_id)
+ params.require(:call_route).permit(:routing_table, :name, :endpoint_type, :endpoint_id, :position)
end
def spread_breadcrumbs
@@ -72,4 +99,50 @@ class CallRoutesController < ApplicationController
end
end
+ def to_channel_variable_name(name)
+ variables_map = {
+ 'Channel-State' => 'state',
+ 'Channel-State-Number' => 'state_number',
+ 'Channel-Name' => 'channel_name',
+ 'Unique-ID' => 'uuid',
+ 'Call-Direction' => 'direction',
+ 'Answer-State' => 'state',
+ 'Channel-Read-Codec-Name' => 'read_codec',
+ 'Channel-Read-Codec-Rate' => 'read_rate',
+ 'Channel-Write-Codec-Name' => 'write_codec',
+ 'Channel-Write-Codec-Rate' => 'write_rate',
+ 'Caller-Username' => 'username',
+ 'Caller-Dialplan' => 'dialplan',
+ 'Caller-Caller-ID-Name' => 'caller_id_name',
+ 'Caller-Caller-ID-Number' => 'caller_id_number',
+ 'Caller-ANI' => 'ani',
+ 'Caller-ANI-II' => 'aniii',
+ 'Caller-Network-Addr' => 'network_addr',
+ 'Caller-Destination-Number' => 'destination_number',
+ 'Caller-Unique-ID' => 'uuid',
+ 'Caller-Source' => 'source',
+ 'Caller-Context' => 'context',
+ 'Caller-RDNIS' => 'rdnis',
+ 'Caller-Channel-Name' => 'channel_name',
+ 'Caller-Profile-Index' => 'profile_index',
+ 'Caller-Channel-Created-Time' => 'created_time',
+ 'Caller-Channel-Answered-Time' => 'answered_time',
+ 'Caller-Channel-Hangup-Time' => 'hangup_time',
+ 'Caller-Channel-Transfer-Time' => 'transfer_time',
+ 'Caller-Screen-Bit' => 'screen_bit',
+ 'Caller-Privacy-Hide-Name' => 'privacy_hide_name',
+ 'Caller-Privacy-Hide-Number' => 'privacy_hide_number',
+ }
+
+ name = name.gsub(/[^a-zA-Z1-9_\-]/, '')
+
+ if variables_map[name]
+ return variables_map[name]
+ elsif name.match(/^variable_/)
+ return name.gsub(/^variable_/, '')
+ end
+
+ return nil
+ end
+
end
diff --git a/app/controllers/config_polycom_controller.rb b/app/controllers/config_polycom_controller.rb
index 9d44e51..fd730e3 100644
--- a/app/controllers/config_polycom_controller.rb
+++ b/app/controllers/config_polycom_controller.rb
@@ -26,12 +26,15 @@ class ConfigPolycomController < ApplicationController
if ! params[:sip_account].blank?
@sip_account = @phone.sip_accounts.where({ :id => params[:sip_account].to_i }).first
+ if ! @sip_account && @phone.fallback_sip_account && @phone.fallback_sip_account.id == params[:sip_account].to_i
+ @sip_account = @phone.fallback_sip_account
+ end
if ! @sip_account
render(
:status => 404,
:layout => false,
:content_type => 'text/plain',
- :text => "<!-- SipAccount not found -->",
+ :text => "<!-- SipAccount ID:#{params[:sip_account]} not found -->",
)
return false
end
@@ -113,37 +116,41 @@ class ConfigPolycomController < ApplicationController
softkey_index = 1
blf_index = 0
- @phone.sip_accounts.each do |sip_account|
- sip_account_index = 0
- if (sip_account.sip_accountable_type == @phone.phoneable_type) and (sip_account.sip_accountable_id == @phone.phoneable_id)
- sip_account_index += 1
- if sip_account_index == 1
- xml_applications_url = "#{request.protocol}#{request.host_with_port}/config_polycom/#{@phone.id}/#{sip_account.id}"
- @settings['voIpProt.SIP.outboundProxy.address'] = sip_account.host
- @settings['voIpProt.SIP.outboundProxy.port'] = SIP_DEFAULT_PORT
- end
+ phone_sip_accounts = Array.new()
+ if @phone.sip_accounts && @phone.sip_accounts.count > 0
+ phone_sip_accounts = @phone.sip_accounts
+ elsif @phone.fallback_sip_account
+ phone_sip_accounts.push( @phone.fallback_sip_account )
+ end
+ sip_account_index = 0
+ phone_sip_accounts.each do |sip_account|
+ sip_account_index += 1
+ if sip_account_index == 1
+ xml_applications_url = "#{request.protocol}#{request.host_with_port}/config_polycom/#{@phone.id}/#{sip_account.id}"
+ @settings['voIpProt.SIP.outboundProxy.address'] = sip_account.host
+ @settings['voIpProt.SIP.outboundProxy.port'] = SIP_DEFAULT_PORT
+ end
- @settings["reg.#{sip_account_index}.address"] = "#{sip_account.auth_name}@#{sip_account.host}"
- @settings["reg.#{sip_account_index}.auth.password"] = sip_account.password
- @settings["reg.#{sip_account_index}.auth.userId"] = sip_account.auth_name
- @settings["reg.#{sip_account_index}.displayName"] = 'Call'
- @settings["reg.#{sip_account_index}.label"] = sip_account.caller_name
- @settings["voIpProt.server.#{sip_account_index}.address"] = sip_account.host
- @settings["voIpProt.server.#{sip_account_index}.port"] = SIP_DEFAULT_PORT
- @settings["call.missedCallTracking.#{sip_account_index}.enabled"] = 0
-
- sip_account.softkeys.order(:position).each do |softkey|
- softkey_index += 1
- if softkey.softkey_function
- softkey_function = softkey.softkey_function.name
- end
- case softkey_function
- when 'blf'
- blf_index += 1
- @settings["lineKey.#{softkey_index}.category"] = 'BLF'
- @settings["attendant.resourceList.#{blf_index}.address"] = "#{softkey.number}@#{sip_account.host}"
- @settings["attendant.resourceList.#{blf_index}.label"] = softkey.label
- end
+ @settings["reg.#{sip_account_index}.address"] = "#{sip_account.auth_name}@#{sip_account.host}"
+ @settings["reg.#{sip_account_index}.auth.password"] = sip_account.password
+ @settings["reg.#{sip_account_index}.auth.userId"] = sip_account.auth_name
+ @settings["reg.#{sip_account_index}.displayName"] = 'Call'
+ @settings["reg.#{sip_account_index}.label"] = sip_account.caller_name
+ @settings["voIpProt.server.#{sip_account_index}.address"] = sip_account.host
+ @settings["voIpProt.server.#{sip_account_index}.port"] = SIP_DEFAULT_PORT
+ @settings["call.missedCallTracking.#{sip_account_index}.enabled"] = 0
+
+ sip_account.softkeys.order(:position).each do |softkey|
+ softkey_index += 1
+ if softkey.softkey_function
+ softkey_function = softkey.softkey_function.name
+ end
+ case softkey_function
+ when 'blf'
+ blf_index += 1
+ @settings["lineKey.#{softkey_index}.category"] = 'BLF'
+ @settings["attendant.resourceList.#{blf_index}.address"] = "#{softkey.number}@#{sip_account.host}"
+ @settings["attendant.resourceList.#{blf_index}.label"] = softkey.label
end
end
end
diff --git a/app/controllers/config_siemens_controller.rb b/app/controllers/config_siemens_controller.rb
index b7fa107..bbeba46 100644
--- a/app/controllers/config_siemens_controller.rb
+++ b/app/controllers/config_siemens_controller.rb
@@ -610,15 +610,21 @@ class ConfigSiemensController < ApplicationController
@new_settings << ['stimulus-led-control-uri', key_idx, '' ]
@new_settings << ['stimulus-DTMF-sequence', key_idx, '' ]
when 'call_forwarding'
+ if sk.softkeyable.class == CallForward then
@new_settings << ['function-key-def', key_idx, '63']
- @new_settings << ['stimulus-led-control-uri', key_idx, "f-cftg-#{sk.call_forward_id}" ]
+ @new_settings << ['stimulus-led-control-uri', key_idx, "f-cftg-#{sk.softkeyable.id}" ]
@new_settings << ['send-url-address', key_idx, request.host]
@new_settings << ['send-url-protocol', key_idx, 3]
@new_settings << ['send-url-port', key_idx, '80']
@new_settings << ['send-url-path', key_idx, "/config_siemens/#{@phone.id}/#{@sip_account.id}/call_forwarding.xml"]
- @new_settings << ['send-url-query', key_idx, "id=#{sk.call_forward_id}&function=toggle"]
+ @new_settings << ['send-url-query', key_idx, "id=#{sk.softkeyable.id}&function=toggle"]
@new_settings << ['send-url-method', key_idx, '0']
@new_settings << ['blf-popup', key_idx, 'false']
+ else
+ @new_settings << ['function-key-def', key_idx, '0']
+ @new_settings << ['stimulus-led-control-uri', key_idx, '' ]
+ @new_settings << ['stimulus-DTMF-sequence', key_idx, '' ]
+ end
when 'call_forwarding_always'
phone_number = PhoneNumber.where(:number => sk.number, :phone_numberable_type => 'SipAccount').first
if phone_number
@@ -887,7 +893,7 @@ class ConfigSiemensController < ApplicationController
if @call_forwarding_id
call_forwarding = @sip_account.call_forwards.where(:id => @call_forwarding_id).first
- if !call_forwarding and @sip_account.softkeys.where(:call_forward_id => @call_forwarding_id).count > 0
+ if !call_forwarding and @sip_account.softkeys.where(:softkeyable_id => @call_forwarding_id, :softkeyable_type => 'CallForward').count > 0
call_forwarding = CallForward.where(:id => @call_forwarding_id).first
end
diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb
index e797a43..58cced2 100644
--- a/app/controllers/config_snom_controller.rb
+++ b/app/controllers/config_snom_controller.rb
@@ -247,6 +247,7 @@ class ConfigSnomController < ApplicationController
elsif @phone.fallback_sip_account
phone_sip_accounts.push( @phone.fallback_sip_account )
end
+ expiry_seconds = GsParameter.get('SIP_EXPIRY_SECONDS')
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 = {
@@ -259,7 +260,8 @@ class ConfigSnomController < ApplicationController
:name => sip_account.auth_name,
:realname => 'Call',
:idle_text => sip_account.caller_name,
- :mailbox => "<sip:#{sip_account.auth_name}@#{sip_account.host}>"
+ :mailbox => "<sip:#{sip_account.auth_name}@#{sip_account.host}>",
+ :expiry => expiry_seconds,
}
@sip_accounts.push(snom_sip_account)
sip_account_index = @sip_accounts.length
@@ -280,23 +282,47 @@ class ConfigSnomController < ApplicationController
@softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "speed f-li-#{softkey.number}"})
when 'conference'
@softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "blf <sip:#{softkey.number}@#{sip_account.host}>|f-ta-"})
- when 'call_forwarding'
+ when 'call_parking'
@softkeys.push({
:context => sip_account_index,
- :function => softkey.function,
+ :function => softkey.softkey_function.name,
:label => softkey.label,
:softkey => softkey,
:general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
:subscription => {
- :to => "f-cftg-#{softkey.call_forward_id}@#{sip_account.host}",
+ :to => "park+#{@softkeys.softkeyable_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?id=#{softkey.call_forward_id}&function=toggle",
+ :type => :dial,
+ :target => "f-tpark-#{@softkeys.softkeyable_id}",
+ :when => 'on press',
+ :states => 'connected,holding',
+ },{
+ :type => :dial,
+ :target => "f-park-#{@softkeys.softkeyable_id}",
:when => 'on press',
}],
})
+ 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 => "f-cftg-#{softkey.softkeyable_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?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
@@ -308,7 +334,7 @@ class ConfigSnomController < ApplicationController
@softkeys.push({
:context => sip_account_index,
- :function => softkey.function,
+ :function => softkey.softkey_function.name,
:label => softkey.label,
:softkey => softkey,
:general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
@@ -333,7 +359,7 @@ class ConfigSnomController < ApplicationController
@softkeys.push({
:context => sip_account_index,
- :function => softkey.function,
+ :function => softkey.softkey_function.name,
:label => softkey.label,
:softkey => softkey,
:general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
@@ -373,7 +399,7 @@ class ConfigSnomController < ApplicationController
if hunt_group_member
@softkeys.push({
:context => sip_account_index,
- :function => softkey.function,
+ :function => softkey.softkey_function.name,
:label => softkey.label,
:softkey => softkey,
:general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
@@ -403,7 +429,7 @@ class ConfigSnomController < ApplicationController
if acd_agent
@softkeys.push({
:context => sip_account_index,
- :function => softkey.function,
+ :function => softkey.softkey_function.name,
:label => softkey.label,
:softkey => softkey,
:general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
@@ -922,7 +948,7 @@ AAAA'
if @call_forwarding_id
call_forwarding = @sip_account.call_forwards.where(:id => @call_forwarding_id).first
- if !call_forwarding and @sip_account.softkeys.where(:call_forward_id => @call_forwarding_id).count > 0
+ if !call_forwarding and @sip_account.softkeys.where(:softkeyable_id => @call_forwarding_id, :softkeyable_type => 'CallForward').count > 0
call_forwarding = CallForward.where(:id => @call_forwarding_id).first
end
diff --git a/app/controllers/fax_documents_controller.rb b/app/controllers/fax_documents_controller.rb
index eff9604..5653683 100644
--- a/app/controllers/fax_documents_controller.rb
+++ b/app/controllers/fax_documents_controller.rb
@@ -58,23 +58,18 @@ class FaxDocumentsController < ApplicationController
end
private
+
def spread_breadcrumbs
- breadcrumbs = []
- breadcrumbs = case @fax_account.fax_accountable.class.to_s
- when 'User' ; [
- [@fax_account.fax_accountable.to_s, user_path(@fax_account.fax_accountable)],
- [t('fax_accounts.name').pluralize, user_fax_accounts_path(@fax_account.fax_accountable)],
- [t('fax_documents.name').pluralize, fax_account_fax_documents_path(@fax_account)],
- ]
- when 'UserGroup' ; [
- [@fax_account.fax_accountable, user_group_path(@fax_account.fax_accountable)],
- [t('fax_accounts.name').pluralize, user_group_fax_accounts_path(@fax_account.fax_accountable)],
- [t('fax_documents.name').pluralize, fax_account_fax_documents_path(@fax_account)],
- ]
+ if @fax_account && @fax_account.fax_accountable.class == User
+ add_breadcrumb t("users.index.page_title"), tenant_users_path(@fax_account.fax_accountable.current_tenant)
+ add_breadcrumb @fax_account.fax_accountable, tenant_user_path(@fax_account.fax_accountable.current_tenant, @fax_account.fax_accountable)
end
- if !breadcrumbs.blank?
- breadcrumbs.each do |breadcrumb|
- add_breadcrumb breadcrumb[0], breadcrumb[1]
+
+ if @fax_account
+ add_breadcrumb t("fax_accounts.index.page_title"), user_fax_accounts_path(@fax_account.fax_accountable)
+ add_breadcrumb @fax_account, user_fax_account_path(@fax_account.fax_accountable, @fax_account)
+ if @fax_document && !@fax_document.new_record?
+ add_breadcrumb @fax_document, fax_account_fax_document_path(@fax_account, @fax_document)
end
end
end
diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb
index 4f4a72a..a62df99 100644
--- a/app/controllers/gemeinschaft_setups_controller.rb
+++ b/app/controllers/gemeinschaft_setups_controller.rb
@@ -4,9 +4,9 @@ class GemeinschaftSetupsController < ApplicationController
#
caches_page :new, :gzip => :best_compression
- load_and_authorize_resource :gemeinschaft_setup
+ skip_before_filter :start_setup_if_new_installation
- skip_before_filter :go_to_setup_if_new_installation
+ load_and_authorize_resource :gemeinschaft_setup
def new
@user = @gemeinschaft_setup.build_user(
@@ -23,6 +23,7 @@ class GemeinschaftSetupsController < ApplicationController
@gemeinschaft_setup.default_company_name = generate_a_new_name(Tenant.new)
@gemeinschaft_setup.default_system_email = 'admin@localhost'
+ @gemeinschaft_setup.trunk_access_code = '0'
end
def create
@@ -52,7 +53,7 @@ class GemeinschaftSetupsController < ApplicationController
CallRoute.factory_defaults_prerouting(@gemeinschaft_setup.country.country_code,
@gemeinschaft_setup.country.trunk_prefix,
@gemeinschaft_setup.country.international_call_prefix,
- '',
+ @gemeinschaft_setup.trunk_access_code,
@gemeinschaft_setup.default_area_code
)
diff --git a/app/controllers/gui_functions_controller.rb b/app/controllers/gui_functions_controller.rb
index 0cb7898..4b57322 100644
--- a/app/controllers/gui_functions_controller.rb
+++ b/app/controllers/gui_functions_controller.rb
@@ -58,7 +58,7 @@ class GuiFunctionsController < ApplicationController
private
def load_user_groups
- @user_groups = Tenant.find(@current_user.current_tenant).user_groups.order(:position)
+ @user_groups = Tenant.find(current_user.current_tenant).user_groups.order(:position)
end
def spread_breadcrumbs
diff --git a/app/controllers/intruders_controller.rb b/app/controllers/intruders_controller.rb
new file mode 100644
index 0000000..eb34f2b
--- /dev/null
+++ b/app/controllers/intruders_controller.rb
@@ -0,0 +1,41 @@
+class IntrudersController < ApplicationController
+ def index
+ @intruders = Intruder.all
+ end
+
+ def show
+ @intruder = Intruder.find(params[:id])
+ end
+
+ def new
+ @intruder = Intruder.new
+ end
+
+ def create
+ @intruder = Intruder.new(params[:intruder])
+ if @intruder.save
+ redirect_to @intruder, :notice => t('intruders.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @intruder = Intruder.find(params[:id])
+ end
+
+ def update
+ @intruder = Intruder.find(params[:id])
+ if @intruder.update_attributes(params[:intruder])
+ redirect_to @intruder, :notice => t('intruders.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @intruder = Intruder.find(params[:id])
+ @intruder.destroy
+ redirect_to intruders_url, :notice => t('intruders.controller.successfuly_destroyed')
+ end
+end
diff --git a/app/controllers/page_controller.rb b/app/controllers/page_controller.rb
index 8f4fa88..ed48e3c 100644
--- a/app/controllers/page_controller.rb
+++ b/app/controllers/page_controller.rb
@@ -2,7 +2,6 @@ class PageController < ApplicationController
# load_and_authorize_resource :class => false
# CanCan doesn't work here really good because Page is not a resource.
- before_filter :if_fresh_system_then_go_to_wizard
skip_before_filter :home_breadcrumb, :only => [:index]
def index
@@ -14,18 +13,5 @@ class PageController < ApplicationController
def help
end
-
- private
- def if_fresh_system_then_go_to_wizard
- if Tenant.count == 0 && User.count == 0
- # This is a brand new system. We need to run a setup first.
- redirect_to wizards_new_initial_setup_path
- else
- if current_user.nil?
- # You need to login first.
- redirect_to log_in_path, :alert => I18n.t('pages.controller.access_denied_login_first')
- end
- end
- end
end
diff --git a/app/controllers/phone_numbers_controller.rb b/app/controllers/phone_numbers_controller.rb
index c562954..67c4922 100644
--- a/app/controllers/phone_numbers_controller.rb
+++ b/app/controllers/phone_numbers_controller.rb
@@ -1,22 +1,22 @@
class PhoneNumbersController < ApplicationController
- load_resource :phone_book_entry
- load_resource :sip_account
- load_resource :conference
- load_resource :fax_account
- load_resource :phone_number_range
- load_resource :callthrough
- load_resource :whitelist
- load_resource :access_authorization
- load_resource :hunt_group
- load_resource :hunt_group_member
- load_resource :automatic_call_distributor
- load_and_authorize_resource :phone_number, :through => [:phone_book_entry, :sip_account, :conference,
+ load_resource :phone_book_entry, :except => [:sort]
+ load_resource :sip_account, :except => [:sort]
+ load_resource :conference, :except => [:sort]
+ load_resource :fax_account, :except => [:sort]
+ load_resource :phone_number_range, :except => [:sort]
+ load_resource :callthrough, :except => [:sort]
+ load_resource :whitelist, :except => [:sort]
+ load_resource :access_authorization, :except => [:sort]
+ load_resource :hunt_group, :except => [:sort]
+ load_resource :hunt_group_member, :except => [:sort]
+ load_resource :automatic_call_distributor, :except => [:sort]
+ load_and_authorize_resource :phone_number, :except => [:sort], :through => [:phone_book_entry, :sip_account, :conference,
:fax_account, :phone_number_range, :callthrough,
:whitelist, :access_authorization, :hunt_group,
:hunt_group_member, :automatic_call_distributor]
- before_filter :set_and_authorize_parent
- before_filter :spread_breadcrumbs
+ before_filter :set_and_authorize_parent, :except => [:sort]
+ before_filter :spread_breadcrumbs, :except => [:sort]
def index
end
@@ -67,16 +67,6 @@ class PhoneNumbersController < ApplicationController
redirect_to m.(), :notice => t('phone_numbers.controller.successfuly_destroyed')
end
- def move_higher
- @phone_number.move_higher
- redirect_to :back
- end
-
- def move_lower
- @phone_number.move_lower
- redirect_to :back
- end
-
def call
sip_account = nil
current_user.sip_accounts.each do |user_sip_account|
@@ -94,6 +84,13 @@ class PhoneNumbersController < ApplicationController
redirect_to(:back)
end
+ def sort
+ params[:phone_number].each_with_index do |id, index|
+ PhoneNumber.update_all({position: index+1}, {id: id})
+ end
+ render nothing: true
+ end
+
private
def set_and_authorize_parent
@parent = @phone_book_entry || @sip_account || @conference || @fax_account ||
diff --git a/app/controllers/route_elements_controller.rb b/app/controllers/route_elements_controller.rb
index c4e4c1a..9c9033e 100644
--- a/app/controllers/route_elements_controller.rb
+++ b/app/controllers/route_elements_controller.rb
@@ -5,7 +5,7 @@ class RouteElementsController < ApplicationController
before_filter :spread_breadcrumbs
def index
- @route_elements = @call_route.route_elements
+ @route_elements = @call_route.route_elements.order([:position])
end
def show
@@ -44,14 +44,14 @@ class RouteElementsController < ApplicationController
redirect_to call_route_route_elements_path(@call_route), :notice => t('route_elements.controller.successfuly_destroyed')
end
- def move_higher
- @route_element.move_higher
- redirect_to :back
- end
+ def sort
+ #call_route = RouteElement.find(params[:route_element].first).call_route
+
+ params[:route_element].each do |route_element_id|
+ @call_route.route_elements.find(route_element_id).move_to_bottom
+ end
- def move_lower
- @route_element.move_lower
- redirect_to :back
+ render nothing: true
end
private
diff --git a/app/controllers/softkeys_controller.rb b/app/controllers/softkeys_controller.rb
index d2a2bb9..c9e8c20 100644
--- a/app/controllers/softkeys_controller.rb
+++ b/app/controllers/softkeys_controller.rb
@@ -1,9 +1,9 @@
class SoftkeysController < ApplicationController
- load_and_authorize_resource :sip_account
- load_and_authorize_resource :softkey, :through => [:sip_account]
+ load_and_authorize_resource :sip_account, :except => [:sort]
+ load_and_authorize_resource :softkey, :through => [:sip_account], :except => [:sort]
before_filter :set_available_call_forwards_and_softkey_functions, :only => [ :new, :edit, :update ]
- before_filter :spread_breadcrumbs
+ before_filter :spread_breadcrumbs, :except => [:sort]
def index
end
@@ -44,16 +44,17 @@ class SoftkeysController < ApplicationController
redirect_to sip_account_softkeys_path(@softkey.sip_account), :notice => t('softkeys.controller.successfuly_destroyed')
end
- def move_higher
- @softkey.move_higher
- redirect_to :back
- end
+ def sort
+ sip_account = Softkey.find(params[:softkey].first).sip_account
+
+ params[:softkey].each do |softkey_id|
+ sip_account.softkeys.find(softkey_id).move_to_bottom
+ end
- def move_lower
- @softkey.move_lower
- redirect_to :back
+ render nothing: true
end
+
private
def set_available_call_forwards_and_softkey_functions
@@ -61,7 +62,7 @@ class SoftkeysController < ApplicationController
@softkey_functions = []
SoftkeyFunction.accessible_by(current_ability, :read).each do |softkey_function|
- if GuiFunction.display?("softkey_function_#{softkey_function.name.downcase}_field_in_softkey_form", @current_user)
+ if GuiFunction.display?("softkey_function_#{softkey_function.name.downcase}_field_in_softkey_form", current_user)
@softkey_functions << softkey_function
end
end
diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb
deleted file mode 100644
index d7fe515..0000000
--- a/app/controllers/system_messages_controller.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-class SystemMessagesController < ApplicationController
- load_and_authorize_resource :user
- load_and_authorize_resource :system_message, :through => [:user]
-
- def index
- @system_messages = @system_messages.where(:created_at => Time.now - 6.hours .. Time.now)
- end
-
- def show
- end
-
- def new
- @system_message = @user.system_messages.build
- end
-
- def create
- @system_message = @user.system_messages.build(params[:system_message])
- if @system_message.save
- # Push the new message via AJAX to the browser.
- #
- # PrivatePub.publish_to("/users/#{@system_message.user.id}/system_messages",
- # "$('#system_message').empty();$('#system_message').append('<span class=\"created_at\">#{(I18n.l @system_message.created_at, :format => :short )}</span> #{@system_message.content}');$('#system_message_display').fadeIn();"
- # )
-
- redirect_to user_system_message_path(@user, @system_message), :notice => t('system_messages.controller.successfuly_created')
- else
- render :new
- end
- end
-end
diff --git a/app/controllers/tenants_controller.rb b/app/controllers/tenants_controller.rb
index 37874b2..b6a96b7 100644
--- a/app/controllers/tenants_controller.rb
+++ b/app/controllers/tenants_controller.rb
@@ -8,6 +8,7 @@ class TenantsController < ApplicationController
def show
@tenant = Tenant.find(params[:id])
@gateways = Gateway.order(:updated_at)
+ @backup_jobs = BackupJob.order(:finished_at).last(5)
end
def new
@@ -27,17 +28,17 @@ class TenantsController < ApplicationController
if @tenant.save
# Become a member of this tenant.
#
- @tenant.tenant_memberships.create(:user_id => @current_user.id)
+ @tenant.tenant_memberships.create(:user_id => current_user.id)
# Groups
#
admin_group = @tenant.user_groups.create(:name => t('gemeinschaft_setups.initial_setup.admin_group_name'))
- admin_group.users << @current_user
+ admin_group.users << current_user
user_group = @tenant.user_groups.create(:name => t('gemeinschaft_setups.initial_setup.user_group_name'))
- user_group.users << @current_user
+ user_group.users << current_user
- @current_user.update_attributes!(:current_tenant_id => @tenant.id)
+ current_user.update_attributes!(:current_tenant_id => @tenant.id)
# Generate the internal_extensions
#