forked from GithubBackups/vichan
Don't show users boards they can't control
This commit is contained in:
parent
58ef0213d2
commit
6f0dc29d03
18
inc/bans.php
18
inc/bans.php
@ -154,13 +154,17 @@ class Bans {
|
|||||||
return $ban_list;
|
return $ban_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function list_all($offset = 0, $limit = 9001) {
|
static public function list_all($offset = 0, $limit = 9001, $board = false) {
|
||||||
$offset = (int)$offset;
|
$offset = (int)$offset;
|
||||||
$limit = (int)$limit;
|
$limit = (int)$limit;
|
||||||
|
|
||||||
$query = query("SELECT ``bans``.*, `username` FROM ``bans``
|
$query = prepare("SELECT ``bans``.*, `username` FROM ``bans``
|
||||||
LEFT JOIN ``mods`` ON ``mods``.`id` = `creator`
|
LEFT JOIN ``mods`` ON ``mods``.`id` = `creator`" . ($board ? ' WHERE ``bans``.`board` = :board' : '') . "
|
||||||
ORDER BY `created` DESC LIMIT $offset, $limit") or error(db_error());
|
ORDER BY `created` DESC LIMIT $offset, $limit");
|
||||||
|
if ($board)
|
||||||
|
$query->bindValue(':board', $board);
|
||||||
|
|
||||||
|
$query->execute() or error(db_error());
|
||||||
$bans = $query->fetchAll(PDO::FETCH_ASSOC);
|
$bans = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
foreach ($bans as &$ban) {
|
foreach ($bans as &$ban) {
|
||||||
@ -170,8 +174,10 @@ class Bans {
|
|||||||
return $bans;
|
return $bans;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function count() {
|
static public function count($board = false) {
|
||||||
$query = query("SELECT COUNT(*) FROM ``bans``") or error(db_error());
|
$query = prepare("SELECT COUNT(*) FROM ``bans`` WHERE `board` = :board");
|
||||||
|
$query->bindValue(':board', $board);
|
||||||
|
$query->execute() or error(db_error());
|
||||||
return (int)$query->fetchColumn();
|
return (int)$query->fetchColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,7 +866,7 @@ function mod_ban() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mod_bans($page_no = 1) {
|
function mod_bans($page_no = 1) {
|
||||||
global $config;
|
global $config, $mod;
|
||||||
|
|
||||||
if ($page_no < 1)
|
if ($page_no < 1)
|
||||||
error($config['error']['404']);
|
error($config['error']['404']);
|
||||||
@ -893,7 +893,9 @@ function mod_bans($page_no = 1) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$bans = Bans::list_all(($page_no - 1) * $config['mod']['banlist_page'], $config['mod']['banlist_page']);
|
$board = ($mod['boards'][0] == '*' ? false : $mod['boards'][0]);
|
||||||
|
|
||||||
|
$bans = Bans::list_all(($page_no - 1) * $config['mod']['banlist_page'], $config['mod']['banlist_page'], $board);
|
||||||
|
|
||||||
if (empty($bans) && $page_no > 1)
|
if (empty($bans) && $page_no > 1)
|
||||||
error($config['error']['404']);
|
error($config['error']['404']);
|
||||||
@ -905,7 +907,7 @@ function mod_bans($page_no = 1) {
|
|||||||
|
|
||||||
mod_page(_('Ban list'), 'mod/ban_list.html', array(
|
mod_page(_('Ban list'), 'mod/ban_list.html', array(
|
||||||
'bans' => $bans,
|
'bans' => $bans,
|
||||||
'count' => Bans::count(),
|
'count' => Bans::count($board),
|
||||||
'token' => make_secure_link_token('bans')
|
'token' => make_secure_link_token('bans')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -65,20 +65,24 @@
|
|||||||
<th>{% trans 'Board' %}</th>
|
<th>{% trans 'Board' %}</th>
|
||||||
<td>
|
<td>
|
||||||
<ul style="list-style:none;padding:2px 5px">
|
<ul style="list-style:none;padding:2px 5px">
|
||||||
|
{% if mod.boards[0] == '*' %}
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="board" value="*" id="ban-allboards" checked>
|
<input type="radio" name="board" value="*" id="ban-allboards" checked>
|
||||||
<label style="display:inline" for="ban-allboards">
|
<label style="display:inline" for="ban-allboards">
|
||||||
<em>{% trans 'all boards' %}</em>
|
<em>{% trans 'all boards' %}</em>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for board in boards %}
|
{% for board in boards %}
|
||||||
|
{% if board.uri in mod.boards or mod.boards[0] == '*' %}
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="board" value="{{ board.uri }}" id="ban-board-{{ board.uri }}">
|
<input type="radio" name="board" value="{{ board.uri }}" id="ban-board-{{ board.uri }}" {%if board.uri == mod.boards[0]%}checked{%endif%}>
|
||||||
<label style="display:inline" for="ban-board-{{ board.uri }}">
|
<label style="display:inline" for="ban-board-{{ board.uri }}">
|
||||||
{{ config.board_abbreviation|sprintf(board.uri) }} - {{ board.title|e }}
|
{{ config.board_abbreviation|sprintf(board.uri) }} - {{ board.title|e }}
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
{{ mod.type }}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{% trans 'Boards' %}</legend>
|
<legend>{% trans 'Boards' %}</legend>
|
||||||
|
|
||||||
@ -16,6 +17,10 @@
|
|||||||
{{ board.subtitle|e }}
|
{{ board.subtitle|e }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</small>
|
</small>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% if mod.type == "20" %}
|
||||||
|
<a href="?/settings/{{ board.uri }}"><small>[{% trans 'settings' %}]</small></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if mod|hasPermission(config.mod.manageboards) %}
|
{% if mod|hasPermission(config.mod.manageboards) %}
|
||||||
<a href="?/edit/{{ board.uri }}"><small>[{% trans 'edit' %}]</small></a>
|
<a href="?/edit/{{ board.uri }}"><small>[{% trans 'edit' %}]</small></a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user