From a8a843bf4b81186571b57e9bcd001fcab3601611 Mon Sep 17 00:00:00 2001 From: unknown <8n-tech@users.noreply.github.com> Date: Sun, 19 Oct 2014 00:07:16 -0500 Subject: [PATCH] [#184] Added Promote and Demote to reports. CSS improvements. --- inc/config.php | 4 ++ inc/mod/pages.php | 91 ++++++++++++++++++++++++++----- mod.php | 10 ++-- stylesheets/mod/mod.css | 61 +++++++++++++++++++-- templates/mod/report.html | 60 ++++++++++++++------ templates/mod/report_content.html | 4 +- 6 files changed, 188 insertions(+), 42 deletions(-) diff --git a/inc/config.php b/inc/config.php index 8ddf3bb6..e917c52e 100644 --- a/inc/config.php +++ b/inc/config.php @@ -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 diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 0b7b78ca..b0dbe47f 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -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; diff --git a/mod.php b/mod.php index 654d23fe..45fff1ad 100644 --- a/mod.php +++ b/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 diff --git a/stylesheets/mod/mod.css b/stylesheets/mod/mod.css index 463b837e..42ff64d9 100644 --- a/stylesheets/mod/mod.css +++ b/stylesheets/mod/mod.css @@ -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; -} \ No newline at end of file +} + diff --git a/templates/mod/report.html b/templates/mod/report.html index a3bc0f6d..f7b5b868 100644 --- a/templates/mod/report.html +++ b/templates/mod/report.html @@ -1,26 +1,52 @@