summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-12-30 14:24:51 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-12-30 14:24:51 +0000
commit2355324d73e26f224e2b13b21249f181314b289f (patch)
tree82df3a96b4376a927ae04b48b29393bd46d56a27 /lib
parent6eee9dbf88de71b28cc78f3b4003f54f04795e04 (diff)
downloadredmine-2355324d73e26f224e2b13b21249f181314b289f.tar.gz
redmine-2355324d73e26f224e2b13b21249f181314b289f.zip
Jump to the current tab when using the project quick-jump combo (#2364).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2210 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/menu_manager.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/redmine/menu_manager.rb b/lib/redmine/menu_manager.rb
index f8fc5dd8d..7a89a32b9 100644
--- a/lib/redmine/menu_manager.rb
+++ b/lib/redmine/menu_manager.rb
@@ -52,8 +52,19 @@ module Redmine
# Returns the menu item name according to the current action
def current_menu_item
- menu_items[controller_name.to_sym][:actions][action_name.to_sym] ||
- menu_items[controller_name.to_sym][:default]
+ @current_menu_item ||= menu_items[controller_name.to_sym][:actions][action_name.to_sym] ||
+ menu_items[controller_name.to_sym][:default]
+ end
+
+ # Redirects user to the menu item of the given project
+ # Returns false if user is not authorized
+ 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
end