Added XenForo activity for Laravel pages

This commit is contained in:
2026-07-03 18:26:03 +02:00
parent be885ab80d
commit e33f0bd77c
17 changed files with 188 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
namespace RomhackPlaza\Master\Pub\Controller; namespace RomhackPlaza\Master\Pub\Controller;
use RomhackPlaza\Master\Helper\Laravel;
use XF\Mvc\ParameterBag; use XF\Mvc\ParameterBag;
use XF\Mvc\Reply\AbstractReply; use XF\Mvc\Reply\AbstractReply;
use XF\Pub\Controller\AbstractController; use XF\Pub\Controller\AbstractController;
@@ -47,4 +48,36 @@ class Entry extends AbstractController {
); );
} }
public static function getActivityDetails(array $activities)
{
return self::getActivityDetailsForContent(
$activities,
\XF::phrase('viewing_romhackplaza_entry'),
'entry_id',
function (array $ids)
{
$db = Laravel::db();
if( !$db || empty($ids) )
return [];
$entries = $db->fetchAll("
SELECT id, complete_title as title, slug, type
FROM entries
WHERE id IN (" . $db->quote($ids) . ")
");
$data = [];
foreach( $entries as $entry ){
$data[$entry['id']] = [
'title' => $entry['title'],
'url' => \XF::options()->homePageUrl . '/' . $entry['type'] . '/' . $entry['slug'],
];
}
return $data;
},
\XF::phrase('viewing_romhackplaza_database')
);
}
} }

View File

@@ -2,6 +2,7 @@
namespace RomhackPlaza\Master\Pub\Controller; namespace RomhackPlaza\Master\Pub\Controller;
use RomhackPlaza\Master\Helper\Laravel;
use XF\Mvc\ParameterBag; use XF\Mvc\ParameterBag;
use XF\Mvc\Reply\AbstractReply; use XF\Mvc\Reply\AbstractReply;
use XF\Pub\Controller\AbstractController; use XF\Pub\Controller\AbstractController;
@@ -15,7 +16,7 @@ class News extends AbstractController {
if( !$laravelDb ) if( !$laravelDb )
return $this->notFound(); return $this->notFound();
$entry = $laravelDb->fetchRow("SELECT id, slugFROM news WHERE id = ?", $entryId); $entry = $laravelDb->fetchRow("SELECT id, slug FROM news WHERE id = ?", $entryId);
if( !$entry ) if( !$entry )
return $this->notFound(); return $this->notFound();
@@ -47,4 +48,35 @@ class News extends AbstractController {
); );
} }
public static function getActivityDetails(array $activities)
{
return self::getActivityDetailsForContent(
$activities,
\XF::phrase('viewing_romhackplaza_news'),
'news_id',
function (array $ids)
{
$db = Laravel::db();
if( !$db || empty($ids) )
return [];
$entries = $db->fetchAll("
SELECT id, slug, title FROM news
WHERE id IN (" . $db->quote($ids) . ")
");
$data = [];
foreach( $entries as $entry ){
$data[$entry['id']] = [
'title' => $entry['title'],
'url' => \XF::options()->homePageUrl . '/news/' . $entry['slug'],
];
}
return $data;
},
\XF::phrase('viewing_romhackplaza_database')
);
}
} }

View File

@@ -0,0 +1,42 @@
<?php
namespace RomhackPlaza\Master\Pub\Controller;
use XF\Entity\SessionActivity;
use XF\Mvc\ParameterBag;
use XF\Pub\Controller\AbstractController;
class RomhackPlaza extends AbstractController
{
public static function getActivityDetails(array $activities)
{
/** @var SessionActivity $activity */
foreach ($activities as $activity) {
switch ( $activity->controller_action ){
case 'Drafts':
return \XF::phrase('viewing_romhackplaza_drafts');
break;
case 'Reviews':
return \XF::phrase('viewing_romhackplaza_reviews');
break;
case 'Mod':
return \XF::phrase('performing_moderation_duties');
break;
case 'Submit':
return \XF::phrase('viewing_romhackplaza_submit');
break;
case 'Edit':
return \XF::phrase('viewing_romhackplaza_edit');
break;
case 'Tools':
return \XF::phrase('viewing_romhackplaza_tools');
break;
case 'Play':
return \XF::phrase('viewing_romhackplaza_play');
break;
}
}
return \XF::phrase('viewing_romhackplaza');
}
}

View File

@@ -58,4 +58,5 @@
<phrase title="permission.romhackplaza_canSubmitTempFile" version_id="1000000" version_string="1.0.0"><![CDATA[Can Submit Temporary File]]></phrase> <phrase title="permission.romhackplaza_canSubmitTempFile" version_id="1000000" version_string="1.0.0"><![CDATA[Can Submit Temporary File]]></phrase>
<phrase title="permission.romhackplaza_view" version_id="1000000" version_string="1.0.0"><![CDATA[View entries]]></phrase> <phrase title="permission.romhackplaza_view" version_id="1000000" version_string="1.0.0"><![CDATA[View entries]]></phrase>
<phrase title="permission_interface.romhackplaza" version_id="1000000" version_string="1.0.0"><![CDATA[Romhack Plaza permissions]]></phrase> <phrase title="permission_interface.romhackplaza" version_id="1000000" version_string="1.0.0"><![CDATA[Romhack Plaza permissions]]></phrase>
<phrase title="rebuld_entries_count" version_id="1010170" version_string="1.1.1"><![CDATA[Rebuild entries count]]></phrase>
</phrases> </phrases>

