Noosfero/noosfero

View on GitHub
plugins/community_block/views/blocks/community.html.erb

Summary

Maintainability
Test Coverage
<div class="community-block">
  <div class="community-block-logo">
    <%= link_to profile_image(profile, :big), profile.url %>
  </div>
  <div class="community-block-info">
    <div class="community-block-title">

      <%
        links = []

        if logged_in?

          if profile.enable_contact?
            links.push(c_('Send an e-mail') => {:href => url_for({:controller => 'contact', :action => 'new', :profile => profile.identifier})})
          end

          links.push(c_('Report abuse') => {:href => url_for({:controller => 'profile', :action => 'report_abuse', :profile => profile.identifier})})

          if !user.nil? && user.has_permission?('edit_profile', profile)
            links.push(c_('Control panel') => {:href => url_for({:controller => 'profile_editor', :profile => profile.identifier})})
          end %>

      <%= link_to(
            content_tag('span','',:class => 'community-block-button icon-arrow'),
            '#',
            :onclick => "toggleSubmenu(this,'',#{CGI::escapeHTML(links.to_json)}); return false;".html_safe,
            :class => 'simplemenu-trigger') %>

      <% end %>

      <% if logged_in? %>
        <% if profile.members.include?(user) || profile.already_request_membership?(user) %>
            <%= link_to(
                  content_tag('span', '', :class => 'community-block-button icon-remove'),
                  profile.leave_url, :class => 'join-community') %>
        <% else %>
            <%= link_to(
                  content_tag('span', '', :class => 'community-block-button icon-add'),
                  profile.join_url, :class => 'join-community') %>
        <% end %>
      <% else %>
        <%= link_to(
              content_tag('span', '', :class => 'community-block-button icon-add'),
              profile.join_not_logged_url) %>
      <% end %>

      <h1><%=profile.name%></h1>
    </div>
    <div class="community-block-description"><%= profile.description %></div>
  </div>
  <div style="clear:both"></div>
</div>