Added helper is_role().

This commit is contained in:
Martin Edenhofer 2012-09-04 18:39:23 +02:00
parent 4f02fb1f7d
commit 9ec70b1a0e

View file

@ -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