diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-10-25 09:55:31 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-10-25 09:55:31 +0000 |
commit | 5f9f6ea2e1736ba6fbdde65d878d09728b1f309b (patch) | |
tree | e42c066902754351af40d02e486d8866e522f826 | |
parent | 738fc579f0dc95aad9ab0dedc65fbce7af0bb980 (diff) | |
download | redmine-5f9f6ea2e1736ba6fbdde65d878d09728b1f309b.tar.gz redmine-5f9f6ea2e1736ba6fbdde65d878d09728b1f309b.zip |
Adds #delete_menu_item to the plugin API (#2087).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1952 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | lib/redmine/menu_manager.rb | 6 | ||||
-rw-r--r-- | lib/redmine/plugin.rb | 10 |
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+. |