Module: Redmine::MenuManager::MenuController

Included in:
ApplicationController
Defined in:
lib/redmine/menu_manager.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(base)



110
111
112
# File 'lib/redmine/menu_manager.rb', line 110

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

- (Object) current_menu_item

Returns the menu item name according to the current action



141
142
143
144
# File 'lib/redmine/menu_manager.rb', line 141

def current_menu_item
  @current_menu_item ||= menu_items[controller_name.to_sym][:actions][action_name.to_sym] ||
                           menu_items[controller_name.to_sym][:default]
end


136
137
138
# File 'lib/redmine/menu_manager.rb', line 136

def menu_items
  self.class.menu_items
end

- (Object) redirect_to_project_menu_item(project, name)

Redirects user to the menu item of the given project Returns false if user is not authorized



148
149
150
151
152
153
154
155
# File 'lib/redmine/menu_manager.rb', line 148

def redirect_to_project_menu_item(project, name)
  item = Redmine::MenuManager.items(:project_menu).detect {|i| i.name.to_s == name.to_s}
  if item && User.current.allowed_to?(item.url, project) && (item.condition.nil? || item.condition.call(project))
    redirect_to({item.param => project}.merge(item.url))
    return true
  end
  false
end