diff --git a/app/Report/AbstractReport.php b/app/Report/AbstractReport.php index 5060aeeec..9aa086084 100644 --- a/app/Report/AbstractReport.php +++ b/app/Report/AbstractReport.php @@ -31,7 +31,7 @@ public function showReason(): bool { public function reason(): string { return (string)self::$db->scalar(" SELECT Reason FROM reports WHERE ID = ? - ", $this->subject->id() /** @phpstan-ignore-line */ + ", $this->reportId /** @phpstan-ignore-line */ ); } } diff --git a/app/Report/Collage.php b/app/Report/Collage.php index 95d30825f..12af24b8e 100644 --- a/app/Report/Collage.php +++ b/app/Report/Collage.php @@ -4,6 +4,7 @@ class Collage extends AbstractReport { public function __construct( + protected int $reportId, protected \Gazelle\Collage $subject ) { } diff --git a/app/Report/Comment.php b/app/Report/Comment.php index 53ba32c71..b16f31623 100644 --- a/app/Report/Comment.php +++ b/app/Report/Comment.php @@ -4,6 +4,7 @@ class Comment extends AbstractReport { public function __construct( + protected int $reportId, protected \Gazelle\Comment\AbstractComment $subject ) { } diff --git a/app/Report/ForumPost.php b/app/Report/ForumPost.php index f71387a7f..79bb7f619 100644 --- a/app/Report/ForumPost.php +++ b/app/Report/ForumPost.php @@ -5,6 +5,7 @@ class ForumPost extends AbstractReport { public function __construct( + protected int $reportId, protected \Gazelle\ForumPost $subject ) { } diff --git a/app/Report/ForumThread.php b/app/Report/ForumThread.php index 3a2e3a459..36df7f296 100644 --- a/app/Report/ForumThread.php +++ b/app/Report/ForumThread.php @@ -5,6 +5,7 @@ class ForumThread extends AbstractReport { public function __construct( + protected int $reportId, protected \Gazelle\ForumThread $subject ) { } @@ -13,10 +14,10 @@ public function template(): string { } public function bbLink(): string { - return "the forum thread [url={$this->subject->id()}]" . display_str($this->title()) . '[/url]'; + return "the forum thread [thread]{$this->subject->id()}[/thread]"; } public function title(): string { - return 'Forum Thread Report: ' . display_str($this->title()); + return 'Forum Thread Report: ' . display_str($this->subject->title()); } } diff --git a/app/Report/Request.php b/app/Report/Request.php index ab5070227..22608b778 100644 --- a/app/Report/Request.php +++ b/app/Report/Request.php @@ -6,6 +6,7 @@ class Request extends AbstractReport { protected bool $isUpdate = false; public function __construct( + protected int $reportId, protected \Gazelle\Request $subject ) { } diff --git a/app/Report/User.php b/app/Report/User.php index 90f047501..7b584fd5b 100644 --- a/app/Report/User.php +++ b/app/Report/User.php @@ -4,6 +4,7 @@ class User extends AbstractReport { public function __construct( + protected int $reportId, protected \Gazelle\User $subject ) { } diff --git a/sections/reports/compose.php b/sections/reports/compose.php index ca76b2479..9f876d887 100644 --- a/sections/reports/compose.php +++ b/sections/reports/compose.php @@ -4,10 +4,10 @@ error(403); } -$ReportID = (int)($_GET['reportid'] ?? 0); +$reportId = (int)($_GET['reportid'] ?? 0); $id = (int)($_GET['thingid'] ?? 0); $type = $_GET['type'] ?? null; -if (!$ReportID || !$id || is_null($type)) { +if (!$reportId || !$id || is_null($type)) { error(403); } @@ -32,7 +32,7 @@ if (is_null($reported)) { error(404); } - $report = new Gazelle\Report\User($reported); + $report = new Gazelle\Report\User($reportId, $reported); break; case 'request': @@ -41,7 +41,7 @@ if (is_null($request)) { error(404); } - $report = new Gazelle\Report\Request($request); + $report = new Gazelle\Report\Request($reportId, $request); break; case 'collage': @@ -49,7 +49,7 @@ if (is_null($collage)) { error(404); } - $report = new Gazelle\Report\Collage($collage); + $report = new Gazelle\Report\Collage($reportId, $collage); break; case 'thread': @@ -60,7 +60,7 @@ if (!$Viewer->readAccess($thread->forum())) { error(403); } - $report = new Gazelle\Report\ForumThread($thread); + $report = new Gazelle\Report\ForumThread($reportId, $thread); break; case 'post': @@ -71,7 +71,7 @@ if (!$Viewer->readAccess($post->thread()->forum())) { error(403); } - $report = new Gazelle\Report\ForumPost($post); + $report = new Gazelle\Report\ForumPost($reportId, $post); break; case 'comment': @@ -79,7 +79,7 @@ if (is_null($comment)) { error(404); } - $report = (new Gazelle\Report\Comment($comment))->setContext($reportType['title']); + $report = (new Gazelle\Report\Comment($reportId, $comment))->setContext($reportType['title']); break; default: diff --git a/sections/reports/report.php b/sections/reports/report.php index 9d2c4f9db..be47ddeec 100644 --- a/sections/reports/report.php +++ b/sections/reports/report.php @@ -18,7 +18,7 @@ if (is_null($user)) { error(404); } - $report = new Gazelle\Report\User($user); + $report = new Gazelle\Report\User($id, $user); break; case 'request': @@ -26,7 +26,7 @@ if (is_null($request)) { error(404); } - $report = new Gazelle\Report\Request($request); + $report = new Gazelle\Report\Request($id, $request); break; case 'request_update': @@ -37,7 +37,7 @@ if ($request->isFilled() || $request->categoryName() != 'Music' || $request->year() != 0) { error(403); } - $report = (new Gazelle\Report\Request($request))->isUpdate(true); + $report = (new Gazelle\Report\Request($id, $request))->isUpdate(true); break; case 'collage': @@ -45,7 +45,7 @@ if (is_null($collage)) { error(404); } - $report = new Gazelle\Report\Collage($collage); + $report = new Gazelle\Report\Collage($id, $collage); break; case 'thread': @@ -56,7 +56,7 @@ if (!$Viewer->readAccess($thread->forum())) { error(403); } - $report = new Gazelle\Report\ForumThread($thread); + $report = new Gazelle\Report\ForumThread($id, $thread); break; case 'post': @@ -67,7 +67,7 @@ if (!$Viewer->readAccess($post->thread()->forum())) { error(403); } - $report = new Gazelle\Report\ForumPost($post); + $report = new Gazelle\Report\ForumPost($id, $post); break; case 'comment': @@ -75,7 +75,7 @@ if (is_null($comment)) { error(404); } - $report = (new Gazelle\Report\Comment($comment))->setContext($reportType['title']); + $report = (new Gazelle\Report\Comment($id, $comment))->setContext($reportType['title']); break; } diff --git a/templates/report/forum-post.twig b/templates/report/forum-post.twig index 58acbd8dc..8776174c4 100644 --- a/templates/report/forum-post.twig +++ b/templates/report/forum-post.twig @@ -1,4 +1,4 @@ -<p>You are reporting the post {{ subject.thread.forum.name }} » {{ report.bbLink|bb_format }}</p> +<p>You are reporting the post {{ subject.thread.forum.link|raw }} » {{ report.bbLink|bb_format }}</p> <table> <tr class="colhead"> <td width="12%">Username</td> diff --git a/templates/report/forum-thread.twig b/templates/report/forum-thread.twig index 2ab0cea00..b55d87b87 100644 --- a/templates/report/forum-thread.twig +++ b/templates/report/forum-thread.twig @@ -1,12 +1,12 @@ <p>You are reporting the thread:</p> <table> <tr class="colhead"> - <td width="12%">Username</td> + <td width="12%">Author</td> <td>Title</td> </tr> <tr> - <td>{{ context.author_id|user_url }}</td> - <td>{{ context.title }}</td> + <td>{{ report.subject.author.id|user_url }}</td> + <td>{{ ("[thread]" ~ report.subject.id ~ "[/thread]")|bb_format }}</td> </tr> </table> diff --git a/templates/report/index.twig b/templates/report/index.twig index d6c2de6e2..e90956025 100644 --- a/templates/report/index.twig +++ b/templates/report/index.twig @@ -17,7 +17,9 @@ <td><strong>{{ report.link|raw }}</strong></td> <td> <strong>{{ type[report.subjectType].title }}</strong> was reported by {{ report.reporter.id|user_url }} {{ report.created|time_diff }} + {% if report.reporter.id != viewer.id %} <a href="reports.php?action=compose&toid={{ report.reporter.id }}&reportid={{ report.id }}&type={{ report.subjectType }}&thingid={{ report.subjectId }}" class="brackets">Contact</a> + {% endif %} </td> </tr> <tr>