module RForum # Navbar is the application's "main menu" displayed somewhere in the layout class NavigationBar include RForum::Localization Item = Struct.new(:prompt, :target, :confirmation_message) def initialize(forum, user) @forum, @user = forum, user end def forums_list Item.new(l(:nav_forum_list), {:controller => 'forum', :action => 'list'}) end def new_topic if @forum and @user.can_post? Item.new(l(:nav_create_topic), {:controller => 'topic', :action => 'new', :params => {'forum_id' => @forum.id}}) else nil end end def search if RForum::CONFIG[:search] != :disabled Item.new(l(:nav_search), {:controller => 'forum', :action => 'search'}) end end # With Hub, we expect the templates to not offer direct links for # logging in and out; they don't in other applications so it would # look rather inconsistent. However, should someone want to use # these functions they should at least do something sane. def user_settings Item.new(@user.guest? ? l(:nav_register) : l(:nav_settings), '/hub/tasks') end def user_list if (@user.admin?) Item.new(l(:nav_user_list), '/hub/account/list') end end def login_info if @user.guest? Item.new(l(:nav_log_in), '/hub/account/login_hop') else link_text = l(:nav_log_out, @user.firstname) # Actually the Hub unique name link_text << " (#{@user.role})" unless @user.class == User Item.new(link_text, '/hub/account/logout') end end end # class NavBar end