Commit aa29773ad8a694b37239da948a7b92af409ea53e
1 parent
8175d7fb
Exists in
master
and in
27 other branches
Not display administration link to common users
ActionItem3173
Showing
2 changed files
with
27 additions
and
7 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -1104,14 +1104,18 @@ module ApplicationHelper | @@ -1104,14 +1104,18 @@ module ApplicationHelper | ||
1104 | end | 1104 | end |
1105 | 1105 | ||
1106 | def manage_enterprises | 1106 | def manage_enterprises |
1107 | - return unless user && user.environment.enabled?(:display_my_enterprises_on_user_menu) | ||
1108 | - manage_link(user.enterprises, :enterprises) | 1107 | + return '' unless user && user.environment.enabled?(:display_my_enterprises_on_user_menu) |
1108 | + manage_link(user.enterprises, :enterprises).to_s | ||
1109 | end | 1109 | end |
1110 | 1110 | ||
1111 | def manage_communities | 1111 | def manage_communities |
1112 | - return unless user && user.environment.enabled?(:display_my_communities_on_user_menu) | 1112 | + return '' unless user && user.environment.enabled?(:display_my_communities_on_user_menu) |
1113 | administered_communities = user.communities.more_popular.select {|c| c.admins.include? user} | 1113 | administered_communities = user.communities.more_popular.select {|c| c.admins.include? user} |
1114 | - manage_link(administered_communities, :communities) | 1114 | + manage_link(administered_communities, :communities).to_s |
1115 | + end | ||
1116 | + | ||
1117 | + def admin_link | ||
1118 | + user.is_admin?(environment) ? link_to('<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>', environment.admin_url, :title => _("Configure the environment"), :class => 'admin-link') : '' | ||
1115 | end | 1119 | end |
1116 | 1120 | ||
1117 | def usermenu_logged_in | 1121 | def usermenu_logged_in |
@@ -1123,9 +1127,9 @@ module ApplicationHelper | @@ -1123,9 +1127,9 @@ module ApplicationHelper | ||
1123 | 1127 | ||
1124 | (_("<span class='welcome'>Welcome,</span> %s") % link_to("<i style='background-image:url(#{user.profile_custom_icon(gravatar_default)})'></i><strong>#{user.identifier}</strong>", user.public_profile_url, :id => "homepage-link", :title => _('Go to your homepage'))) + | 1128 | (_("<span class='welcome'>Welcome,</span> %s") % link_to("<i style='background-image:url(#{user.profile_custom_icon(gravatar_default)})'></i><strong>#{user.identifier}</strong>", user.public_profile_url, :id => "homepage-link", :title => _('Go to your homepage'))) + |
1125 | render_environment_features(:usermenu) + | 1129 | render_environment_features(:usermenu) + |
1126 | - link_to('<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>', @environment.admin_url, :title => _("Configure the environment"), :class => 'admin-link') + | ||
1127 | - manage_enterprises.to_s + | ||
1128 | - manage_communities.to_s + | 1130 | + admin_link + |
1131 | + manage_enterprises + | ||
1132 | + manage_communities + | ||
1129 | link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', user.admin_url, :class => 'ctrl-panel', :title => _("Configure your personal account and content")) + | 1133 | link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', user.admin_url, :class => 'ctrl-panel', :title => _("Configure your personal account and content")) + |
1130 | pending_tasks_count + | 1134 | pending_tasks_count + |
1131 | link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system")) | 1135 | link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system")) |
test/unit/application_helper_test.rb
@@ -606,6 +606,22 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -606,6 +606,22 @@ class ApplicationHelperTest < ActionView::TestCase | ||
606 | assert_equal 'Open chat', render_environment_features(:usermenu) | 606 | assert_equal 'Open chat', render_environment_features(:usermenu) |
607 | end | 607 | end |
608 | 608 | ||
609 | + should 'not inlude administration link if user is not an environment administrator' do | ||
610 | + user = mock() | ||
611 | + stubs(:environment).returns(Environment.default) | ||
612 | + user.stubs(:is_admin?).with(environment).returns(false) | ||
613 | + stubs(:user).returns(user) | ||
614 | + assert admin_link.blank? | ||
615 | + end | ||
616 | + | ||
617 | + should 'inlude administration link if user is an environment administrator' do | ||
618 | + user = mock() | ||
619 | + stubs(:environment).returns(Environment.default) | ||
620 | + user.stubs(:is_admin?).with(environment).returns(true) | ||
621 | + stubs(:user).returns(user) | ||
622 | + assert admin_link.present? | ||
623 | + end | ||
624 | + | ||
609 | should 'not return mime type of profile icon if not requested' do | 625 | should 'not return mime type of profile icon if not requested' do |
610 | stubs(:profile).returns(Person.new) | 626 | stubs(:profile).returns(Person.new) |
611 | stubs(:current_theme).returns('default') | 627 | stubs(:current_theme).returns('default') |