comparison lib/redmine/menu_manager.rb @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents 433d4f72a19b
children
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
188 return [caption, url, (current_menu_item == item.name)] 188 return [caption, url, (current_menu_item == item.name)]
189 end 189 end
190 190
191 # Checks if a user is allowed to access the menu item by: 191 # Checks if a user is allowed to access the menu item by:
192 # 192 #
193 # * Checking the url target (project only)
193 # * Checking the conditions of the item 194 # * Checking the conditions of the item
194 # * Checking the url target (project only)
195 def allowed_node?(node, user, project) 195 def allowed_node?(node, user, project)
196 if project && user && !user.allowed_to?(node.url, project)
197 return false
198 end
196 if node.condition && !node.condition.call(project) 199 if node.condition && !node.condition.call(project)
197 # Condition that doesn't pass 200 # Condition that doesn't pass
198 return false 201 return false
199 end 202 end
200 203 return true
201 if project
202 return user && user.allowed_to?(node.url, project)
203 else
204 # outside a project, all menu items allowed
205 return true
206 end
207 end 204 end
208 end 205 end
209 206
210 class << self 207 class << self
211 def map(menu_name) 208 def map(menu_name)