summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/menu_manager.rb6
-rw-r--r--lib/redmine/plugin.rb10
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/redmine/menu_manager.rb b/lib/redmine/menu_manager.rb
index f6431928e..730097d74 100644
--- a/lib/redmine/menu_manager.rb
+++ b/lib/redmine/menu_manager.rb
@@ -94,7 +94,11 @@ module Redmine
def map(menu_name)
@items ||= {}
mapper = Mapper.new(menu_name.to_sym, @items)
- yield mapper
+ if block_given?
+ yield mapper
+ else
+ mapper
+ end
end
def items(menu_name)
diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb
index cf6c194a2..8123003cc 100644
--- a/lib/redmine/plugin.rb
+++ b/lib/redmine/plugin.rb
@@ -70,8 +70,14 @@ module Redmine #:nodoc:
#
# +name+ parameter can be: :top_menu, :account_menu, :application_menu or :project_menu
#
- def menu(name, item, url, options={})
- Redmine::MenuManager.map(name) {|menu| menu.push item, url, options}
+ def menu(menu, item, url, options={})
+ Redmine::MenuManager.map(menu).push(item, url, options)
+ end
+ alias :add_menu_item :menu
+
+ # Removes +item+ from the given +menu+.
+ def delete_menu_item(menu, item)
+ Redmine::MenuManager.map(menu).delete(item)
end
# Defines a permission called +name+ for the given +actions+.