mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-28 17:31:00 +01:00
[#184] Added Promote and Demote to reports. CSS improvements.
This commit is contained in:
parent
e90eca7339
commit
a8a843bf4b
@ -1388,6 +1388,10 @@
|
||||
$config['mod']['reports'] = JANITOR;
|
||||
// Dismiss an abuse report
|
||||
$config['mod']['report_dismiss'] = JANITOR;
|
||||
// Remove global status from a report
|
||||
$config['mod']['report_demote'] = JANITOR;
|
||||
// Elevate a global report to a local report.
|
||||
$config['mod']['report_promote'] = JANITOR;
|
||||
// Dismiss all abuse reports by an IP
|
||||
$config['mod']['report_dismiss_ip'] = JANITOR;
|
||||
// View list of bans
|
||||
|
@ -2266,16 +2266,18 @@ function mod_reports($global = false) {
|
||||
if ($mod['type'] == '20' and $global)
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
// Get REPORTS.
|
||||
$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");
|
||||
}
|
||||
// Limit reports to ONLY those in our scope.
|
||||
$report_scope = $global ? "global" : "local";
|
||||
|
||||
$query->bindValue(':limit', $config['mod']['recent_reports'], PDO::PARAM_INT);
|
||||
// Get REPORTS.
|
||||
$query = prepare("SELECT * FROM ``reports`` " . ($mod["type"] == "20" ? "WHERE board = :board" : "") . " WHERE ``{$report_scope}``=TRUE LIMIT :limit");
|
||||
|
||||
// Limit reports by board if the moderator is local.
|
||||
if( $mod['type'] == '20' )
|
||||
$query->bindValue(':board', $mod['boards'][0]);
|
||||
|
||||
// Limit by config ceiling.
|
||||
$query->bindValue( ':limit', $config['mod']['recent_reports'], PDO::PARAM_INT );
|
||||
|
||||
$query->execute() or error(db_error($query));
|
||||
$reports = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
@ -2380,11 +2382,14 @@ function mod_reports($global = false) {
|
||||
$content_reports = 0;
|
||||
foreach( $report_item['reports'] as $report ) {
|
||||
$report_html .= Element('mod/report.html', array(
|
||||
'report' => $report,
|
||||
'config' => $config,
|
||||
'mod' => $mod,
|
||||
'token' => make_secure_link_token('reports/' . $report['id'] . '/dismiss'),
|
||||
'token_all' => make_secure_link_token('reports/' . $report['id'] . '/dismissall')
|
||||
'report' => $report,
|
||||
'config' => $config,
|
||||
'mod' => $mod,
|
||||
'global' => $global,
|
||||
'token_dismiss' => make_secure_link_token('reports/' . $report['id'] . '/dismiss'),
|
||||
'token_ip' => make_secure_link_token('reports/' . $report['id'] . '/dismissall'),
|
||||
'token_demote' => make_secure_link_token('reports/' . $report['id'] . '/demote'),
|
||||
'token_promote' => make_secure_link_token('reports/' . $report['id'] . '/promote'),
|
||||
));
|
||||
|
||||
++$content_reports;
|
||||
@ -2464,6 +2469,64 @@ function mod_report_dismiss($id, $all = false) {
|
||||
header('Location: ?/reports', true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
function mod_report_demote($id) {
|
||||
global $config;
|
||||
|
||||
$query = prepare("SELECT `post`, `board`, `ip` FROM ``reports`` WHERE `id` = :id AND ``global`` = TRUE");
|
||||
$query->bindValue(':id', $id);
|
||||
$query->execute() or error(db_error($query));
|
||||
if ($report = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$ip = $report['ip'];
|
||||
$board = $report['board'];
|
||||
$post = $report['post'];
|
||||
}
|
||||
else {
|
||||
error($config['error']['404']);
|
||||
}
|
||||
|
||||
if( !hasPermission($config['mod']['report_demote'], $board) ) {
|
||||
error($config['error']['noaccess']);
|
||||
}
|
||||
|
||||
$query = prepare("UPDATE ``reports`` SET ``global`` = FALSE WHERE `id` = :id");
|
||||
$query->bindValue(':id', $id);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
|
||||
modLog("Demoted a global report for post #{$id}", $board);
|
||||
|
||||
header('Location: ?/reports', true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
function mod_report_promote($id) {
|
||||
global $config;
|
||||
|
||||
$query = prepare("SELECT `post`, `board`, `ip` FROM ``reports`` WHERE `id` = :id AND ``global`` = FALSE");
|
||||
$query->bindValue(':id', $id);
|
||||
$query->execute() or error(db_error($query));
|
||||
if ($report = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$ip = $report['ip'];
|
||||
$board = $report['board'];
|
||||
$post = $report['post'];
|
||||
}
|
||||
else {
|
||||
error($config['error']['404']);
|
||||
}
|
||||
|
||||
if( !hasPermission($config['mod']['report_promote'], $board) ) {
|
||||
error($config['error']['noaccess']);
|
||||
}
|
||||
|
||||
$query = prepare("UPDATE ``reports`` SET ``global`` = TRUE WHERE `id` = :id");
|
||||
$query->bindValue(':id', $id);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
|
||||
modLog("Promoted a local report for post #{$id}", $board);
|
||||
|
||||
header('Location: ?/reports', true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
function mod_recent_posts($lim) {
|
||||
global $config, $mod, $pdo;
|
||||
|
||||
|
10
mod.php
10
mod.php
@ -53,10 +53,12 @@ $pages = array(
|
||||
'/edit/(\%b)' => 'secure_POST edit_board', // edit board details
|
||||
'/new-board' => 'secure_POST new_board', // create a new board
|
||||
|
||||
'/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
|
||||
'/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
|
||||
'/reports/(\d+)/demote?' => 'secure report_demote', // demote a global report to a local report
|
||||
'/reports/(\d+)/promote?' => 'secure report_promote', // promote a local report to a global report
|
||||
|
||||
'/IP/([\w.:]+)' => 'secure_POST ip', // view ip address
|
||||
'/IP/([\w.:]+)/remove_note/(\d+)' => 'secure ip_remove_note', // remove note from ip address
|
||||
|
@ -16,6 +16,10 @@
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.report-header {
|
||||
margin: 0 0 0.25em 0;
|
||||
}
|
||||
|
||||
.report-list {
|
||||
display: block;
|
||||
list-style: none;
|
||||
@ -29,23 +33,72 @@
|
||||
}
|
||||
.report-item .report {
|
||||
background: #D6DAF0;
|
||||
margin: 0.2em 4px;
|
||||
padding: 0.2em 0.3em 0.5em 0.6em;
|
||||
margin: 0.2em 4px 0.2em 0;
|
||||
padding: 0.3em 0.3em 0.5em 0.6em;
|
||||
border-width: 1px;
|
||||
border-style: none solid solid none;
|
||||
border-color: #B7C5D9;
|
||||
display: inline-block;
|
||||
max-width: 94% !important;
|
||||
}
|
||||
.report-reason {
|
||||
display: block;
|
||||
font-size: 115%;
|
||||
line-height: 115%;
|
||||
}
|
||||
|
||||
.report-details {
|
||||
display: block;
|
||||
margin: 0.3em 0 0 0;
|
||||
padding: 0.3em 0 0 0;
|
||||
clear: left;
|
||||
list-style: none;
|
||||
}
|
||||
.report-detail {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.detail-name {
|
||||
display: inline-block;
|
||||
min-width: 6.25em;
|
||||
}
|
||||
|
||||
.report-actions {
|
||||
display: block;
|
||||
border: none;
|
||||
border-top: 1px solid #B7C5D9;
|
||||
margin: 0.3em 0 0 0;
|
||||
padding: 0.3em 0 0 0;
|
||||
clear: left;
|
||||
list-style: none;
|
||||
}
|
||||
.report-action {
|
||||
display: inline-block;
|
||||
margin: 0 0.5em 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
.report-action::after {
|
||||
display: inline-block;
|
||||
margin: 0 0 0 0.5em;
|
||||
padding: 0;
|
||||
content: ' | ';
|
||||
}
|
||||
.report-action:last-child::after {
|
||||
display: none;
|
||||
content: '';
|
||||
}
|
||||
|
||||
|
||||
.report-content div.post.reply,
|
||||
.report-content div.thread {
|
||||
background: #FFC4C4;
|
||||
margin: 0.2em 4px;
|
||||
margin: 0.2em 4px 0.2em 0;
|
||||
padding: 0.2em 0.3em 0.5em 0.6em;
|
||||
border-width: 1px;
|
||||
border-style: none solid solid none;
|
||||
border-color: #F88;
|
||||
display: inline-block;
|
||||
max-width: 94% !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,26 +1,52 @@
|
||||
<li class="report-item">
|
||||
<div class="report">
|
||||
{% trans 'Board' %}: <a href="?/{{ report.board }}/{{ config.file_index }}">{{ config.board_abbreviation|sprintf(report.board) }}</a>
|
||||
<br>
|
||||
{% trans 'Reason' %}: {{ report.reason }}
|
||||
<br>
|
||||
{% trans 'Report date' %}: {{ report.time|date(config.post_date) }}
|
||||
<br>
|
||||
{% if mod|hasPermission(config.mod.show_ip, report.board) %}
|
||||
{% trans 'Reported by' %}: <a href="?/IP/{{ report.ip }}">{{ report.ip }}</a>
|
||||
<br>
|
||||
{% endif %}
|
||||
<span class="report-reason">{% if report.reason %}{{ report.reason }}{% else %}<em>{% trans 'No reason given.' %}</em>{% endif %}</span>
|
||||
|
||||
<ul class="report-details">
|
||||
<li class="report-detail detail-date">
|
||||
<span class="detail-name">{% trans 'Report date' %}:</span>
|
||||
<span class="detail-value">{{ report.time|date(config.post_date) }}</span>
|
||||
</li>
|
||||
|
||||
{% if mod|hasPermission(config.mod.show_ip, report.board) %}
|
||||
<li class="report-detail detail-date">
|
||||
<span class="detail-name">{% trans 'Reported by' %}:</span>
|
||||
<span class="detail-value"><a href="?/IP/{{ report.ip }}">{{ report.ip }}</a></span>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
{% if mod|hasPermission(config.mod.report_dismiss, report.board) or mod|hasPermission(config.mod.report_dismiss_ip, report.board) %}
|
||||
<hr>
|
||||
<ul class="report-actions">
|
||||
{% if mod|hasPermission(config.mod.report_dismiss, report.board) %}
|
||||
<a title="{% trans 'Discard abuse report' %}" href="?/reports/{{ report.id }}/dismiss/{{ token }}">Dismiss</a>
|
||||
<li class="report-action">
|
||||
<a class="action-item action-available" title="{% trans 'Discard abuse report' %}" href="?/reports/{{ report.id }}/dismiss/{{ token_dismiss }}">Dismiss</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if mod|hasPermission(config.mod.report_dismiss_ip, report.board) %}
|
||||
{% if mod|hasPermission(config.mod.report_dismiss, report.board) %}
|
||||
|
|
||||
{% endif %}
|
||||
<a title="{% trans 'Discard all abuse reports by this IP address' %}" href="?/reports/{{ report.id }}/dismissall/{{ token_all }}">Dismiss+</a>
|
||||
<li class="report-action">
|
||||
<a class="action-item action-available" title="{% trans 'Discard all abuse reports by this IP address' %}" href="?/reports/{{ report.id }}/dismissall/{{ token_ip }}">Dismiss+</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if global and mod|hasPermission(config.mod.report_demote, report.board) %}
|
||||
<li class="report-action">
|
||||
{% if report.local %}
|
||||
<a class="action-item action-available" title="{% trans 'Demote global abuse report to a local report' %}" href="?/reports/{{ report.id }}/demote/{{ token_demote }}">Demote</a>
|
||||
{% else %}
|
||||
<span class="action-item action-unavailable" title="{% trans 'Report has already been dismissed locally' %}">Demote</span>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% elseif not global and mod|hasPermission(config.mod.report_promote, report.board) %}
|
||||
<li class="report-action">
|
||||
{% if report.global %}
|
||||
<span class="action-item action-unavailable" title="{% trans 'Report is already a global report' %}">Promote</span>
|
||||
{% else %}
|
||||
<a class="action-item action-available" title="{% trans 'Promote local abuse report to a global report' %}" href="?/reports/{{ report.id }}/promote/{{ token_promote }}">Promote</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
@ -1,7 +1,5 @@
|
||||
<li class="mod-report">
|
||||
<div class="report-details">
|
||||
<h2>{{ report_title }}</h2>
|
||||
</div>
|
||||
<h2 class="report-header">{{ report_title }}</h2>
|
||||
|
||||
<div class="report-content">
|
||||
{{ content_html }}
|
||||
|
Loading…
Reference in New Issue
Block a user