<% title "Forums" %> <%= link_to "Search All Threads", forumthreads_path, class: "btn blue right" %>
<% @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_view?(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(:id).last %> <% if last_reply && last_reply.created_at > last_thread.created_at %> <% if last_reply.thread.can_read?(current_user) %> <%= last_reply.author.name %> <% position = last_reply.thread.replies.count - 1 page = position / Kaminari.config.default_per_page + 1 %> <%= link_to "replied", forumthread_path(last_reply.thread, page: page) + "#reply-#{last_reply.id}" %> <%= ago last_reply.created_at %>. <% else %> Hidden <% end %> <% else %> <% if last_thread.can_read?(current_user) %> <%= last_thread.author.name %> <%= link_to "posted", forumthread_path(last_thread) %> <%= ago last_thread.created_at %>. <% else %> Hidden <% end %> <% 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 %>