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