Club System

This commit is contained in:
2026-06-02 20:54:38 +02:00
parent f4dc336c88
commit 8eb94ff05d
44 changed files with 412 additions and 0 deletions

28
Entity/Entry.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
namespace RomhackPlaza\Master\Entity;
use Override;
use XF\Mvc\Entity\Entity;
use XF\Mvc\Entity\Structure;
class Entry extends Entity
{
#[Override]
public static function getStructure(Structure $structure)
{
$structure->shortName = 'RomhackPlaza\Master:Entry';
$structure->table = 'xf_romhackplaza_entry'; // Unused.
$structure->primaryKey = 'id';
$structure->columns = [
'id' => ['type' => self::UINT],
'user_id' => ['type' => self::UINT, 'required' => true],
'title' => ['type' => self::STR, 'required' => true],
'slug' => ['type' => self::STR, 'required' => true],
'type' => ['type' => self::STR, 'required' => true],
];
return $structure;
}
}

24
Helper/Laravel.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
namespace RomhackPlaza\Master\Helper;
use XF\Container;
class Laravel
{
public static function db(): ?\XF\Db\Mysqli\Adapter {
$container = \XF::app()->container();
if( !isset( $container['laravelDb'] ) ){
$container['laravelDb'] = function(Container $c){
$config = \XF::config('sitedb');
if( !$config )
return null;
return new \XF\Db\Mysqli\Adapter($config, true);
};
}
return $container['laravelDb'];
}
}

50
Pub/Controller/Entry.php Normal file
View File

@@ -0,0 +1,50 @@
<?php
namespace RomhackPlaza\Master\Pub\Controller;
use XF\Mvc\ParameterBag;
use XF\Mvc\Reply\AbstractReply;
use XF\Pub\Controller\AbstractController;
class Entry 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, slug, type FROM entries WHERE id = ?", $entryId);
if( !$entry )
return $this->notFound();
return $this->redirect(\XF::options()->homePageUrl . '/' . $entry['type'] . '/' . $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, complete_title as title, slug, type, user_id, description FROM entries WHERE id = ?", $entryId);
if( !$entry )
return $this->notFound();
$entity = $this->em()->instantiateEntity('RomhackPlaza\Master:Entry', $entry);
$entity->setReadOnly(true);
$reportPlugin = $this->plugin('XF:Report');
return $reportPlugin->actionReport(
'romhackplaza_entry', $entity,
$this->buildLink('romhackplaza_entry/report', $entity),
\XF::options()->homePageUrl . '/entry/report_redirect?id=' . $entity->id
);
}
}

76
Report/Entry.php Normal file
View File

@@ -0,0 +1,76 @@
<?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";
}
}

View File

@@ -0,0 +1,6 @@
{
"from_class": "XF\\Entity\\User",
"to_class": "RomhackPlaza\\Master\\XF\\Entity\\User",
"execute_order": 10,
"active": true
}

View File

@@ -0,0 +1,5 @@
{
"XF-Entity-User_RomhackPlaza-Master-XF-Entity-User.json": {
"hash": "811593d6f012a53b9fa2ced871de96a9"
}
}

View File

@@ -0,0 +1,14 @@
{
"club_request-approval_queue_handler_class.json": {
"hash": "e46546c5b569b04e7ad740a672d217cd"
},
"club_request-entity.json": {
"hash": "547d2af8708a4c569b3b09fdd9308880"
},
"romhackplaza_entry-entity.json": {
"hash": "8686ffd261eb8c1698a3ec6e31118f02"
},
"romhackplaza_entry-report_handler_class.json": {
"hash": "3e3d009b1b4671a506accc2e920307b2"
}
}

View File

@@ -0,0 +1,5 @@
{
"content_type": "club_request",
"field_name": "approval_queue_handler_class",
"field_value": "RomhackPlaza\\Master\\ApprovalQueue\\ClubRequest"
}

View File

@@ -0,0 +1,5 @@
{
"content_type": "club_request",
"field_name": "entity",
"field_value": "RomhackPlaza\\Master\\Entity\\ClubRequest"
}

View File

@@ -0,0 +1,5 @@
{
"content_type": "romhackplaza_entry",
"field_name": "entity",
"field_value": "RomhackPlaza\\Master\\Entity\\Entry"
}

View File

@@ -0,0 +1,5 @@
{
"content_type": "romhackplaza_entry",
"field_name": "report_handler_class",
"field_value": "RomhackPlaza\\Master\\Report\\Entry"
}

View File

@@ -0,0 +1,14 @@
<?php
// ################## THIS IS A GENERATED FILE ##################
// DO NOT EDIT DIRECTLY. EDIT THE CLASS EXTENSIONS IN THE CONTROL PANEL.
/**
* @noinspection PhpIllegalPsrClassPathInspection
* @noinspection PhpMultipleClassesDeclarationsInOneFile
*/
namespace RomhackPlaza\Master\XF\Entity
{
class XFCP_User extends \XF\Entity\User {}
}

View File

@@ -0,0 +1,5 @@
{
"romhackplaza.json": {
"hash": "02d554f377cebf4d2532162b1c223e64"
}
}

View File

@@ -0,0 +1,6 @@
{
"icon": "",
"display_order": 500,
"advanced": false,
"debug_only": false
}

