3 UserRole::ALL_ROLES.reduce("".html_safe) { |a, e| a + " " + role_icon(user, e) }
6 def role_icon(user, role)
7 if @user && @user.administrator?
8 if user.has_role?(role)
9 image = "roles/#{role}.png"
10 alt = t("user.view.role.revoke.#{role}")
11 title = t("user.view.role.revoke.#{role}")
12 url = revoke_role_path(:display_name => user.display_name, :role => role)
13 confirm = t("user_role.revoke.are_you_sure", :name => user.display_name, :role => role)
15 image = "roles/blank_#{role}.png"
16 alt = t("user.view.role.grant.#{role}")
17 title = t("user.view.role.grant.#{role}")
18 url = grant_role_path(:display_name => user.display_name, :role => role)
19 confirm = t("user_role.grant.are_you_sure", :name => user.display_name, :role => role)
21 elsif user.has_role?(role)
22 image = "roles/#{role}.png"
23 alt = t("user.view.role.#{role}")
24 title = t("user.view.role.#{role}")
28 icon = image_tag(image, :size => "20x20", :border => 0, :alt => alt, :title => title)
29 icon = link_to(icon, url, :method => :post, :confirm => confirm) if url