This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/helpers/admin_helper.rb

42 lines
847 B
Ruby

module AdminHelper
# Check if the current_user is manager in current module app
def is_manager?
(@module_app.is_manager?(current_or_guest_user) rescue nil) || is_admin?
end
# Check if the current_user is sub manager in current module app
def is_sub_manager?
(@module_app.is_sub_manager?(current_or_guest_user) rescue nil) || is_admin?
end
def is_admin?
current_or_guest_user.admin? rescue false
end
def is_member?
if (current_user rescue false)
return true
end
return false
end
def is_guest?
if session[:guest_user_id]
return true
end
return false
end
def get_user_module_role(user)
if user.admin?
t(:admin)
elsif @module_app.is_manager?(user)
t(:manager)
elsif @module_app.is_sub_manager?(user)
t(:sub_manager)
end
end
end