From c94a7cb40342777d23433a38d29ba17fa2390981 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 19 Oct 2024 21:25:15 +0200 Subject: [PATCH] pages.php: mod_reports signal if there are more reports than the limit --- inc/mod/pages.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 625a66e6..aee684e4 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -2917,10 +2917,11 @@ function mod_reports() { } } - $count = 0; - $body = ''; + $to_build = []; foreach ($reports as $report) { - if (!isset($report_posts[$report['board']][$report['post']])) { + if (isset($report_posts[$report['board']][$report['post']])) { + $to_build[] = $report; + } else { // Invalid report (post has since been deleted) if ($config['auto_maintenance'] != false) { $query = prepare("DELETE FROM ``reports`` WHERE `post` = :id AND `board` = :board"); @@ -2930,7 +2931,17 @@ function mod_reports() { } continue; } + } + if (\count($to_build) > $reports_limit) { + \array_pop($to_build); + $has_extra = true; + } else { + $has_extra = false; + } + + $body = ''; + foreach ($to_build as $report) { openBoard($report['board']); $post = &$report_posts[$report['board']][$report['post']]; @@ -2967,11 +2978,16 @@ function mod_reports() { if (isset($__old_body_truncate_char)) { $config['body_truncate_char'] = $__old_body_truncate_char; } - - $count++; } - mod_page(\sprintf('%s (%d)', _('Report queue'), $count), 'mod/reports.html', [ 'reports' => $body, 'count' => $count ]); + $count = \count($to_build); + $header_count = $has_extra ? "{$count}+" : (string)$count; + + mod_page( + \sprintf('%s (%s)', _('Report queue'), $header_count), + 'mod/reports.html', + [ 'reports' => $body, 'count' => $count ] + ); } function mod_report_dismiss($id, $all = false) {