View File

@@ -88,6 +88,13 @@ $0]]></replace>
</li> </li>
$0]]></replace> $0]]></replace>
</modification> </modification>
<modification type="admin" template="tools_rebuild" modification_key="rhpz_tools_rebuild_rhpz_entry_count" description="Add RHPZ Entry count job on rebuild caches page" execution_order="10" enabled="1" action="str_replace">
<find><![CDATA[<!--[XF:after_message_count]-->]]></find>
<replace><![CDATA[$0
<xf:macro id="rebuild_job"
arg-header="{{ phrase('rebuild_entries_count') }}"
arg-job="RomhackPlaza\Master:EntriesCount" />]]></replace>
</modification>
<modification type="admin" template="user_edit" modification_key="rhpz_user_edit_delete_account_codes_tab" description="Add Tab for listing delete account codes in User edit" execution_order="10" enabled="1" action="str_replace"> <modification type="admin" template="user_edit" modification_key="rhpz_user_edit_delete_account_codes_tab" description="Add Tab for listing delete account codes in User edit" execution_order="10" enabled="1" action="str_replace">
<find><![CDATA[<!--[XF:tabs:end]-->]]></find> <find><![CDATA[<!--[XF:tabs:end]-->]]></find>
<replace><![CDATA[<xf:if is="$user.user_id"> <replace><![CDATA[<xf:if is="$user.user_id">

View File

@@ -352,5 +352,65 @@
"version_id": 1010170, "version_id": 1010170,
"version_string": "1.1.1", "version_string": "1.1.1",
"hash": "4aacc0a0b65d374943a84f9a0c8ad173" "hash": "4aacc0a0b65d374943a84f9a0c8ad173"
},
"viewing_romhackplaza.txt": {
"global_cache": false,
"version_id": 1010270,
"version_string": "1.1.2",
"hash": "7227f6290a7ed21eb99f9bf648271e1d"
},
"viewing_romhackplaza_database.txt": {
"global_cache": false,
"version_id": 1010270,
"version_string": "1.1.2",
"hash": "f5fed0a3a280a492e174885c4139b292"
},
"viewing_romhackplaza_drafts.txt": {
"global_cache": false,
"version_id": 1010270,
"version_string": "1.1.2",
"hash": "5fa6af4f4d92357c0702cb20a4723408"
},
"viewing_romhackplaza_edit.txt": {
"global_cache": false,
"version_id": 1010270,
"version_string": "1.1.2",
"hash": "3e9d8bab76d8ed750e1ebad609625ec3"
},
"viewing_romhackplaza_entry.txt": {
"global_cache": false,
"version_id": 1010270,
"version_string": "1.1.2",
"hash": "ddbf5cfda5b2f0fc93f9f6341cf9bba3"
},
"viewing_romhackplaza_news.txt": {
"global_cache": false,
"version_id": 1010270,
"version_string": "1.1.2",
"hash": "c978170b03d4f82db58b3e94649d1855"
},
"viewing_romhackplaza_play.txt": {
"global_cache": false,
"version_id": 1010270,
"version_string": "1.1.2",
"hash": "8b3437b63b894e8b6be5acf3949a0c6a"
},
"viewing_romhackplaza_reviews.txt": {
"global_cache": false,
"version_id": 1010270,
"version_string": "1.1.2",
"hash": "d45735f9e3a9b21520461e75df1eddf4"
},
"viewing_romhackplaza_submit.txt": {
"global_cache": false,
"version_id": 1010270,
"version_string": "1.1.2",
"hash": "0495b6c845b61f6d068d94895cf52fb2"
},
"viewing_romhackplaza_tools.txt": {
"global_cache": false,
"version_id": 1010270,
"version_string": "1.1.2",
"hash": "c9ad17b928695681b4752643360f4102"
} }
} }

View File

@@ -0,0 +1 @@
Viewing the website

View File

@@ -0,0 +1 @@
Viewing database

View File

@@ -0,0 +1 @@
Viewing drafts

View File

@@ -0,0 +1 @@
Edit an entry

View File

@@ -0,0 +1 @@
Viewing entry

View File

@@ -0,0 +1 @@
Viewing news

View File

@@ -0,0 +1 @@
Play online

View File

@@ -0,0 +1 @@
Viewing reviews

View File

@@ -0,0 +1 @@
Create an entry

View File

@@ -0,0 +1 @@
Use tools

View File

@@ -2,8 +2,8 @@
"legacy_addon_id": "", "legacy_addon_id": "",
"title": "RomhackPlaza Master Addon", "title": "RomhackPlaza Master Addon",
"description": "", "description": "",
"version_id": 1010170, "version_id": 1010270,
"version_string": "1.1.1", "version_string": "1.1.2",
"dev": "", "dev": "",
"dev_url": "", "dev_url": "",
"faq_url": "", "faq_url": "",