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
- #current_menu(project) ⇒ Object
-
#current_menu_item ⇒ Object
Returns the menu item name according to the current action.
- #menu_items ⇒ Object
-
#redirect_to_menu_item(name) ⇒ Object
Redirects user to the menu item Returns false if user is not authorized.
-
#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.
Class Method Details
.included(base) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/redmine/menu_manager.rb', line 27 def self.included(base) base.class_attribute :main_menu base. = true base.extend(ClassMethods) end |
Instance Method Details
#current_menu(project) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/redmine/menu_manager.rb', line 60 def (project) if project && !project.new_record? :project_menu elsif self.class. :application_menu end end |
#current_menu_item ⇒ Object
Returns the menu item name according to the current action
69 70 71 72 |
# File 'lib/redmine/menu_manager.rb', line 69 def @current_menu_item ||= [controller_name.to_sym][:actions][action_name.to_sym] || [controller_name.to_sym][:default] end |
#menu_items ⇒ Object
56 57 58 |
# File 'lib/redmine/menu_manager.rb', line 56 def self.class. end |
#redirect_to_menu_item(name) ⇒ Object
Redirects user to the menu item Returns false if user is not authorized
76 77 78 |
# File 'lib/redmine/menu_manager.rb', line 76 def (name) (nil, name) 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
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/redmine/menu_manager.rb', line 82 def (project, name) = project.nil? ? :application_menu : :project_menu item = Redmine::MenuManager.items().detect {|i| i.name.to_s == name.to_s} if item && item.allowed?(User.current, project) url = item.url url = {item.param => project}.merge(url) if project redirect_to url return true end false end |