Files
XenForoRomhackPlazaAddon/Pub/Controller/News.php
2026-06-16 16:21:43 +02:00

50 lines
1.5 KiB
PHP

<?php
namespace RomhackPlaza\Master\Pub\Controller;
use XF\Mvc\ParameterBag;
use XF\Mvc\Reply\AbstractReply;
use XF\Pub\Controller\AbstractController;
class News extends AbstractController {
public function actionIndex(ParameterBag $params): AbstractReply
{
$entryId = $params->id;
$laravelDb = \RomhackPlaza\Master\Helper\Laravel::db();
if( !$laravelDb )
return $this->notFound();
$entry = $laravelDb->fetchRow("SELECT id, slugFROM news WHERE id = ?", $entryId);
if( !$entry )
return $this->notFound();
return $this->redirect(\XF::options()->homePageUrl . '/news/' . $entry['slug']);
}
public function actionReport(ParameterBag $params): AbstractReply
{
$this->assertRegistrationRequired();
$entryId = $params->id;
$laravelDb = \RomhackPlaza\Master\Helper\Laravel::db();
if( !$laravelDb )
return $this->notFound();
$entry = $laravelDb->fetchRow("SELECT id, title, slug, user_id, description FROM news WHERE id = ?", $entryId);
if( !$entry )
return $this->notFound();
$entity = $this->em()->instantiateEntity('RomhackPlaza\Master:News', $entry);
$entity->setReadOnly(true);
$reportPlugin = $this->plugin('XF:Report');
return $reportPlugin->actionReport(
'romhackplaza_news', $entity,
$this->buildLink('romhackplaza_news/report', $entity),
\XF::options()->homePageUrl . '/news/report_redirect?id=' . $entity->id
);
}
}