2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2023-01-10 22:44:09 +00:00
|
|
|
|
|
|
|
namespace Shimmie2;
|
|
|
|
|
2020-01-26 23:12:48 +00:00
|
|
|
use function MicroHTML\INPUT;
|
2007-10-24 21:45:38 +00:00
|
|
|
|
2024-01-20 20:48:47 +00:00
|
|
|
/**
|
|
|
|
* @phpstan-type Report array{id: int, image: Image, reason: string, reporter_name: string}
|
|
|
|
*/
|
2019-05-28 16:59:38 +00:00
|
|
|
class ReportImageTheme extends Themelet
|
|
|
|
{
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
2024-01-20 20:48:47 +00:00
|
|
|
* @param array<Report> $reports
|
2024-01-20 14:10:59 +00:00
|
|
|
*/
|
2024-01-15 14:23:00 +00:00
|
|
|
public function display_reported_images(Page $page, array $reports): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $config, $user;
|
2008-08-12 02:37:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$h_reportedimages = "";
|
|
|
|
foreach ($reports as $report) {
|
|
|
|
$image = $report['image'];
|
|
|
|
$h_reason = format_text($report['reason']);
|
|
|
|
$image_link = $this->build_thumb_html($image);
|
2008-08-12 02:37:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$reporter_name = html_escape($report['reporter_name']);
|
|
|
|
$userlink = "<a href='".make_link("user/$reporter_name")."'>$reporter_name</a>";
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2023-02-04 20:50:26 +00:00
|
|
|
$iabbe = send_event(new ImageAdminBlockBuildingEvent($image, $user, "report"));
|
2024-03-28 12:42:39 +00:00
|
|
|
$actions = join("", $iabbe->get_parts());
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$h_reportedimages .= "
|
2012-02-22 14:27:56 +00:00
|
|
|
<tr>
|
2008-08-12 02:37:48 +00:00
|
|
|
<td>{$image_link}</td>
|
2022-09-30 13:16:48 +00:00
|
|
|
<td class='reason'>Report by $userlink: $h_reason</td>
|
2024-01-19 19:04:11 +00:00
|
|
|
<td class='formstretch post_controls'>
|
2010-09-22 11:56:19 +00:00
|
|
|
".make_form(make_link("image_report/remove"))."
|
2008-08-12 02:37:48 +00:00
|
|
|
<input type='hidden' name='id' value='{$report['id']}'>
|
|
|
|
<input type='submit' value='Remove Report'>
|
|
|
|
</form>
|
|
|
|
|
2024-01-19 19:04:11 +00:00
|
|
|
$actions
|
2008-08-12 02:37:48 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2019-06-18 18:45:59 +00:00
|
|
|
$thumb_width = $config->get_int(ImageConfig::THUMB_WIDTH);
|
2019-05-28 16:59:38 +00:00
|
|
|
$html = "
|
2009-08-18 21:39:10 +00:00
|
|
|
<table id='reportedimage' class='zebra'>
|
2020-10-26 15:18:23 +00:00
|
|
|
<thead><td width='$thumb_width'>Post</td><td>Reason</td><td width='128'>Action</td></thead>
|
2007-10-24 21:45:38 +00:00
|
|
|
$h_reportedimages
|
|
|
|
</table>
|
|
|
|
";
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2020-10-26 15:18:23 +00:00
|
|
|
$page->set_title("Reported Posts");
|
|
|
|
$page->set_heading("Reported Posts");
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->add_block(new NavBlock());
|
2020-10-26 15:18:23 +00:00
|
|
|
$page->add_block(new Block("Reported Posts", $html));
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2007-10-24 21:45:38 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
/**
|
2024-01-01 03:27:39 +00:00
|
|
|
* @param ImageReport[] $reports
|
2019-05-28 16:59:38 +00:00
|
|
|
*/
|
2024-01-15 14:23:00 +00:00
|
|
|
public function display_image_banner(Image $image, array $reports): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $config, $page;
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2020-01-26 13:19:35 +00:00
|
|
|
$i_image = $image->id;
|
2019-05-28 16:59:38 +00:00
|
|
|
$html = "";
|
|
|
|
$public = $config->get_string("report_image_publicity");
|
|
|
|
if ($public != "none" && count($reports) > 0) {
|
|
|
|
$html .= "<b>Current reports:</b>";
|
|
|
|
foreach ($reports as $report) {
|
|
|
|
$html .= "<br>";
|
|
|
|
if ($public == "both") {
|
|
|
|
$html .= html_escape(User::by_id($report->user_id)->name);
|
|
|
|
$html .= " - ";
|
|
|
|
$html .= format_text($report->reason);
|
|
|
|
} elseif ($public == "user") {
|
|
|
|
$html .= html_escape(User::by_id($report->user_id)->name);
|
|
|
|
} elseif ($public == "reason") {
|
|
|
|
$html .= format_text($report->reason);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$html .= "<p>";
|
|
|
|
}
|
|
|
|
$html .= "
|
2010-09-22 11:56:19 +00:00
|
|
|
".make_form(make_link("image_report/add"))."
|
2007-10-24 21:45:38 +00:00
|
|
|
<input type='hidden' name='image_id' value='$i_image'>
|
2012-02-12 09:55:47 +00:00
|
|
|
<input type='text' name='reason' placeholder='Please enter a reason'>
|
2007-10-24 21:45:38 +00:00
|
|
|
<input type='submit' value='Report'>
|
|
|
|
</form>
|
|
|
|
";
|
2020-10-26 15:18:23 +00:00
|
|
|
$page->add_block(new Block("Report Post", $html, "left"));
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2015-02-08 04:27:54 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
public function get_nuller(User $duser): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-01-26 23:12:48 +00:00
|
|
|
global $page;
|
|
|
|
$html = (string)SHM_SIMPLE_FORM(
|
2020-01-30 10:31:11 +00:00
|
|
|
"image_report/remove_reports_by",
|
2023-11-11 21:49:12 +00:00
|
|
|
INPUT(["type" => 'hidden', "name" => 'user_id', "value" => $duser->id]),
|
2020-01-26 23:12:48 +00:00
|
|
|
SHM_SUBMIT('Delete all reports by this user')
|
|
|
|
);
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->add_block(new Block("Reports", $html, "main", 80));
|
|
|
|
}
|
2007-10-24 21:45:38 +00:00
|
|
|
}
|