]> source.dussan.org Git - redmine.git/commitdiff
Adds #delete_menu_item to the plugin API (#2087).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 25 Oct 2008 09:55:31 +0000 (09:55 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 25 Oct 2008 09:55:31 +0000 (09:55 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1952 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/menu_manager.rb
lib/redmine/plugin.rb

index f6431928ef1ed3eb11e2ea0e8a2f0e63841a75d9..730097d745692fe5ad7e451e4bb703d308de8f6c 100644 (file)
@@ -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)
index cf6c194a268cc88ae6e8dc52df31cd95506e6ed9..8123003cc463a98cdfebcb6fdb9537a07a3f0bfa 100644 (file)
@@ -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+.