From 9ec70b1a0efc32def1d5f087338c32d9b8509552 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 4 Sep 2012 18:39:23 +0200 Subject: [PATCH] Added helper is_role(). --- app/controllers/application_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 286cc1b52..b803307fc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base include UserInfo # http_basic_authenticate_with :name => "test", :password => "ttt" - helper_method :current_user, :authentication_check, :config_frontend, :user_data_full + helper_method :current_user, :authentication_check, :config_frontend, :user_data_full, :is_role before_filter :set_user before_filter :cors_preflight_check @@ -127,6 +127,14 @@ class ApplicationController < ActionController::Base UserInfo.current_user_id = current_user.id end + def is_role( role_name ) + return false if !current_user + current_user.roles.each { |role| + return true if role.name == role_name + } + return false + end + def log_view (object) history_type = History::Type.where( :name => 'viewed' ).first if !history_type || !history_type.id