Orbit/lib/orbit_app/helper/context_link_renderer.rb

33 lines
960 B
Ruby
Raw Normal View History

module ContextLinkRenderer
include Renderer
2012-12-05 10:35:58 +00:00
def render(request,params,current_module_app,current_user,belong_module_app)
@current_module_app = current_module_app
@belong_module_app = belong_module_app
@request = request
@params = params
2012-12-05 10:35:58 +00:00
@current_user = current_user
if display?
2013-05-02 03:35:48 +00:00
content_tag :li, link_to(content_tag(:span, I18n.t(@label_i18n)), eval(@path)), :class => (active? ? 'active' : nil)
end
end
2012-12-03 10:52:36 +00:00
protected
def display?
@available_for.each do |available_for_in_sym|
result = case available_for_in_sym
when :all
true
when :manager
2012-12-05 10:35:58 +00:00
@belong_module_app.is_manager? @current_user
2012-12-03 10:52:36 +00:00
when :sub_manager
2012-12-05 10:35:58 +00:00
@belong_module_app.is_sub_manager? @current_user
2012-12-03 10:52:36 +00:00
else
(eval(available_for_in_sym).include? @current_user rescue false)
end # of case
2012-12-07 04:40:47 +00:00
return true if result || (@current_user.admin? rescue false)
2012-12-03 10:52:36 +00:00
end # of collect
false
end
end