mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-29 01:34:31 +01:00
Global reports function
This commit is contained in:
parent
14e7c44a94
commit
f456f86a87
@ -100,13 +100,18 @@ function mod_dashboard() {
|
||||
cache::set('pm_unreadcount_' . $mod['id'], $args['unread_pms']);
|
||||
}
|
||||
|
||||
$query = prepare('SELECT COUNT(*) FROM ``reports``' . ($mod["type"] == "20" ? "WHERE board = :board" : ""));
|
||||
$query = prepare('SELECT COUNT(*) AS `total_reports` FROM ``reports``' . ($mod["type"] == "20" ? " WHERE board = :board" : ""));
|
||||
|
||||
if ($mod['type'] == '20')
|
||||
if ($mod['type'] == '20') {
|
||||
$query->bindValue(':board', $mod['boards'][0]);
|
||||
} else {
|
||||
$query = prepare('SELECT (SELECT COUNT(id) FROM reports WHERE global = 0) AS total_reports, (SELECT COUNT(id) FROM reports WHERE global = 1) AS global_reports');
|
||||
}
|
||||
|
||||
$query->execute() or error(db_error($query));
|
||||
$args['reports'] = $query->fetchColumn();
|
||||
$row = $query->fetch();
|
||||
$args['reports'] = $row['total_reports'];
|
||||
$args['global_reports'] = isset($row['global_reports']) ? $row['global_reports'] : false;
|
||||
|
||||
if ($mod['type'] >= ADMIN && $config['check_updates']) {
|
||||
if (!$config['version'])
|
||||
@ -1995,18 +2000,26 @@ function mod_rebuild() {
|
||||
));
|
||||
}
|
||||
|
||||
function mod_reports() {
|
||||
function mod_reports($global = false) {
|
||||
global $config, $mod;
|
||||
|
||||
if (!hasPermission($config['mod']['reports']))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
$query = prepare("SELECT * FROM ``reports`` " . ($mod["type"] == "20" ? "WHERE board = :board" : "") . " ORDER BY `time` DESC LIMIT :limit");
|
||||
$query->bindValue(':limit', $config['mod']['recent_reports'], PDO::PARAM_INT);
|
||||
if ($mod['type'] == '20' and $global)
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
$query = prepare("SELECT * FROM ``reports`` " . ($mod["type"] == "20" ? "WHERE board = :board" : "") . " ORDER BY `time` DESC LIMIT :limit");
|
||||
if ($mod['type'] == '20')
|
||||
$query->bindValue(':board', $mod['boards'][0]);
|
||||
|
||||
if ($global) {
|
||||
$query = prepare("SELECT * FROM ``reports`` WHERE global = TRUE ORDER BY `time` DESC LIMIT :limit");
|
||||
}
|
||||
|
||||
$query->bindValue(':limit', $config['mod']['recent_reports'], PDO::PARAM_INT);
|
||||
|
||||
|
||||
$query->execute() or error(db_error($query));
|
||||
$reports = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
|
1
mod.php
1
mod.php
@ -55,6 +55,7 @@ $pages = array(
|
||||
|
||||
'/rebuild' => 'secure_POST rebuild', // rebuild static files
|
||||
'/reports' => 'reports', // report queue
|
||||
'/reports/(global)' => 'reports', // global report queue
|
||||
'/reports/(\d+)/dismiss(all)?' => 'secure report_dismiss', // dismiss a report
|
||||
|
||||
'/IP/([\w.:]+)' => 'secure_POST ip', // view ip address
|
||||
|
3
post.php
3
post.php
@ -128,12 +128,13 @@ if (isset($_POST['delete'])) {
|
||||
'/' . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $thread ? $thread : $id) . ($thread ? '#' . $id : '') .
|
||||
' for "' . $reason . '"'
|
||||
);
|
||||
$query = prepare("INSERT INTO ``reports`` VALUES (NULL, :time, :ip, :board, :post, :reason)");
|
||||
$query = prepare("INSERT INTO ``reports`` VALUES (NULL, :time, :ip, :board, :post, :reason, :global)");
|
||||
$query->bindValue(':time', time(), PDO::PARAM_INT);
|
||||
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR);
|
||||
$query->bindValue(':board', $board['uri'], PDO::PARAM_INT);
|
||||
$query->bindValue(':post', $id, PDO::PARAM_INT);
|
||||
$query->bindValue(':reason', $reason, PDO::PARAM_STR);
|
||||
$query->bindValue(':global', isset($_POST['global']), PDO::PARAM_BOOL);
|
||||
$query->execute() or error(db_error($query));
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,12 @@
|
||||
<li>
|
||||
{% if reports > 0 %}<strong>{% endif %}
|
||||
<a href="?/reports">{% trans 'Report queue' %} ({{ reports }})</a>
|
||||
{% if reports > 0 %}</strong>{% endif %}
|
||||
{% if global_reports > 0 %}<strong>{% endif %}
|
||||
{% if mod.type != 20 %}<a href="?/reports/global">Global reports ({{global_reports}})</a>{% endif %}
|
||||
{% if reports > 0 %}</strong>{% endif %}
|
||||
</li>
|
||||
|
||||
{% endif %}
|
||||
{% if mod|hasPermission(config.mod.view_banlist) %}
|
||||
<li><a href="?/bans">{% trans 'Ban list' %}</a></li>
|
||||
|
@ -7,5 +7,6 @@
|
||||
<div class="delete" style="clear:both">
|
||||
<label for="reason">{% trans %}Reason{% endtrans %}</label>
|
||||
<input id="reason" type="text" name="reason" size="20" maxlength="30" />
|
||||
[<input title="Delete file only" type="checkbox" name="global" id="global_report" /><label for="global_report" title="Report rule violation (CP, etc) to global staff">{% trans %}Global{% endtrans %}</label>]
|
||||
<input type="submit" name="report" value="{% trans %}Report{% endtrans %}" />
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user