From 8eb94ff05d07b9a82db691ae64e68d3128e76497 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 2 Jun 2026 20:54:38 +0200 Subject: [PATCH] Club System --- Entity/Entry.php | 28 +++++++ Helper/Laravel.php | 24 ++++++ Pub/Controller/Entry.php | 50 ++++++++++++ Report/Entry.php | 76 +++++++++++++++++++ ...er_RomhackPlaza-Master-XF-Entity-User.json | 6 ++ _output/class_extensions/_metadata.json | 5 ++ _output/content_type_fields/_metadata.json | 14 ++++ ..._request-approval_queue_handler_class.json | 5 ++ .../club_request-entity.json | 5 ++ .../romhackplaza_entry-entity.json | 5 ++ ...mhackplaza_entry-report_handler_class.json | 5 ++ _output/extension_hint.php | 14 ++++ _output/option_groups/_metadata.json | 5 ++ _output/option_groups/romhackplaza.json | 6 ++ _output/option_hint.php | 18 +++++ _output/options/_metadata.json | 5 ++ _output/options/rhpz_club_node_id.json | 13 ++++ .../romhackplaza-canEditMyEntries.json | 6 ++ .../romhackplaza-canEditOthersEntries.json | 6 ++ .../romhackplaza-canModerateEntries.json | 6 ++ .../romhackplaza-canSeeHiddenEntries.json | 6 ++ .../romhackplaza-canSeeLockedEntries.json | 6 ++ .../romhackplaza-canSeeOthersDrafts.json | 6 ++ .../romhackplaza-canSeeRejectedEntries.json | 6 ++ ...omhackplaza-canSubmitEntryInPublished.json | 6 ++ _output/phrases/option.rhpz_club_node_id.txt | 1 + .../option_explain.rhpz_club_node_id.txt | 0 _output/phrases/option_group.romhackplaza.txt | 1 + .../option_group_description.romhackplaza.txt | 0 ...rmission.romhackplaza_canEditMyEntries.txt | 1 + ...sion.romhackplaza_canEditOthersEntries.txt | 1 + ...ission.romhackplaza_canModerateEntries.txt | 1 + ...ssion.romhackplaza_canSeeHiddenEntries.txt | 1 + ...ssion.romhackplaza_canSeeLockedEntries.txt | 1 + ...ission.romhackplaza_canSeeOthersDrafts.txt | 1 + ...ion.romhackplaza_canSeeRejectedEntries.txt | 1 + ...romhackplaza_canSubmitEntryInPublished.txt | 1 + _output/routes/_metadata.json | 11 +++ _output/routes/api_romhackplaza_entry_.json | 11 +++ _output/routes/public_clubs_.json | 11 +++ .../routes/public_romhackplaza_entry_.json | 11 +++ .../public/approval_item_club_request.html | 11 +++ .../templates/public/club_request_form.html | 11 +++ .../report_content_romhackplaza_entry.html | 4 + 44 files changed, 412 insertions(+) create mode 100644 Entity/Entry.php create mode 100644 Helper/Laravel.php create mode 100644 Pub/Controller/Entry.php create mode 100644 Report/Entry.php create mode 100644 _output/class_extensions/XF-Entity-User_RomhackPlaza-Master-XF-Entity-User.json create mode 100644 _output/class_extensions/_metadata.json create mode 100644 _output/content_type_fields/_metadata.json create mode 100644 _output/content_type_fields/club_request-approval_queue_handler_class.json create mode 100644 _output/content_type_fields/club_request-entity.json create mode 100644 _output/content_type_fields/romhackplaza_entry-entity.json create mode 100644 _output/content_type_fields/romhackplaza_entry-report_handler_class.json create mode 100644 _output/extension_hint.php create mode 100644 _output/option_groups/_metadata.json create mode 100644 _output/option_groups/romhackplaza.json create mode 100644 _output/option_hint.php create mode 100644 _output/options/_metadata.json create mode 100644 _output/options/rhpz_club_node_id.json create mode 100644 _output/permissions/romhackplaza-canEditMyEntries.json create mode 100644 _output/permissions/romhackplaza-canEditOthersEntries.json create mode 100644 _output/permissions/romhackplaza-canModerateEntries.json create mode 100644 _output/permissions/romhackplaza-canSeeHiddenEntries.json create mode 100644 _output/permissions/romhackplaza-canSeeLockedEntries.json create mode 100644 _output/permissions/romhackplaza-canSeeOthersDrafts.json create mode 100644 _output/permissions/romhackplaza-canSeeRejectedEntries.json create mode 100644 _output/permissions/romhackplaza-canSubmitEntryInPublished.json create mode 100644 _output/phrases/option.rhpz_club_node_id.txt create mode 100644 _output/phrases/option_explain.rhpz_club_node_id.txt create mode 100644 _output/phrases/option_group.romhackplaza.txt create mode 100644 _output/phrases/option_group_description.romhackplaza.txt create mode 100644 _output/phrases/permission.romhackplaza_canEditMyEntries.txt create mode 100644 _output/phrases/permission.romhackplaza_canEditOthersEntries.txt create mode 100644 _output/phrases/permission.romhackplaza_canModerateEntries.txt create mode 100644 _output/phrases/permission.romhackplaza_canSeeHiddenEntries.txt create mode 100644 _output/phrases/permission.romhackplaza_canSeeLockedEntries.txt create mode 100644 _output/phrases/permission.romhackplaza_canSeeOthersDrafts.txt create mode 100644 _output/phrases/permission.romhackplaza_canSeeRejectedEntries.txt create mode 100644 _output/phrases/permission.romhackplaza_canSubmitEntryInPublished.txt create mode 100644 _output/routes/_metadata.json create mode 100644 _output/routes/api_romhackplaza_entry_.json create mode 100644 _output/routes/public_clubs_.json create mode 100644 _output/routes/public_romhackplaza_entry_.json create mode 100644 _output/templates/public/approval_item_club_request.html create mode 100644 _output/templates/public/club_request_form.html create mode 100644 _output/templates/public/report_content_romhackplaza_entry.html diff --git a/Entity/Entry.php b/Entity/Entry.php new file mode 100644 index 0000000..ef1091f --- /dev/null +++ b/Entity/Entry.php @@ -0,0 +1,28 @@ +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; + } +} \ No newline at end of file diff --git a/Helper/Laravel.php b/Helper/Laravel.php new file mode 100644 index 0000000..50cab2d --- /dev/null +++ b/Helper/Laravel.php @@ -0,0 +1,24 @@ +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']; + } +} \ No newline at end of file diff --git a/Pub/Controller/Entry.php b/Pub/Controller/Entry.php new file mode 100644 index 0000000..5a5139e --- /dev/null +++ b/Pub/Controller/Entry.php @@ -0,0 +1,50 @@ +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 + ); + + } +} \ No newline at end of file diff --git a/Report/Entry.php b/Report/Entry.php new file mode 100644 index 0000000..1b45027 --- /dev/null +++ b/Report/Entry.php @@ -0,0 +1,76 @@ +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"; + } +} \ No newline at end of file diff --git a/_output/class_extensions/XF-Entity-User_RomhackPlaza-Master-XF-Entity-User.json b/_output/class_extensions/XF-Entity-User_RomhackPlaza-Master-XF-Entity-User.json new file mode 100644 index 0000000..dbc58f0 --- /dev/null +++ b/_output/class_extensions/XF-Entity-User_RomhackPlaza-Master-XF-Entity-User.json @@ -0,0 +1,6 @@ +{ + "from_class": "XF\\Entity\\User", + "to_class": "RomhackPlaza\\Master\\XF\\Entity\\User", + "execute_order": 10, + "active": true +} \ No newline at end of file diff --git a/_output/class_extensions/_metadata.json b/_output/class_extensions/_metadata.json new file mode 100644 index 0000000..96c4b77 --- /dev/null +++ b/_output/class_extensions/_metadata.json @@ -0,0 +1,5 @@ +{ + "XF-Entity-User_RomhackPlaza-Master-XF-Entity-User.json": { + "hash": "811593d6f012a53b9fa2ced871de96a9" + } +} \ No newline at end of file diff --git a/_output/content_type_fields/_metadata.json b/_output/content_type_fields/_metadata.json new file mode 100644 index 0000000..102b3e5 --- /dev/null +++ b/_output/content_type_fields/_metadata.json @@ -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" + } +} \ No newline at end of file diff --git a/_output/content_type_fields/club_request-approval_queue_handler_class.json b/_output/content_type_fields/club_request-approval_queue_handler_class.json new file mode 100644 index 0000000..3aaaaf2 --- /dev/null +++ b/_output/content_type_fields/club_request-approval_queue_handler_class.json @@ -0,0 +1,5 @@ +{ + "content_type": "club_request", + "field_name": "approval_queue_handler_class", + "field_value": "RomhackPlaza\\Master\\ApprovalQueue\\ClubRequest" +} \ No newline at end of file diff --git a/_output/content_type_fields/club_request-entity.json b/_output/content_type_fields/club_request-entity.json new file mode 100644 index 0000000..17f5bcf --- /dev/null +++ b/_output/content_type_fields/club_request-entity.json @@ -0,0 +1,5 @@ +{ + "content_type": "club_request", + "field_name": "entity", + "field_value": "RomhackPlaza\\Master\\Entity\\ClubRequest" +} \ No newline at end of file diff --git a/_output/content_type_fields/romhackplaza_entry-entity.json b/_output/content_type_fields/romhackplaza_entry-entity.json new file mode 100644 index 0000000..91b1c6a --- /dev/null +++ b/_output/content_type_fields/romhackplaza_entry-entity.json @@ -0,0 +1,5 @@ +{ + "content_type": "romhackplaza_entry", + "field_name": "entity", + "field_value": "RomhackPlaza\\Master\\Entity\\Entry" +} \ No newline at end of file diff --git a/_output/content_type_fields/romhackplaza_entry-report_handler_class.json b/_output/content_type_fields/romhackplaza_entry-report_handler_class.json new file mode 100644 index 0000000..fc2967f --- /dev/null +++ b/_output/content_type_fields/romhackplaza_entry-report_handler_class.json @@ -0,0 +1,5 @@ +{ + "content_type": "romhackplaza_entry", + "field_name": "report_handler_class", + "field_value": "RomhackPlaza\\Master\\Report\\Entry" +} \ No newline at end of file diff --git a/_output/extension_hint.php b/_output/extension_hint.php new file mode 100644 index 0000000..ae897a0 --- /dev/null +++ b/_output/extension_hint.php @@ -0,0 +1,14 @@ +", + "build_class": "", + "build_method": "", + "controller": "RomhackPlaza\\Master:Entry", + "context": "", + "action_prefix": "" +} \ No newline at end of file diff --git a/_output/templates/public/approval_item_club_request.html b/_output/templates/public/approval_item_club_request.html new file mode 100644 index 0000000..ba30adb --- /dev/null +++ b/_output/templates/public/approval_item_club_request.html @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/_output/templates/public/club_request_form.html b/_output/templates/public/club_request_form.html new file mode 100644 index 0000000..8ecd903 --- /dev/null +++ b/_output/templates/public/club_request_form.html @@ -0,0 +1,11 @@ +Submit Club Request + + +
+
+ + +
+ +
+
\ No newline at end of file diff --git a/_output/templates/public/report_content_romhackplaza_entry.html b/_output/templates/public/report_content_romhackplaza_entry.html new file mode 100644 index 0000000..a3c44e4 --- /dev/null +++ b/_output/templates/public/report_content_romhackplaza_entry.html @@ -0,0 +1,4 @@ +
+ {{ phrase('content:') }} + {$report.content_info.description} +
\ No newline at end of file