diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 46c71da5..1c7e1912 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,7 +3,7 @@ Changelog 0.5.9-dev +++++++++ - +- user group support for issue auto assign - optimize deface overwrite path 0.5.8 diff --git a/lib/redmine_tweaks/helpers/tweaks_helper.rb b/lib/redmine_tweaks/helpers/tweaks_helper.rb index 1ffdaa69..3ce4671b 100644 --- a/lib/redmine_tweaks/helpers/tweaks_helper.rb +++ b/lib/redmine_tweaks/helpers/tweaks_helper.rb @@ -61,47 +61,45 @@ module RedmineTweaks title: Setting.plugin_redmine_tweaks[menu_name + '_title'], roles: Setting.plugin_redmine_tweaks[menu_name + '_roles'] } + return if item[:name].blank? || item[:url].blank? || item[:roles].nil? - unless item[:name].blank? || item[:url].blank? || item[:roles].nil? - show_entry = false - item[:roles].each do |role| - if user_roles.empty? && role.to_i == Role::BUILTIN_ANONYMOUS - show_entry = true - break - elsif User.current.logged? && role.to_i == Role::BUILTIN_NON_MEMBER - # if user is logged in and non_member is active in item, - # always show it - show_entry = true - break - end - - user_roles.each do |user_role| - if role.to_i == user_role.id.to_i - show_entry = true - break - end - end - break if show_entry == true + show_entry = false + item[:roles].each do |role| + if user_roles.empty? && role.to_i == Role::BUILTIN_ANONYMOUS + show_entry = true + break + elsif User.current.logged? && role.to_i == Role::BUILTIN_NON_MEMBER + # if user is logged in and non_member is active in item, + # always show it + show_entry = true + break end - handle_top_menu_item(menu_name, item, show_entry) + + user_roles.each do |user_role| + if role.to_i == user_role.id.to_i + show_entry = true + break + end + end + break if show_entry == true end + handle_top_menu_item(menu_name, item, show_entry) end def handle_top_menu_item(menu_name, item, show_entry = false) if Redmine::MenuManager.map(:top_menu).exists?(menu_name.to_sym) Redmine::MenuManager.map(:top_menu).delete(menu_name.to_sym) end + return unless show_entry - if show_entry - html_options = {} - html_options[:class] = 'external' if item[:url].include? '://' - html_options[:title] = item[:title] unless item[:title].blank? - Redmine::MenuManager.map(:top_menu).push menu_name, - item[:url], - caption: item[:name].to_s, - html: html_options, - before: :help - end + html_options = {} + html_options[:class] = 'external' if item[:url].include? '://' + html_options[:title] = item[:title] unless item[:title].blank? + Redmine::MenuManager.map(:top_menu).push menu_name, + item[:url], + caption: item[:name].to_s, + html: html_options, + before: :help end def bootstrap_datepicker_locale