18
_output/option_hint.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
// ################## THIS IS A GENERATED FILE ##################
// DO NOT EDIT DIRECTLY. EDIT THE OPTIONS IN THE CONTROL PANEL.
/**
* @noinspection PhpMultipleClassDeclarationsInspection
* @noinspection PhpIllegalPsrClassPathInspection
*/
namespace XF;
/**
* @property non-negative-int|null $rhpz_club_node_id Club Parent Node ID
*/
class Options
{
}

View File

@@ -0,0 +1,5 @@
{
"rhpz_club_node_id.json": {
"hash": "96114ee498a669ab50a1bc32768d3969"
}
}

View File

@@ -0,0 +1,13 @@
{
"edit_format": "spinbox",
"edit_format_params": "",
"data_type": "unsigned_integer",
"sub_options": [],
"validation_class": "",
"validation_method": "",
"advanced": false,
"default_value": "0",
"relations": {
"romhackplaza": 1
}
}

View File

@@ -0,0 +1,6 @@
{
"permission_type": "flag",
"interface_group_id": "romhackplaza",
"display_order": 4,
"depend_permission_id": ""
}

View File

@@ -0,0 +1,6 @@
{
"permission_type": "flag",
"interface_group_id": "romhackplaza",
"display_order": 5,
"depend_permission_id": ""
}

View File

@@ -0,0 +1,6 @@
{
"permission_type": "flag",
"interface_group_id": "romhackplaza",
"display_order": 6,
"depend_permission_id": ""
}

View File

@@ -0,0 +1,6 @@
{
"permission_type": "flag",
"interface_group_id": "romhackplaza",
"display_order": 9,
"depend_permission_id": ""
}

View File

@@ -0,0 +1,6 @@
{
"permission_type": "flag",
"interface_group_id": "romhackplaza",
"display_order": 10,
"depend_permission_id": ""
}

View File

@@ -0,0 +1,6 @@
{
"permission_type": "flag",
"interface_group_id": "romhackplaza",
"display_order": 7,
"depend_permission_id": ""
}

View File

@@ -0,0 +1,6 @@
{
"permission_type": "flag",
"interface_group_id": "romhackplaza",
"display_order": 8,
"depend_permission_id": ""
}

View File

@@ -0,0 +1,6 @@
{
"permission_type": "flag",
"interface_group_id": "romhackplaza",
"display_order": 11,
"depend_permission_id": ""
}

View File

@@ -0,0 +1 @@
Club Parent Node ID

View File

@@ -0,0 +1 @@
RomhackPlaza Options

View File

@@ -0,0 +1 @@
Can Edit My Entries

View File

@@ -0,0 +1 @@
Can Edit Others Entries

View File

@@ -0,0 +1 @@
Can Moderate Entries

View File

@@ -0,0 +1 @@
Can See Hidden Entries

View File

@@ -0,0 +1 @@
Can See Locked Entries

View File

@@ -0,0 +1 @@
Can See Others Drafts

View File

@@ -0,0 +1 @@
Can See Rejected Entries

View File

@@ -0,0 +1 @@
Can Submit Entry in Published

View File

@@ -0,0 +1,11 @@
{
"api_romhackplaza_entry_.json": {
"hash": "5f1609f559980b44af09fd85c3b34a30"
},
"public_clubs_.json": {
"hash": "a10d34d7ce33cb577dc85906353d1bb2"
},
"public_romhackplaza_entry_.json": {
"hash": "2c40d7266fcc22a5727830a69af2360c"
}
}

View File

@@ -0,0 +1,11 @@
{
"route_type": "api",
"route_prefix": "romhackplaza_entry",
"sub_name": "",
"format": "",
"build_class": "",
"build_method": "",
"controller": "RomhackPlaza\\Master:Entry",
"context": "",
"action_prefix": ""
}

View File

@@ -0,0 +1,11 @@
{
"route_type": "public",
"route_prefix": "clubs",
"sub_name": "",
"format": "",
"build_class": "",
"build_method": "",
"controller": "RomhackPlaza\\Master:Club",
"context": "",
"action_prefix": ""
}

View File

@@ -0,0 +1,11 @@
{
"route_type": "public",
"route_prefix": "romhackplaza_entry",
"sub_name": "",
"format": ":int<id>",
"build_class": "",
"build_method": "",
"controller": "RomhackPlaza\\Master:Entry",
"context": "",
"action_prefix": ""
}

View File

@@ -0,0 +1,11 @@
<xf:macro id="approval_queue_macros::item_message_type"
arg-content="{$content}"
arg-user="{$content.User}"
arg-messageHtml="{$content.description}"
arg-contentDate="{$content.request_date}"
arg-typePhraseHtml="Club Request"
arg-headerPhrase="{$content.title}"
arg-spamDetails="{$spamDetails}"
arg-unapprovedItem="{$unapprovedItem}"
arg-handler="{$handler}"
/>

View File

@@ -0,0 +1,11 @@
<xf:title>Submit Club Request</xf:title>
<xf:form action="{{ link('clubs/save') }}" ajax="true" class="block">
<div class="block-container">
<div class="block-body">
<xf:textboxrow name="title" label="Title" required="required" />
<xf:textarearow name="description" label="Description" rows="4" required="required" />
</div>
<xf:submitrow submit="Submit" icon="save" />
</div>
</xf:form>

View File

@@ -0,0 +1,4 @@
<div class="block-row block-row--separated">
{{ phrase('content:') }}
{$report.content_info.description}
</div>