<% provide :title, t('.title') %>
<div class="section">
  <h6><%=t :user_blocked %></h6>
  <%= form_tag(:action => "unblock") do %>
    <table width="100%" class="highlightable">
      <thead>
        <tr>
          <th width="1%"></th>
          <th width="19%"><%=t :user_user %></th>
          <th width="10%"><%=t :user_expires %></th>
          <th width="15%"><%=t :user_when %></th>
          <th width="60%"><%=t :user_reason %></th>
        </tr>
      </thead>
      <tfoot>
        <tr>
          <td colspan="4"><%= submit_tag t(:user_unblock) %></td>
        </tr>
      </tfoot>
      <tbody>
        <% @users.each do |user| %>
          <tr class="<%= cycle 'even', 'odd' %>">
            <td><%= check_box_tag "user[#{user.id}]" %></td>
            <td><%= link_to h(user.pretty_name), :controller => "user", :action => "show", :id => user.id %></td>
            <td><%= time_ago_in_words(user.ban.expires_at) %></td>
            <td><%= user.ban.expires_at %></td>
            <td><%= h user.ban.reason %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  <% end %>

  <h6><%=t :user_blocked_ips %></h6>
  <%= form_tag(:controller => "blocks", :action => "unblock_ip") do %>
    <table width="100%" class="highlightable">
      <thead>
        <tr>
          <th width="1%"></th>
          <th width="19%"><%=t :user_ip %></th>
          <th width="10%"><%=t :user_expires %></th>
          <th width="10%"><%=t :user_banned_by %></th>
          <th width="60%"><%=t :user_reason %></th>
        </tr>
      </thead>
      <tfoot>
        <tr>
          <td colspan="4"><%= submit_tag t(:user_unblock) %></td>
        </tr>
      </tfoot>
      <tbody>
        <% @ip_bans.each do |ban| %>
          <tr class="<%= cycle 'even', 'odd' %>">
            <td><%= check_box_tag "ip_ban[#{ban.id}]" %></td>
            <td><%= h ban.ip_addr %></td>
            <td><%= if ban.expires_at then time_ago_in_words(ban.expires_at) else "never" end %></td>
            <td><%= link_to h(ban.user.pretty_name), :controller => "user", :action => "show", :id => ban.user.id %></td>
            <td><%= h ban.reason %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  <% end %>
  <%= form_tag(:controller => "blocks", :action => "block_ip") do %>
    <table class="form">
      <tfoot>
        <tr>
          <td></td>
          <td><%= submit_tag t(:user_resend_submit) %></td>
        </tr>
      </tfoot>
      <tbody>
        <tr>
          <th><label for="ip_addr"><%=t :user_address %></label>
            <p><%=t :user_address_text %></p></th>
          <td><%= text_field "ban", "ip_addr", :size => "40" %></td>
        </tr>
        <tr>
          <th><label for="ban_reason"><%=t :user_reason %></label></th>
          <td><%= text_area "ban", "reason", :size => "40x5" %></td>
        </tr>
        <tr>
          <th>
            <label for="ban_duration"><%=t :user_duration %></label>
          </th>
          <td><%= text_field "ban", "duration", :size => 10 %></td>
        </tr>
      </tbody>
    </table>
  <% end %>
</div>

<%= render :partial => "footer" %>
