Skip to content

Commit

Permalink
Improve non-torrent reporting experience
Browse files Browse the repository at this point in the history
  • Loading branch information
Spine committed Oct 15, 2022
1 parent f974d99 commit aecd807
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/Report/AbstractReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
);
}
}
1 change: 1 addition & 0 deletions app/Report/Collage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class Collage extends AbstractReport {
public function __construct(
protected int $reportId,
protected \Gazelle\Collage $subject
) { }

Expand Down
1 change: 1 addition & 0 deletions app/Report/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class Comment extends AbstractReport {
public function __construct(
protected int $reportId,
protected \Gazelle\Comment\AbstractComment $subject
) { }

Expand Down
1 change: 1 addition & 0 deletions app/Report/ForumPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class ForumPost extends AbstractReport {

public function __construct(
protected int $reportId,
protected \Gazelle\ForumPost $subject
) { }

Expand Down
5 changes: 3 additions & 2 deletions app/Report/ForumThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class ForumThread extends AbstractReport {

public function __construct(
protected int $reportId,
protected \Gazelle\ForumThread $subject
) { }

Expand All @@ -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());
}
}
1 change: 1 addition & 0 deletions app/Report/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Request extends AbstractReport {
protected bool $isUpdate = false;

public function __construct(
protected int $reportId,
protected \Gazelle\Request $subject
) { }

Expand Down
1 change: 1 addition & 0 deletions app/Report/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class User extends AbstractReport {
public function __construct(
protected int $reportId,
protected \Gazelle\User $subject
) { }

Expand Down
16 changes: 8 additions & 8 deletions sections/reports/compose.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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':
Expand All @@ -41,15 +41,15 @@
if (is_null($request)) {
error(404);
}
$report = new Gazelle\Report\Request($request);
$report = new Gazelle\Report\Request($reportId, $request);
break;

case 'collage':
$collage = (new Gazelle\Manager\Collage)->findById($id);
if (is_null($collage)) {
error(404);
}
$report = new Gazelle\Report\Collage($collage);
$report = new Gazelle\Report\Collage($reportId, $collage);
break;

case 'thread':
Expand All @@ -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':
Expand All @@ -71,15 +71,15 @@
if (!$Viewer->readAccess($post->thread()->forum())) {
error(403);
}
$report = new Gazelle\Report\ForumPost($post);
$report = new Gazelle\Report\ForumPost($reportId, $post);
break;

case 'comment':
$comment = (new Gazelle\Manager\Comment)->findById($id);
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:
Expand Down
14 changes: 7 additions & 7 deletions sections/reports/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
if (is_null($user)) {
error(404);
}
$report = new Gazelle\Report\User($user);
$report = new Gazelle\Report\User($id, $user);
break;

case 'request':
$request = (new Gazelle\Manager\Request)->findById($id);
if (is_null($request)) {
error(404);
}
$report = new Gazelle\Report\Request($request);
$report = new Gazelle\Report\Request($id, $request);
break;

case 'request_update':
Expand All @@ -37,15 +37,15 @@
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':
$collage = (new Gazelle\Manager\Collage)->findById($id);
if (is_null($collage)) {
error(404);
}
$report = new Gazelle\Report\Collage($collage);
$report = new Gazelle\Report\Collage($id, $collage);
break;

case 'thread':
Expand All @@ -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':
Expand All @@ -67,15 +67,15 @@
if (!$Viewer->readAccess($post->thread()->forum())) {
error(403);
}
$report = new Gazelle\Report\ForumPost($post);
$report = new Gazelle\Report\ForumPost($id, $post);
break;

case 'comment':
$comment = (new Gazelle\Manager\Comment)->findById($id);
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;
}

Expand Down
2 changes: 1 addition & 1 deletion templates/report/forum-post.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p>You are reporting the post {{ subject.thread.forum.name }} &raquo; {{ report.bbLink|bb_format }}</p>
<p>You are reporting the post {{ subject.thread.forum.link|raw }} &raquo; {{ report.bbLink|bb_format }}</p>
<table>
<tr class="colhead">
<td width="12%">Username</td>
Expand Down
6 changes: 3 additions & 3 deletions templates/report/forum-thread.twig
Original file line number Diff line number Diff line change
@@ -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>

2 changes: 2 additions & 0 deletions templates/report/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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&amp;toid={{ report.reporter.id }}&amp;reportid={{ report.id }}&amp;type={{ report.subjectType }}&amp;thingid={{ report.subjectId }}" class="brackets">Contact</a>
{% endif %}
</td>
</tr>
<tr>
Expand Down

0 comments on commit aecd807

Please sign in to comment.