Module: Redmine::MenuManager::MenuController

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

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



16
17
18
# File 'lib/redmine/menu_manager/menu_controller.rb', line 16

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

Instance Method Details

#current_menu_itemObject

Returns the menu item name according to the current action



47
48
49
50
# File 'lib/redmine/menu_manager/menu_controller.rb', line 47

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


42
43
44
# File 'lib/redmine/menu_manager/menu_controller.rb', line 42

def menu_items
  self.class.menu_items
end

#redirect_to_project_menu_item(project, name) ⇒ Object

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



54
55
56
57
58
59
60
61
# File 'lib/redmine/menu_manager/menu_controller.rb', line 54

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