<% title "Forums" %>
<% @groups.each do |group| %>
<%= group.name %> <%= link_to "edit", edit_forumgroup_path(group), class: "editlink" if admin? %>
<% group.forums.sort_by{ |f| f.position || 0 }.each do |f| %> <% if f.can_read?(current_user) %>
<%= link_to f.name, f, id: "forum-#{f.id}"%>
<% if last_thread = f.threads.last %> <% last_reply = Threadreply.where(forumthread: f.threads).order(:created_at).last %> <% if last_reply && last_reply.created_at > last_thread.created_at %> <%= last_reply.author.name %> <%= link_to "replied", forumthread_path(last_reply.thread) + "#reply-#{last_reply.id}" %> . <% else %> <%= last_thread.author.name %> <%= link_to "posted", forumthread_path(last_thread) %> . <% end %> <% else %> No posts yet. <% end %>
<% end %> <% end %>
<% end %>
<% if admin? %> <%= link_to "New group", new_forumgroup_path, class: "btn blue" %> <% elsif mod? %> <%= link_to "New group", "#", class: "btn blue", disabled: true %> <% end %>