Files

76 lines
2.0 KiB
PHP
Raw Permalink Normal View History

2026-06-02 20:54:38 +02:00
<?php
namespace RomhackPlaza\Master\Report;
use XF\Entity\Report;
use Override;
use XF\Mvc\Entity\Entity;
use XF\Report\AbstractHandler;
class Entry extends AbstractHandler
{
#[Override]
protected function canViewContent(Report $report)
{
return \XF::visitor()->hasPermission('romhackplaza', 'view');
}
#[Override]
protected function canActionContent(Report $report)
{
return \XF::visitor()->hasPermission('romhackplaza', 'canEditOthersEntries');
}
#[Override]
public function setupReportEntityContent(Report $report, Entity $content)
{
$report->content_user_id = $content['user_id'];
$report->content_info = [
'id' => $content['id'],
'title' => $content['title'],
'slug' => $content['slug'],
'type' => $content['type'],
'user_id' => $content['user_id'],
'description' => $content['description'] ?? "",
];
}
public function getContent($id)
{
$laravelDb = \RomhackPlaza\Master\Helper\Laravel::db();
if( $laravelDb ){
$entry = $laravelDb->fetchRow("SELECT id, complete_title as title, slug, type, user_id, description FROM entries WHERE id = ?", $id);
$entity = \XF::em()->instantiateEntity('RomhackPlaza\Master:Entry', $entry);
$entity->setReadOnly(true);
return $entity;
}
return null;
}
#[Override]
public function getContentTitle(Report $report)
{
return $report->content_info['title'] ?? 'Unknown';
}
#[Override]
public function getContentLink(Report $report)
{
return \XF::options()->homePageUrl . '/' . $report->content_info['type'] . '/' . $report->content_info['slug'];
}
#[Override]
public function getContentMessage(Report $report)
{
return $report->content_info['message'];
}
#[Override]
public function getTemplateName()
{
return "public:report_content_romhackplaza_entry";
}
}