Browse Source

Fix search for new bans table

pull/40/head
Michael Foster 11 years ago
parent
commit
803f0c8ce1
  1. 7
      inc/mod/pages.php
  2. 2
      templates/mod/ban_list.html
  3. 14
      templates/mod/search_results.html

7
inc/mod/pages.php

@ -289,7 +289,7 @@ function mod_search($type, $search_query_escaped, $page_no = 1) {
} }
if ($type == 'bans') { if ($type == 'bans') {
$query = 'SELECT ``bans``.*, `username` FROM ``bans`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE ' . $sql_like . ' ORDER BY (`expires` IS NOT NULL AND `expires` < UNIX_TIMESTAMP()), `created` DESC'; $query = 'SELECT ``bans``.*, `username` FROM ``bans`` LEFT JOIN ``mods`` ON `creator` = ``mods``.`id` WHERE ' . $sql_like . ' ORDER BY (`expires` IS NOT NULL AND `expires` < UNIX_TIMESTAMP()), `created` DESC';
$sql_table = 'bans'; $sql_table = 'bans';
if (!hasPermission($config['mod']['view_banlist'])) if (!hasPermission($config['mod']['view_banlist']))
error($config['error']['noaccess']); error($config['error']['noaccess']);
@ -317,8 +317,9 @@ function mod_search($type, $search_query_escaped, $page_no = 1) {
if ($type == 'bans') { if ($type == 'bans') {
foreach ($results as &$ban) { foreach ($results as &$ban) {
if (filter_var($ban['ip'], FILTER_VALIDATE_IP) !== false) $ban['mask'] = Bans::range_to_string(array($ban['ipstart'], $ban['ipend']));
$ban['real_ip'] = true; if (filter_var($ban['mask'], FILTER_VALIDATE_IP) !== false)
$ban['single_addr'] = true;
} }
} }

2
templates/mod/ban_list.html

@ -46,7 +46,7 @@
{% if ban.expires == 0 %} {% if ban.expires == 0 %}
- -
{% else %} {% else %}
{{ (ban.expires - ban.set + time()) | until }} {{ (ban.expires - ban.created + time()) | until }}
{% endif %} {% endif %}
</td> </td>
<td style="white-space: nowrap"> <td style="white-space: nowrap">

14
templates/mod/search_results.html

@ -56,10 +56,10 @@
{% for ban in results %} {% for ban in results %}
<tr{% if ban.expires != 0 and ban.expires < time() %} style="text-decoration:line-through"{% endif %}> <tr{% if ban.expires != 0 and ban.expires < time() %} style="text-decoration:line-through"{% endif %}>
<td style="white-space: nowrap"> <td style="white-space: nowrap">
{% if ban.real_ip %} {% if ban.single_addr %}
<a href="?/IP/{{ ban.ip }}#bans">{{ ban.ip }}</a> <a href="?/IP/{{ ban.mask }}#bans">{{ ban.mask }}</a>
{% else %} {% else %}
{{ ban.ip|e }} {{ ban.mask|e }}
{% endif %} {% endif %}
</td> </td>
<td> <td>
@ -77,15 +77,15 @@
{% endif %} {% endif %}
</td> </td>
<td style="white-space: nowrap"> <td style="white-space: nowrap">
<span title="{{ ban.set|date(config.post_date) }}"> <span title="{{ ban.created|date(config.post_date) }}">
{{ ban.set|ago }} ago {{ ban.created|ago }} ago
</span> </span>
</td> </td>
<td style="white-space: nowrap"> <td style="white-space: nowrap">
{% if ban.expires == 0 %} {% if ban.expires == 0 %}
- -
{% else %} {% else %}
{{ (ban.expires - ban.set + time()) | until }} {{ (ban.expires - ban.created + time()) | until }}
{% endif %} {% endif %}
</td> </td>
<td style="white-space: nowrap"> <td style="white-space: nowrap">
@ -116,7 +116,7 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
{% elseif ban.mod == -1 %} {% elseif ban.creator == -1 %}
<em>system</em> <em>system</em>
{% else %} {% else %}
<em>{% trans 'deleted?' %}</em> <em>{% trans 'deleted?' %}</em>

Loading…
Cancel
Save