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.
2010-01-18 07:52:52 +00:00
|
|
|
module AdminHelper
|
|
|
|
|
2012-02-15 10:20:44 +00:00
|
|
|
# Check if the current_user is manager in current module app
|
|
|
|
def is_manager?
|
2012-11-06 09:51:42 +00:00
|
|
|
(@module_app.is_manager?(current_or_guest_user) rescue nil) || is_admin?
|
2012-02-15 10:20:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Check if the current_user is sub manager in current module app
|
|
|
|
def is_sub_manager?
|
2012-11-06 09:51:42 +00:00
|
|
|
(@module_app.is_sub_manager?(current_or_guest_user) rescue nil) || is_admin?
|
2012-02-15 10:20:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def is_admin?
|
2012-12-03 10:52:36 +00:00
|
|
|
current_or_guest_user.admin? rescue false
|
2012-02-15 10:20:44 +00:00
|
|
|
end
|
2012-09-11 03:30:58 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-07-30 16:01:48 +00:00
|
|
|
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
|
|
|
|
|
2010-01-18 07:52:52 +00:00
|
|
|
end
|