summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application_controller.rb12
-rw-r--r--app/controllers/call_forwards_controller.rb4
-rw-r--r--app/controllers/gui_functions_controller.rb2
-rw-r--r--app/controllers/softkeys_controller.rb2
-rw-r--r--app/controllers/tenants_controller.rb8
-rw-r--r--app/views/phone_numbers/_form_core.html.haml4
-rw-r--r--test/unit/callthrough_test.rb12
7 files changed, 22 insertions, 22 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e4165f3..2d49890 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -106,7 +106,7 @@ 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
@@ -121,13 +121,13 @@ class ApplicationController < ActionController::Base
private
- def current_user
- begin
- @current_user ||= User.find(session[:user_id]) if session[:user_id]
- rescue ActiveRecord::RecordNotFound
+ def current_user
+ if session[:user_id] && User.where(:id => session[:user_id]).any?
+ return User.where(:id => session[:user_id]).first
+ else
session[:user_id] = nil
+ return nil
end
- @current_user
end
def go_to_setup_if_new_installation
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/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/softkeys_controller.rb b/app/controllers/softkeys_controller.rb
index d2a2bb9..8f363cd 100644
--- a/app/controllers/softkeys_controller.rb
+++ b/app/controllers/softkeys_controller.rb
@@ -61,7 +61,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/tenants_controller.rb b/app/controllers/tenants_controller.rb
index 37874b2..f30246b 100644
--- a/app/controllers/tenants_controller.rb
+++ b/app/controllers/tenants_controller.rb
@@ -27,17 +27,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
#
diff --git a/app/views/phone_numbers/_form_core.html.haml b/app/views/phone_numbers/_form_core.html.haml
index a1ce1f3..a0a69db 100644
--- a/app/views/phone_numbers/_form_core.html.haml
+++ b/app/views/phone_numbers/_form_core.html.haml
@@ -4,7 +4,7 @@
= f.input :name, :collection => ['Office', 'Home', 'Mobile', 'Fax'], :include_blank => false, :label => t('phone_numbers.form.name.label'), :hint => conditional_hint('phone_numbers.form.name.hint')
= f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :autofocus => true
- else
- - if @callthrough || @hunt_group_member || @access_authorization || @current_user.current_tenant.array_of_available_internal_extensions_and_dids.count == 0 || @current_user.current_tenant.array_of_available_internal_extensions_and_dids.count > 250
+ - if @callthrough || @hunt_group_member || @access_authorization || current_user.current_tenant.array_of_available_internal_extensions_and_dids.count == 0 || current_user.current_tenant.array_of_available_internal_extensions_and_dids.count > 250
= f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :autofocus => true
- else
- = f.input :number, :collection => @current_user.current_tenant.array_of_available_internal_extensions_and_dids, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :include_blank => false, :autofocus => true
+ = f.input :number, :collection => current_user.current_tenant.array_of_available_internal_extensions_and_dids, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :include_blank => false, :autofocus => true
diff --git a/test/unit/callthrough_test.rb b/test/unit/callthrough_test.rb
index 5764c0d..2e8cc56 100644
--- a/test/unit/callthrough_test.rb
+++ b/test/unit/callthrough_test.rb
@@ -12,7 +12,7 @@ class CallthroughTest < ActiveSupport::TestCase
@gemeinschaft_setup.country = Country.first
@gemeinschaft_setup.language = Language.first
- @current_user = @gemeinschaft_setup.build_user(
+ current_user = @gemeinschaft_setup.build_user(
:user_name => I18n.t('gemeinschaft_setups.initial_setup.admin_name'),
:male => true,
:email => 'admin@localhost',
@@ -52,18 +52,18 @@ class CallthroughTest < ActiveSupport::TestCase
@tenant.did_list = '02622-70648-x, 02622-706480'
@tenant.save
- @tenant.tenant_memberships.create(:user_id => @current_user.id)
- @current_user.update_attributes!(:current_tenant_id => @tenant.id)
+ @tenant.tenant_memberships.create(:user_id => current_user.id)
+ current_user.update_attributes!(:current_tenant_id => @tenant.id)
# The first user becomes a member of the 'admin' UserGroup
#
admin_group = @tenant.user_groups.create(:name => I18n.t('gemeinschaft_setups.initial_setup.admin_group_name'))
- admin_group.users << @current_user
+ admin_group.users << current_user
# User group
#
user_group = @tenant.user_groups.create(:name => I18n.t('gemeinschaft_setups.initial_setup.user_group_name'))
- user_group.users << @current_user
+ user_group.users << current_user
# Generate the internal_extensions
#
@@ -84,7 +84,7 @@ class CallthroughTest < ActiveSupport::TestCase
#
assert @gemeinschaft_setup.valid?
assert @sip_domain.valid?
- assert @current_user.valid?
+ assert current_user.valid?
assert @tenant.valid?