summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/call_histories_controller.rb5
-rw-r--r--app/controllers/config_snom_controller.rb5
-rw-r--r--app/controllers/gateways_controller.rb2
-rw-r--r--app/controllers/gemeinschaft_setups_controller.rb28
-rw-r--r--app/controllers/page_controller.rb5
-rw-r--r--app/controllers/sip_accounts_controller.rb2
-rw-r--r--app/controllers/tenants_controller.rb4
-rw-r--r--app/controllers/trigger_controller.rb124
-rw-r--r--app/controllers/voicemail_settings_controller.rb3
9 files changed, 165 insertions, 13 deletions
diff --git a/app/controllers/call_histories_controller.rb b/app/controllers/call_histories_controller.rb
index 5335ed3..2bfd4e3 100644
--- a/app/controllers/call_histories_controller.rb
+++ b/app/controllers/call_histories_controller.rb
@@ -44,7 +44,10 @@ class CallHistoriesController < ApplicationController
if can?(:destroy, @call_history)
@call_history.destroy
m = method( :"#{@parent.class.name.underscore}_call_histories_url" )
- redirect_to m.(), :notice => t('call_histories.controller.successfuly_destroyed')
+ respond_to do |format|
+ format.html { redirect_to m.(), :notice => t('call_histories.controller.successfuly_destroyed')}
+ format.js
+ end
end
end
diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb
index 149e601..e797a43 100644
--- a/app/controllers/config_snom_controller.rb
+++ b/app/controllers/config_snom_controller.rb
@@ -158,12 +158,15 @@ class ConfigSnomController < 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].to_i} not found -->",
)
end
end
diff --git a/app/controllers/gateways_controller.rb b/app/controllers/gateways_controller.rb
index 5741195..d3362e0 100644
--- a/app/controllers/gateways_controller.rb
+++ b/app/controllers/gateways_controller.rb
@@ -13,6 +13,7 @@ class GatewaysController < ApplicationController
def new
@gateway = Gateway.new
+ @technologies = Gateway::TECHNOLOGIES
spread_breadcrumbs
end
@@ -28,6 +29,7 @@ class GatewaysController < ApplicationController
def edit
@gateway = Gateway.find(params[:id])
+ @technologies = Gateway::TECHNOLOGIES
spread_breadcrumbs
end
diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb
index 347e043..4f4a72a 100644
--- a/app/controllers/gemeinschaft_setups_controller.rb
+++ b/app/controllers/gemeinschaft_setups_controller.rb
@@ -20,6 +20,9 @@ class GemeinschaftSetupsController < ApplicationController
)
@gemeinschaft_setup.country = Country.find_by_name('Germany')
@gemeinschaft_setup.language = Language.find_by_name('Deutsch')
+
+ @gemeinschaft_setup.default_company_name = generate_a_new_name(Tenant.new)
+ @gemeinschaft_setup.default_system_email = 'admin@localhost'
end
def create
@@ -64,11 +67,34 @@ class GemeinschaftSetupsController < ApplicationController
FreeswitchAPI.execute('fsctl', 'shutdown restart')
end
+ # Create the tenant
+ tenant = Tenant.create({:name => @gemeinschaft_setup.default_company_name,
+ :sip_domain_id => SipDomain.last.id,
+ :country_id => @gemeinschaft_setup.country.id,
+ :language_id => @gemeinschaft_setup.language_id,
+ :from_field_voicemail_email => @gemeinschaft_setup.default_system_email,
+ :from_field_pin_change_email => @gemeinschaft_setup.default_system_email,
+ })
+
+ # Become a member of this tenant.
+ #
+ tenant.tenant_memberships.create(:user_id => user.id)
+
+ # Groups
+ #
+ admin_group = tenant.user_groups.create(:name => t('gemeinschaft_setups.initial_setup.admin_group_name'))
+ admin_group.users << user
+
+ user_group = tenant.user_groups.create(:name => t('gemeinschaft_setups.initial_setup.user_group_name'))
+ user_group.users << user
+
+ user.update_attributes!(:current_tenant_id => tenant.id)
+
# Auto-Login:
session[:user_id] = user.id
# Redirect to the user
- redirect_to new_tenant_url, :notice => t('gemeinschaft_setups.initial_setup.successful_setup')
+ redirect_to page_help_path, :notice => t('gemeinschaft_setups.initial_setup.successful_setup')
else
render :new
end
diff --git a/app/controllers/page_controller.rb b/app/controllers/page_controller.rb
index dc5f57b..8f4fa88 100644
--- a/app/controllers/page_controller.rb
+++ b/app/controllers/page_controller.rb
@@ -11,8 +11,9 @@ class PageController < ApplicationController
end
end
- def conference;end
- def beginners_intro;end
+ def help
+
+ end
private
def if_fresh_system_then_go_to_wizard
diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb
index a83208b..b5c3ae4 100644
--- a/app/controllers/sip_accounts_controller.rb
+++ b/app/controllers/sip_accounts_controller.rb
@@ -71,7 +71,7 @@ class SipAccountsController < ApplicationController
def destroy
@sip_account.destroy
m = method( :"#{@parent.class.name.underscore}_sip_accounts_url" )
- redirect_to :back, :notice => t('sip_accounts.controller.successfuly_destroyed')
+ redirect_to :root, :notice => t('sip_accounts.controller.successfuly_destroyed')
end
private
diff --git a/app/controllers/tenants_controller.rb b/app/controllers/tenants_controller.rb
index cb67e5f..37874b2 100644
--- a/app/controllers/tenants_controller.rb
+++ b/app/controllers/tenants_controller.rb
@@ -70,7 +70,7 @@ class TenantsController < ApplicationController
:amount_of_numbers => @tenant.array_of_internal_extension_numbers.count + @tenant.array_of_dids.count
)
else
- redirect_to page_beginners_intro_path, :notice => t('tenants.controller.successfuly_created_plus_delayed_jobs',
+ redirect_to page_help_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
)
@@ -81,7 +81,7 @@ class TenantsController < ApplicationController
:resource => @tenant
)
else
- redirect_to page_beginners_intro_path, :notice => t('tenants.controller.successfuly_created',
+ redirect_to page_help_path, :notice => t('tenants.controller.successfuly_created',
:resource => @tenant
)
end
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb
index e9821f6..ac43832 100644
--- a/app/controllers/trigger_controller.rb
+++ b/app/controllers/trigger_controller.rb
@@ -1,11 +1,127 @@
class TriggerController < ApplicationController
+ TIFF_FUFFIX = ".tiff"
+ PDF_SUFFIX = ".pdf"
+ TMP_DIR = "/tmp/"
+
def voicemail
- # Something is triggered when ever a local script fetches this action.
- #
+ if !params[:sip_account_id].blank?
+ sip_account = SipAccount.where(:id => params[:sip_account_id].to_i).first
+ if sip_account
+ sip_account.voicemail_messages.where(:notification => nil).each do |message|
+ message.notification = false
+ message.save
+ if !File.exists?( message.file_path )
+ next
+ end
+
+ user = sip_account.sip_accountable
+ if user.class != User
+ next
+ end
+
+ if user.email.blank?
+ next
+ end
+
+ voicemail_settings = sip_account.voicemail_setting
+ if !voicemail_settings
+ voicemail_settings = VoicemailSetting.new(:notify => user.send_voicemail_as_email_attachment, :attachment => user.send_voicemail_as_email_attachment, :mark_read => user.send_voicemail_as_email_attachment)
+ end
+
+ message.notification = voicemail_settings.notify
+ if voicemail_settings.notify
+ if Notifications.new_voicemail(message, voicemail_settings.attachment).deliver
+ if voicemail_settings.purge
+ message.delete
+ next
+ end
+ message.save
+ if voicemail_settings.mark_read
+ message.mark_read
+ end
+ end
+ else
+ message.save
+ end
+ end
+
+ render(
+ :status => 200,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- OK -->",
+ )
+ else
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Account not found -->",
+ )
+ end
+ end
end
def fax
- # Something is triggered when ever a local script fetches this action.
- #
+ if !params[:fax_account_id].blank?
+ fax_account = FaxAccount.where(:id => params[:fax_account_id].to_i).first
+ if fax_account
+ fax_account.fax_documents.where(:state => 'received').each do |fax_document|
+
+ tiff_file = File.basename(fax_document.tiff.to_s)
+
+ if !File.exists?( "#{TMP_DIR}#{tiff_file}" )
+ fax_document.state = 'unsuccessful'
+ fax_document.save
+ next
+ end
+
+ paper_size = "letter"
+ pdf_file = "#{TMP_DIR}#{File.basename(tiff_file, TIFF_FUFFIX)}#{PDF_SUFFIX}"
+
+ system "tiff2pdf \\
+ -o \"#{pdf_file}\" \\
+ -p #{paper_size} \\
+ -a \"#{fax_document.remote_station_id}\" \\
+ -c \"AMOOMA Gemeinschaft version #{GsParameter.get('GEMEINSCHAFT_VERSION')}\" \\
+ -t \"#{fax_document.remote_station_id}\" \"#{TMP_DIR}#{tiff_file}\""
+
+ if !File.exists?( pdf_file )
+ fax_document.state = 'unsuccessful'
+ fax_document.save
+ next
+ end
+
+ fax_document.document = File.open(pdf_file)
+ fax_document.state = 'successful'
+
+ if fax_document.save
+ Notifications.new_fax(fax_document).deliver
+ File.delete("#{TMP_DIR}#{tiff_file}");
+ File.delete(pdf_file);
+ fax_document.tiff = nil
+ fax_document.save
+ fax_document.render_thumbnails
+ else
+ fax_document.state = 'unsuccessful'
+ fax_document.save
+ end
+ end
+
+ render(
+ :status => 200,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- OK -->",
+ )
+ else
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Account not found -->",
+ )
+ end
+ end
end
end
diff --git a/app/controllers/voicemail_settings_controller.rb b/app/controllers/voicemail_settings_controller.rb
index d31de8f..5de0c35 100644
--- a/app/controllers/voicemail_settings_controller.rb
+++ b/app/controllers/voicemail_settings_controller.rb
@@ -71,7 +71,8 @@ class VoicemailSettingsController < ApplicationController
end
def voicemail_defaults
- path = "/opt/freeswitch/storage/voicemail/default/#{@sip_account.sip_domain.host}/#{@sip_account.auth_name}/"
+ storage_dir = GsParameter.where(:entity => 'voicemail', :section => 'parameters', :name => 'storage-dir').first.try(:value)
+ path = "#{storage_dir}/#{@sip_account.sip_domain.host}/#{@sip_account.auth_name}/"
@greeting_files = Dir.glob("#{path}*greeting*.wav").collect {|r| [ File.basename(r), File.expand_path(r) ] }
@name_files = Dir.glob("#{path}*name*.wav").collect {|r| [ File.basename(r), File.expand_path(r) ] }