Files

76 lines
2.1 KiB
PHP
Raw Permalink Normal View History

2026-06-02 20:54:08 +02:00
<?php
namespace RomhackPlaza\Master\ApprovalQueue;
use XF\ApprovalQueue\AbstractHandler;
use XF\Mvc\Entity\Entity;
2026-06-08 16:25:52 +02:00
class Club extends AbstractHandler
2026-06-02 20:54:08 +02:00
{
protected function canViewContent(Entity $content, &$error = null)
{
return $this->canActionContent($content, $error);
}
protected function canActionContent(Entity $content, &$error = null)
{
return \XF::visitor()->hasAdminPermission('node');
}
public function getEntityWith()
{
return ['User'];
}
2026-06-08 16:25:52 +02:00
public function actionApprove(\RomhackPlaza\Master\Entity\Club $club)
2026-06-02 20:54:08 +02:00
{
2026-06-08 16:25:52 +02:00
$club->club_state = 'visible';
$club->save();
2026-06-02 20:54:08 +02:00
$node = \XF::em()->create('XF:Node');
$node->node_type_id = 'Forum';
2026-06-08 16:25:52 +02:00
$node->title = $club->title;
$node->description = $club->description;
2026-06-02 20:54:08 +02:00
$node->parent_node_id = \XF::options()->rhpz_club_node_id ?? 0;
$node->display_order = 1;
$node->save();
$forum = \XF::em()->create('XF:Forum');
$forum->node_id = $node->node_id;
$forum->allow_posting = true;
$forum->save();
2026-06-08 16:25:52 +02:00
$club->node_id = $node->node_id;
$club->save();
$user = $club->User;
2026-06-02 20:54:08 +02:00
if ($user) {
$modContent = \XF::em()->create('XF:ModeratorContent');
$modContent->content_type = 'node';
$modContent->content_id = $node->node_id;
$modContent->user_id = $user->user_id;
$modContent->save();
$permissionUpdater = \XF::app()->service('XF:UpdatePermissions');
$permissionUpdater->setContent('node', $node->node_id);
$permissionUpdater->setUser($user);
2026-06-08 16:25:52 +02:00
$permissionUpdater->updatePermissions(\RomhackPlaza\Master\Entity\Club::MOD_PERMISSIONS);
2026-06-02 20:54:08 +02:00
\XF::app()->jobManager()->enqueueUnique('permissionRebuild', 'XF:PermissionRebuild');
}
}
2026-06-08 16:25:52 +02:00
public function actionReject(\RomhackPlaza\Master\Entity\Club $club)
2026-06-02 20:54:08 +02:00
{
2026-06-08 16:25:52 +02:00
$club->club_state = 'rejected';
$club->save();
2026-06-02 20:54:08 +02:00
}
public function getTemplateName()
{
return 'public:approval_item_club_request';
}
}