A lot of things.

This commit is contained in:
2026-06-08 16:25:52 +02:00
parent 8eb94ff05d
commit 4415a2e8c4
55 changed files with 995 additions and 163 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace RomhackPlaza\Master\Api\Controller;
use XF\Api\Controller\AbstractController;
use XF\ControllerPlugin\UndeletePlugin;
use XF\Entity\Thread;
use XF\Mvc\ParameterBag;
class ThreadController extends AbstractController
{
public function actionPost(ParameterBag $params)
{
$this->assertApiScope('thread:write');
/** @var Thread $thread */
$thread = $this->assertRecordExists('XF:Thread', $params->thread_id, ['FirstPost'] );
if( $thread->discussion_state !== 'deleted' )
return $this->error("This thread is not deleted.", 'not_deleted' );
if(!$thread->canUndelete($error)){
return $this->noPermission($error);
}
$thread->discussion_state = 'visible';
$thread->save();
return $this->apiSuccess([
'thread' => $thread->toApiResult()
]);
}
}

View File

@@ -5,7 +5,7 @@ namespace RomhackPlaza\Master\ApprovalQueue;
use XF\ApprovalQueue\AbstractHandler;
use XF\Mvc\Entity\Entity;
class ClubRequest extends AbstractHandler
class Club extends AbstractHandler
{
protected function canViewContent(Entity $content, &$error = null)
@@ -23,15 +23,15 @@ class ClubRequest extends AbstractHandler
return ['User'];
}
public function actionApprove(\RomhackPlaza\Master\Entity\ClubRequest $clubRequest)
public function actionApprove(\RomhackPlaza\Master\Entity\Club $club)
{
$clubRequest->request_state = 'visible';
$clubRequest->save();
$club->club_state = 'visible';
$club->save();
$node = \XF::em()->create('XF:Node');
$node->node_type_id = 'Forum';
$node->title = $clubRequest->title;
$node->description = $clubRequest->description;
$node->title = $club->title;
$node->description = $club->description;
$node->parent_node_id = \XF::options()->rhpz_club_node_id ?? 0;
$node->display_order = 1;
$node->save();
@@ -41,7 +41,10 @@ class ClubRequest extends AbstractHandler
$forum->allow_posting = true;
$forum->save();
$user = $clubRequest->User;
$club->node_id = $node->node_id;
$club->save();
$user = $club->User;
if ($user) {
$modContent = \XF::em()->create('XF:ModeratorContent');
@@ -54,26 +57,16 @@ class ClubRequest extends AbstractHandler
$permissionUpdater->setContent('node', $node->node_id);
$permissionUpdater->setUser($user);
$permissionUpdater->updatePermissions([
'forum' => [
'editAnyPost' => 'content_allow',
'deleteAnyPost' => 'content_allow',
'deleteAnyThread' => 'content_allow',
'inlineMod' => 'content_allow',
'lockUnlockThread' => 'content_allow',
'stickUnstickThread' => 'content_allow'
]
]);
$permissionUpdater->updatePermissions(\RomhackPlaza\Master\Entity\Club::MOD_PERMISSIONS);
// D. Reconstruction des permissions
\XF::app()->jobManager()->enqueueUnique('permissionRebuild', 'XF:PermissionRebuild');
}
}
public function actionReject(\RomhackPlaza\Master\Entity\ClubRequest $clubRequest)
public function actionReject(\RomhackPlaza\Master\Entity\Club $club)
{
$clubRequest->request_state = 'rejected';
$clubRequest->save();
$club->club_state = 'rejected';
$club->save();
}
public function getTemplateName()

120
Entity/Club.php Normal file
View File

@@ -0,0 +1,120 @@
<?php
namespace RomhackPlaza\Master\Entity;
use XF\Entity\ApprovalQueue;
use XF\Entity\Forum;
use XF\Mvc\Entity\Entity;
use XF\Mvc\Entity\Structure;
/**
* @property-read int club_id
* @property int node_id
* @property int user_id
* @property string title
* @property string description
* @property string club_state
* @property int club_date
* @property int banner_date
* @property ?Forum Forum
*/
class Club extends Entity
{
/**
*
*/
public const array MOD_PERMISSIONS = [
'forum' => [
'editAnyPost' => 'content_allow',
'deleteAnyPost' => 'content_allow',
'deleteAnyThread' => 'content_allow',
'inlineMod' => 'content_allow',
'lockUnlockThread' => 'content_allow',
'stickUnstickThread' => 'content_allow'
]
];
public static function getStructure(Structure $structure): Structure
{
$structure->table = 'xf_club';
$structure->shortName = 'RomhackPlaza\Master:Club';
$structure->primaryKey = 'club_id';
$structure->columns = [
'club_id' => ['type' => self::UINT, 'autoIncrement' => true],
'node_id' => ['type' => self::UINT, 'default' => 0],
'user_id' => ['type' => self::UINT, 'required' => true],
'title' => ['type' => self::STR, 'maxLength' => 100, 'required' => true],
'description' => ['type' => self::STR, 'required' => true],
'club_state' => ['type' => self::STR, 'default' => 'moderated',
'allowedValues' => ['visible', 'moderated', 'rejected']
],
'club_creation_date' => ['type' => self::UINT, 'default' => \XF::$time],
'banner_date' => ['type' => self::UINT, 'default' => 0],
];
$structure->relations = [
'User' => [
'entity' => 'XF:User',
'type' => self::TO_ONE,
'conditions' => 'user_id',
'primary' => true
],
'Forum' => [
'entity' => 'XF:Forum',
'type' => self::TO_ONE,
'conditions' => 'node_id',
'primary' => true
]
];
return $structure;
}
public function getBannerUrl(): ?string
{
if( !$this->banner_date )
return null;
return \XF::app()->applyExternalDataUrl("club_banners/{$this->club_id}.jpg?{$this->banner_date}");
}
protected function _postSave()
{
if( $this->isInsert() && $this->club_state == 'moderated' ){
$this->inQueue();
} else if( $this->isUpdate() && $this->isChanged('club_state') ){
if( $this->club_state === 'moderated' ){
$this->inQueue();
} else {
$this->removeQueue();
}
}
}
protected function _postDelete()
{
if( $this->club_state === 'moderated' ){
$this->removeQueue();
}
}
protected function inQueue()
{
$queue = $this->em()->find('XF:ApprovalQueue', ['club', $this->club_id ] );
if( !$queue )
{
/** @var ApprovalQueue $newQueue */
$newQueue = $this->em()->create('XF:ApprovalQueue');
$newQueue->content_type = 'club';
$newQueue->content_id = $this->club_id;
$newQueue->save();
}
}
protected function removeQueue()
{
$queue = $this->em()->find('XF:ApprovalQueue', ['club', $this->club_id ] );
if( $queue )
$queue->delete();
}
}

View File

@@ -1,75 +0,0 @@
<?php
namespace RomhackPlaza\Master\Entity;
use XF\Mvc\Entity\Entity;
use XF\Mvc\Entity\Structure;
class ClubRequest extends Entity
{
public static function getStructure(Structure $structure): Structure
{
$structure->table = 'xf_club_request';
$structure->shortName = 'RomhackPlaza\Master:ClubRequest';
$structure->primaryKey = 'request_id';
$structure->columns = [
'request_id' => ['type' => self::UINT, 'autoIncrement' => true],
'user_id' => ['type' => self::UINT, 'required' => true],
'title' => ['type' => self::STR, 'maxLength' => 100, 'required' => true],
'description' => ['type' => self::STR, 'required' => true],
'request_state' => ['type' => self::STR, 'default' => 'moderated',
'allowedValues' => ['visible', 'moderated', 'rejected']
],
'request_date' => ['type' => self::UINT, 'default' => \XF::$time]
];
$structure->relations = [
'User' => [
'entity' => 'XF:User',
'type' => self::TO_ONE,
'conditions' => 'user_id',
'primary' => true
]
];
return $structure;
}
protected function _postSave()
{
if( $this->isInsert() && $this->request_state == 'moderated' ){
$this->inQueue();
} else if( $this->isUpdate() && $this->isChanged('request_state') ){
if( $this->request_state === 'moderated' ){
$this->inQueue();
} else {
$this->removeQueue();
}
}
}
protected function _postDelete()
{
if( $this->request_state === 'moderated' ){
$this->removeQueue();
}
}
protected function inQueue()
{
$queue = $this->em()->find('XF:ApprovalQueue', ['club_request', $this->request_id ] );
if( !$queue )
{
$newQueue = $this->em()->create('XF:ApprovalQueue');
$newQueue->content_type = 'club_request';
$newQueue->content_id = $this->request_id;
$newQueue->save();
}
}
protected function removeQueue()
{
$queue = $this->em()->find('XF:ApprovalQueue', ['club_request', $this->request_id ] );
if( $queue )
$queue->delete();
}
}

View File

@@ -2,12 +2,23 @@
namespace RomhackPlaza\Master\Pub\Controller;
use PhpParser\Node\Param;
use RomhackPlaza\Master\Service\Club\CreatorService;
use RomhackPlaza\Master\Service\Club\DeleterService;
use RomhackPlaza\Master\Service\Club\EditorService;
use RomhackPlaza\Master\Service\Club\ModeratorService;
use XF\Mvc\ParameterBag;
use XF\Pub\Controller\AbstractController;
use XF\Util\File;
class Club extends AbstractController
{
public function actionIndex(){
$clubsForum = \XF::options()->rhpz_club_node_id;
return $this->redirect('categories/.' . $clubsForum );
}
public function actionSubmit(ParameterBag $params)
{
$this->assertRegistrationRequired();
@@ -15,18 +26,157 @@ class Club extends AbstractController
return $this->view('RomhackPlaza\Master:Club\Request', 'club_request_form');
}
public function actionEdit(ParameterBag $params)
{
$this->assertRegistrationRequired();
if( !$params->club_id )
$this->notFound("Club not found");
/** @var \RomhackPlaza\Master\Entity\Club $club */
$club = $this->assertRecordExists( 'RomhackPlaza\Master:Club', $params->club_id );
if( $club->user_id !== \XF::visitor()->user_id && !\XF::visitor()->hasAdminPermission('node') ){
$this->noPermission();
}
$mods = [];
$modsCount = 0;
if( $club->node_id ){
$mods = $this->finder('XF:ModeratorContent')
->where('content_type', 'node')
->where('content_id', $club->node_id)
->with('User')
->fetch();
foreach( $mods as $m ){
if( $m->user_id !== $club->user_id ){
$modsCount++;
}
}
}
return $this->view('RomhackPlaza\Master:Club\Edit', 'club_edit_form', [ 'club' => $club, 'moderators' => $mods, 'subModCount' => $modsCount ] );
}
public function actionSave(ParameterBag $params)
{
$this->assertRegistrationRequired();
$this->assertPostOnly();
$entity = $this->em()->create('RomhackPlaza\Master:ClubRequest');
$entity->user_id = \XF::visitor()->user_id;
$entity->title = $this->filter('title','str');
$entity->description = $this->filter('description','str');
$entity->request_state = 'moderated';
$entity->save();
$isEdit = (bool) $params->club_id;
if( $isEdit ){
$club = $this->assertRecordExists('RomhackPlaza\Master:Club', $params->club_id );
if( $club->user_id !== \XF::visitor()->user_id && !\XF::visitor()->hasAdminPermission('node') ){
$this->noPermission();
}
/** @var EditorService $editor */
$editor = $this->service('RomhackPlaza\Master:Club\Editor', $club);
$editor->setContent($this->filter('title','str'), $this->filter('description','str'));
$editor->setBannerUpload($this->request->getFile('upload_banner', false, false) );
if( !$editor->validate($errors) ){
return $this->error($errors);
}
$editor->save();
return $this->redirect( $this->buildLink('clubs'), "Changes saved successfully" );
} else {
/** @var CreatorService $creator */
$creator = $this->service('RomhackPlaza\Master:Club\Creator', \XF::visitor());
$creator->setContent($this->filter('title','str'), $this->filter('description','str'));
$creator->setBannerUpload($this->request->getFile('upload_banner', false, false));
if( !$creator->validate($errors) ){
return $this->error($errors);
}
$creator->save();
return $this->redirect( $this->buildLink('clubs'), "Your club creation request has been submitted and is awaiting approval by a staff member." );
}
}
public function actionDelete(ParameterBag $params)
{
$this->assertRegistrationRequired();
/** @var \RomhackPlaza\Master\Entity\Club $club */
$club = $this->assertRecordExists('RomhackPlaza\Master:Club', $params->club_id);
if( $club->user_id !== \XF::visitor()->user_id && !\XF::visitor()->hasAdminPermission('node') ){
$this->noPermission();
}
if( $this->isPost() ){
/** @var DeleterService $deleter */
$deleter = $this->service('RomhackPlaza\Master:Club\Deleter', $club);
$deleter->delete();
return $this->redirect( $this->buildLink('clubs'), "Club deleted successfully." );
}
return $this->view('RomhackPlaza\Master:Club\Delete', 'club_delete_confirm', [ 'club' => $club ] );
}
public function actionAddModerator(ParameterBag $params)
{
$this->assertRegistrationRequired();
$this->assertPostOnly();
/** @var \RomhackPlaza\Master\Entity\Club $club */
$club = $this->assertRecordExists('RomhackPlaza\Master:Club', $params->club_id);
if( $club->user_id !== \XF::visitor()->user_id && !\XF::visitor()->hasAdminPermission('node') ){
return $this->noPermission();
}
$username = $this->filter('username','str');
$user = $this->em()->findOne('XF:User', ['username' => $username]);
if( !$user ){
return $this->error("This user doesn't exist");
}
/** @var ModeratorService $modManage */
$modManage = \XF::app()->service('RomhackPlaza\Master:Club\Moderator', $club, $user );
$error = "";
$modManage->addModerator( $error );
if( $error && $error !== "" ){
return $this->error($error);
}
return $this->redirect( $this->buildLink('clubs/edit', $club), "Moderator added successfully." );
}
public function actionRemoveModerator(ParameterBag $params)
{
$this->assertRegistrationRequired();
$this->assertPostOnly();
/** @var \RomhackPlaza\Master\Entity\Club $club */
$club = $this->assertRecordExists('RomhackPlaza\Master:Club', $params->club_id);
if( $club->user_id !== \XF::visitor()->user_id && !\XF::visitor()->hasAdminPermission('node') ){
$this->noPermission();
}
$userId = $this->filter('user_id','uint');
$user = $this->em()->findOne('XF:User', ['user_id' => $userId]);
if( !$user ){
$this->error("This user doesn't exist");
}
/** @var ModeratorService $modManage */
$modManage = \XF::app()->service('RomhackPlaza\Master:Club\Moderator', $club, $user );
$error = "";
$modManage->deleteModerator( $error );
if( $error && $error !== "" ){
return $this->error($error);
}
return $this->redirect( $this->buildLink('clubs/edit', $club), "Moderator deleted successfully." );
}
}

View File

@@ -0,0 +1,64 @@
<?php
namespace RomhackPlaza\Master\Service\Club;
use RomhackPlaza\Master\Entity\Club;
use XF\App;
use XF\Entity\Forum;
use XF\Entity\Node;
use XF\Service\AbstractService;
use XF\Util\File;
class ApproverService extends AbstractService
{
/**
* @var Club
*/
protected $club;
public function __construct(App $app, Club $club)
{
parent::__construct($app);
$this->club = $club;
}
public function approve(): bool
{
if( $this->club->club_state !== 'moderated' ) {
return false;
}
$this->club->club_state = 'visible';
$this->club->save();
/** @var Node $node */
$node = $this->em()->create('XF:Node');
$node->node_type_id = 'Forum';
$node->title = $this->club->title;
$node->description = $this->club->description;
$node->parent_node_id = \XF::options()->rhpz_club_node_id ?? 0;
$node->display_order = 1;
$node->save();
/** @var Forum $forum */
$forum = $this->em()->create('XF:Forum');
$forum->node_id = $node->node_id;
$forum->allow_posting = true;
$forum->save();
$this->club->node_id = $node->node_id;
$this->club->save();
$user = $this->club->User;
if( $user ){
/** @var ModeratorService $modManage */
$modManage = \XF::app()->service('RomhackPlaza\Master:Club\Moderator', $this->club, $user );
$modManage->addModerator( $error );
}
return true;
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace RomhackPlaza\Master\Service\Club;
use RomhackPlaza\Master\Entity\Club;
use RomhackPlaza\Master\XF\Entity\Forum;
use XF\App;
use XF\Entity\Node;
use XF\Entity\User;
use XF\Http\Upload;
use XF\Service\AbstractService;
use XF\Service\ValidateAndSavableTrait;
use XF\Util\File;
class CreatorService extends AbstractService
{
use ValidateAndSavableTrait;
/**
* @var Club
*/
protected $club;
/**
* @var Upload
*/
protected $bannerUpload;
/**
* @var User
*/
protected $user;
public function __construct(App $app, User $creator)
{
parent::__construct($app);
$this->club = $this->em()->create('RomhackPlaza\Master:Club');
$this->setUser($creator);
$this->setupDefaults();
}
protected function setupDefaults()
{
$this->club->club_state = 'moderated';
}
public function getClub()
{
return $this->club;
}
public function getUser()
{
return $this->user;
}
public function setUser(User $user)
{
$this->user = $user;
$this->club->user_id = $this->user->user_id;
}
public function setContent(string $title, string $description )
{
$this->club->title = $title;
$this->club->description = $description;
}
public function setBannerUpload(?Upload $upload = null)
{
if ($upload) {
$upload->requireImage();
if($upload->isValid()){
$this->bannerUpload = $upload;
}
}
}
protected function _validate()
{
$this->club->preSave();
return $this->club->getErrors();
}
protected function _save()
{
$this->club->save();
if( $this->bannerUpload ){
$path = 'data://club_banners/' . $this->club->club_id . '.jpg';
if( File::copyFileToAbstractedPath($this->bannerUpload->getFileWrapper()->getFilePath(), $path) ){
$this->club->banner_date = \XF::$time;
$this->club->save();
}
}
return $this->club;
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace RomhackPlaza\Master\Service\Club;
use RomhackPlaza\Master\Entity\Club;
use XF\App;
use XF\Entity\Forum;
use XF\Entity\Node;
use XF\Http\Upload;
use XF\Service\AbstractService;
use XF\Service\ValidateAndSavableTrait;
use XF\Util\File;
class DeleterService extends AbstractService
{
/**
* @var Club
*/
protected $club;
public function __construct(App $app, Club $club)
{
parent::__construct($app);
$this->club = $club;
}
public function delete()
{
if( $this->club->Forum && $this->club->Forum->Node ){
$this->club->Forum->Node->delete();
}
$path = 'data://club_banners/' . $this->club->club_id . '.jpg';
File::deleteFromAbstractedPath($path);
$this->club->delete();
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace RomhackPlaza\Master\Service\Club;
use RomhackPlaza\Master\Entity\Club;
use XF\App;
use XF\Entity\Forum;
use XF\Entity\Node;
use XF\Http\Upload;
use XF\Service\AbstractService;
use XF\Service\ValidateAndSavableTrait;
use XF\Util\File;
class EditorService extends AbstractService
{
use ValidateAndSavableTrait;
/**
* @var Club
*/
protected $club;
public function __construct(App $app, Club $club)
{
parent::__construct($app);
$this->club = $club;
}
public function setContent(string $title, string $description)
{
$this->club->title = $title;
$this->club->description = $description;
}
public function setBannerUpload(?Upload $upload = null)
{
if( $upload ){
$upload->requireImage();
if( $upload->isValid() ){
$path = 'data://club_banners/' . $this->club->club_id . '.jpg';
if(File::copyFileToAbstractedPath($upload->getFileWrapper()->getFilePath(), $path)){
$this->club->banner_date = \XF::$time;
}
}
}
}
protected function syncForumNode()
{
if( $this->club->Forum && $this->club->Forum->Node )
{
$node = $this->club->Forum->Node;
$node->title = $this->club->title;
$node->description = $this->club->description;
$node->save();
}
}
protected function _validate()
{
$this->club->preSave();
return $this->club->getErrors();
}
protected function _save()
{
$this->club->save();
$this->syncForumNode();
return $this->club;
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace RomhackPlaza\Master\Service\Club;
use RomhackPlaza\Master\Entity\Club;
use XF\App;
use XF\Entity\User;
use XF\Service\AbstractService;
class ModeratorService extends AbstractService
{
public const int MAX_MODS = 5;
/**
* @var Club
*/
protected $club;
/**
* @var User
*/
protected $user;
public function __construct(App $app, Club $club, User $moderator)
{
parent::__construct($app);
$this->club = $club;
$this->user = $moderator;
}
protected function countMods( int $nodeId, int $excludeUserId = 0 )
{
return $this->finder('XF:ModeratorContent')
->where('content_type', 'node')
->where('content_id', $nodeId)
->where('user_id', '!=', $excludeUserId)
->total();
}
public function addModerator( string &$error ): bool
{
if( !$this->club->Forum || !$this->club->Forum->Node ) {
$error = "No node linked to this club.";
return false;
}
if( $this->countMods( $this->club->node_id, $this->club->user_id ) > self::MAX_MODS ) {
$error = "The limit of 5 moderators has been reached.";
return false;
}
$existingMod = $this->em()->findOne('XF:ModeratorContent', [
'content_type' => 'node',
'content_id' => $this->club->node_id,
'user_id' => $this->user->user_id
]);
if( $existingMod ){
$error = "This user is already a moderator.";
return false;
}
$modContent = $this->em()->create('XF:ModeratorContent');
$modContent->content_type = 'node';
$modContent->content_id = $this->club->node_id;
$modContent->user_id = $this->user->user_id;
$modContent->save();
$permissionUpdater = \XF::app()->service('XF:UpdatePermissions');
$permissionUpdater->setContent('node', $this->club->node_id);
$permissionUpdater->setUser($this->user);
$permissionUpdater->updatePermissions(Club::MOD_PERMISSIONS);
\XF::app()->jobManager()->enqueueUnique('permissionRebuild', 'XF:PermissionRebuild');
return true;
}
public function deleteModerator( string &$error ): bool
{
if( !$this->club->Forum || !$this->club->Forum->Node ) {
$error = "No node linked to this club.";
return false;
}
if( $this->user->user_id === $this->club->user_id ){
$error = "You cannot delete yourself.";
return false;
}
$mod = $this->em()->findOne('XF:ModeratorContent', [
'content_type' => 'node',
'content_id' => $this->club->node_id,
'user_id' => $this->user->user_id
]);
if( $mod ){
$mod->delete();
\XF::db()->delete('xf_permission_entry_content', 'content_type = ? AND content_id = ? AND user_id = ?', ['node', $this->club->node_id, $this->user->user_id]);
\XF::app()->jobManager()->enqueueUnique('permissionRebuild', 'XF:PermissionRebuild');
}
return true;
}
}

View File

@@ -25,19 +25,22 @@ class Setup extends AbstractSetup
}
/**
* Create club request table.
* Create club table.
* @return void
*/
public function installStep2(): void
{
$this->schemaManager()->createTable('xf_club_request', function(Create $table){
$table->addColumn('request_id', 'int')->autoIncrement();
$this->schemaManager()->createTable('xf_club', function(Create $table){
$table->addColumn('club_id', 'int')->autoIncrement();
$table->addColumn( 'node_id', 'int' );
$table->addColumn('user_id', 'int');
$table->addColumn('title', 'varchar', 100);
$table->addColumn('description', 'text');
$table->addColumn('request_state', 'enum')->values(['visible','moderated','rejected'])->setDefault('moderated');
$table->addColumn('request_date','int');
$table->addKey('request_state');
$table->addColumn('club_state', 'enum')->values(['visible','moderated','rejected'])->setDefault('moderated');
$table->addColumn('club_creation_date','int');
$table->addColumn('banner_date', 'int')->setDefault(0);
$table->addPrimaryKey('club_id');
$table->addKey('club_state');
});
}
@@ -50,6 +53,6 @@ class Setup extends AbstractSetup
public function uninstallStep2(): void
{
$this->schemaManager()->dropTable('xf_club_request');
$this->schemaManager()->dropTable('xf_club');
}
}

22
XF/Entity/Forum.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
namespace RomhackPlaza\Master\XF\Entity;
use XF\Mvc\Entity\Structure;
class Forum extends XFCP_Forum
{
public static function getStructure(Structure $structure)
{
$structure = parent::getStructure($structure);
$structure->relations['Club'] = [
'entity' => 'RomhackPlaza\Master:Club',
'type' => self::TO_ONE,
'conditions' => 'node_id',
'primary' => false
];
return $structure;
}
}

View File

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

View File

@@ -1,4 +1,7 @@
{
"XF-Entity-Forum_RomhackPlaza-Master-XF-Entity-Forum.json": {
"hash": "c7747b6ea6bd924d2d02e82917ff0df3"
},
"XF-Entity-User_RomhackPlaza-Master-XF-Entity-User.json": {
"hash": "811593d6f012a53b9fa2ced871de96a9"
}

View File

@@ -1,9 +1,9 @@
{
"club_request-approval_queue_handler_class.json": {
"hash": "e46546c5b569b04e7ad740a672d217cd"
"club-approval_queue_handler_class.json": {
"hash": "468464999ab50b9de400a6eae27625ac"
},
"club_request-entity.json": {
"hash": "547d2af8708a4c569b3b09fdd9308880"
"club-entity.json": {
"hash": "ed572323131987e295051165e4ec3c5e"
},
"romhackplaza_entry-entity.json": {
"hash": "8686ffd261eb8c1698a3ec6e31118f02"

View File

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

View File

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

View File

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

View File

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

View File

@@ -10,5 +10,6 @@
namespace RomhackPlaza\Master\XF\Entity
{
class XFCP_Forum extends \XF\Entity\Forum {}
class XFCP_User extends \XF\Entity\User {}
}

View File

@@ -1,53 +1,59 @@
{
"about.json": {
"hash": "96e3aa134dd14f5d43ca9ca1d5c55113"
"hash": "362cdca71eb4d21d7b9290ffc8f0df57"
},
"clubs.json": {
"hash": "e7ddced6269072f7db774f09424d671c"
},
"community.json": {
"hash": "bddec05ee1acb9cb82ed72155bdd7817"
"hash": "b3b5bb7146a8eb66e2830c48c4714456"
},
"contact_us.json": {
"hash": "05d205aee6ac1db9d9ad0f68bdd4f7c2"
"hash": "59453e1b06c296c777987d0fae0eb3a5"
},
"database.json": {
"hash": "7b42b608fad8ab23417a8cc3fcd331c2"
"hash": "604cabbdf4fb4fd941dc6123eb119165"
},
"discord.json": {
"hash": "d20860e95b3f4a96622733ef9ef4cfa0"
"hash": "37b3a139a26e30bd558de47b9e364d41"
},
"drafts.json": {
"hash": "bea14e944290aeb07659374fa487d61c"
},
"forum.json": {
"hash": "4a2e65ba6b553ed68dd5b6f7fd6d71d8"
"hash": "ca20fad278aeab93ccbc3c3a20a743d2"
},
"home.json": {
"hash": "6bf83f1a17528a3c075addfbc8fca830"
"hash": "4f55ee2e4a49e82c18e9beab428ab0ee"
},
"learn_romhacking.json": {
"hash": "dc98809d9e310f450123400bf106d2e5"
"hash": "3da66fadac2c1aa805e639d727e36223"
},
"legal_pages.json": {
"hash": "d379ad33a85a4387888d90fd75380b8a"
"hash": "34ae35915e620f1f0b5d88dcd25a5b59"
},
"members.json": {
"hash": "d625548b0c17df789d595691931732a3"
"hash": "cad1568d161bea1a7dd1f286b8788e2d"
},
"pages.json": {
"hash": "fe3fa7929ab20e981dd2f03d6d81f5d2"
"hash": "8d75bf99b2fb6528f84433f4519d4da3"
},
"rom_checker.json": {
"hash": "d23131981318ff9afa142b6512225cc3"
"hash": "c9349db6120520e82d02b793a30e67ce"
},
"rom_hasher.json": {
"hash": "5f7ab5a76ff0060ac7854ca2c53ea245"
"hash": "e14613a1bd0f1e1fadc084a009801570"
},
"rom_patcher.json": {
"hash": "73fab3932646c350da9a40102f650d9d"
"hash": "2a2af404aa6395b02c711867a7287a6f"
},
"submissions_queue.json": {
"hash": "84060a775af4419d44c8dc2c083ef447"
"hash": "071c745afd8f28cf9505702496f72a18"
},
"tools.json": {
"hash": "0221bb27d36511c5dd1feaf697626778"
"hash": "3d56ca10d6cf3ff772e9ce92d200f2f8"
},
"website.json": {
"hash": "e2f7d3d0102894eb09ecb359712d0fed"
"hash": "9ca169f049cffa2cf82f395617e2b897"
}
}

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "pages",
"display_order": 2,
"display_order": 200,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}/pages/about",

View File

@@ -0,0 +1,13 @@
{
"parent_navigation_id": "community",
"display_order": 200,
"navigation_type_id": "basic",
"type_config": {
"link": "{{ link('clubs') }}",
"display_condition": "",
"extra_attributes": {
"icon": "balloon"
}
},
"enabled": true
}

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "",
"display_order": 50,
"display_order": 300,
"navigation_type_id": "basic",
"type_config": {
"link": "",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "pages",
"display_order": 3,
"display_order": 300,
"navigation_type_id": "basic",
"type_config": {
"link": "{{ link('misc/contact') }}",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "website",
"display_order": 2,
"display_order": 200,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}/database",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "community",
"display_order": 2,
"display_order": 300,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}/discord",

View File

@@ -0,0 +1,13 @@
{
"parent_navigation_id": "website",
"display_order": 400,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}/my-drafts",
"display_condition": "{$xf.visitor.user_id}",
"extra_attributes": {
"icon": "scissors"
}
},
"enabled": true
}

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "community",
"display_order": 1,
"display_order": 100,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.boardUrl}",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "website",
"display_order": 1,
"display_order": 100,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "pages",
"display_order": 1,
"display_order": 100,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}/pages/learn",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "pages",
"display_order": 4,
"display_order": 400,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}/pages/legal-pages",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "community",
"display_order": 3,
"display_order": 400,
"navigation_type_id": "basic",
"type_config": {
"link": "{{ link('members') }}",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "",
"display_order": 150,
"display_order": 500,
"navigation_type_id": "basic",
"type_config": {
"link": "",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "tools",
"display_order": 3,
"display_order": 300,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}/tools/rom-checker",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "tools",
"display_order": 2,
"display_order": 200,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}/tools/rom-hasher",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "tools",
"display_order": 1,
"display_order": 100,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}/tools/rom-patcher",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "website",
"display_order": 3,
"display_order": 300,
"navigation_type_id": "basic",
"type_config": {
"link": "{$xf.options.homePageUrl}/queue",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "",
"display_order": 100,
"display_order": 400,
"navigation_type_id": "basic",
"type_config": {
"link": "",

View File

@@ -1,6 +1,6 @@
{
"parent_navigation_id": "",
"display_order": 1,
"display_order": 200,
"navigation_type_id": "basic",
"type_config": {
"link": "",

View File

@@ -5,6 +5,12 @@
"version_string": "1.0.0",
"hash": "8f7f4c1ce7a4f933663d10543562b096"
},
"nav.clubs.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "bc56e1ae1e30e7123ffc5030f108f2a0"
},
"nav.community.txt": {
"global_cache": false,
"version_id": 1000000,
@@ -29,6 +35,12 @@
"version_string": "1.0.0",
"hash": "8f5cc6430613f1c12f36965050bb7197"
},
"nav.drafts.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "bc67af65fab4a8b1848ccedf29c3b733"
},
"nav.forum.txt": {
"global_cache": false,
"version_id": 1000000,

View File

@@ -0,0 +1 @@
Clubs

View File

@@ -0,0 +1 @@
My drafts

View File

@@ -2,8 +2,11 @@
"api_romhackplaza_entry_.json": {
"hash": "5f1609f559980b44af09fd85c3b34a30"
},
"api_threads_undelete.json": {
"hash": "3376251e185807693e0fb7dc6dcc9ee0"
},
"public_clubs_.json": {
"hash": "a10d34d7ce33cb577dc85906353d1bb2"
"hash": "4fbb4a364e108ff5b30dfd57692205aa"
},
"public_romhackplaza_entry_.json": {
"hash": "2c40d7266fcc22a5727830a69af2360c"

View File

@@ -0,0 +1,11 @@
{
"route_type": "api",
"route_prefix": "threads",
"sub_name": "undelete",
"format": ":int<thread_id>/undelete",
"build_class": "",
"build_method": "",
"controller": "RomhackPlaza\\Master:Thread",
"context": "",
"action_prefix": ""
}

View File

@@ -2,7 +2,7 @@
"route_type": "public",
"route_prefix": "clubs",
"sub_name": "",
"format": "",
"format": ":int<club_id>/",
"build_class": "",
"build_method": "",
"controller": "RomhackPlaza\\Master:Club",

View File

@@ -0,0 +1,11 @@
{
"public/rhpz_above_thread_list_clubs.json": {
"hash": "c261ea6e33cf5eb7ab0a7f6fe934de7c"
},
"public/rhpz_above_thread_list_clubs_buttons.json": {
"hash": "c783001e00f7a63389c9ae988012f5fe"
},
"public/rhpz_category_view_clubs_submit_button.json": {
"hash": "a24a5a4b130b6198de7ef37610aa1a7d"
}
}

View File

@@ -0,0 +1,9 @@
{
"template": "forum_view",
"description": "Add the club banner above the threads list.",
"execution_order": 10,
"enabled": true,
"action": "str_replace",
"find": "<xf:extension id=\"above_thread_list\"></xf:extension>",
"replace": "$0\n<xf:if is=\"$forum.Node.parent_node_id == $xf.options.rhpz_club_node_id\">\n <div class=\"club-banner-container\">\n <xf:if is=\"$forum.Club.banner_date\">\n <img src=\"{$forum.Club.getBannerUrl()}\" alt=\"Banner {$forum.title}\" class=\"club-banner\" />\n </xf:if>\n </div>\n</xf:if>"
}

View File

@@ -0,0 +1,9 @@
{
"template": "forum_view",
"description": "Add Owner edit/delete buttons.",
"execution_order": 5,
"enabled": true,
"action": "str_replace",
"find": "<xf:extension id=\"above_thread_list\"></xf:extension>",
"replace": "$0\n<xf:if is=\"$forum.Club && $forum.Club.user_id == $xf.visitor.user_id\">\n <div class=\"block-outer-opposite u-marginBottom\">\n <div class=\"buttonGroup\">\n <a href=\"{{ link('clubs/edit', $forum.Club) }}\" class=\"button button--link\" icon=\"edit\">Edit</a>\n <a href=\"{{ link('clubs/delete', $forum.Club) }}\" class=\"button button--link\" icon=\"delete\" overlay=\"true\">Delete</a>\n </div>\n </div>\n</xf:if>"
}

View File

@@ -0,0 +1,9 @@
{
"template": "category_view",
"description": "Add Club Submit button",
"execution_order": 10,
"enabled": true,
"action": "str_replace",
"find": "\t\t\t\t\t\t\t<xf:button href=\"{{ link('categories/mark-read', $category, {'date': $xf.time}) }}\"\n\t\t\t\t\t\t\t\tclass=\"button--link\" overlay=\"true\">",
"replace": "<xf:if is=\"$xf.options.rhpz_club_node_id == $category.node_id\">\n\t<xf:button href=\"{{ link('clubs/submit') }}\"\n\t\t\t class=\"button--link\">\n\t\tRequest a club\n\t</xf:button>\n</xf:if>\n$0"
}

View File

@@ -7,12 +7,22 @@
"public/approval_item_club_request.html": {
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "39492e4fb48e7aa1622a6bb4371a36f4"
"hash": "da1f9c78c4e33597062258c0bba3cb4d"
},
"public/club_delete_confirm.html": {
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "c84c3878a0aee370e2080427405fe920"
},
"public/club_edit_form.html": {
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "d83cbfd477fc14de26b72aed00c866c3"
},
"public/club_request_form.html": {
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "5e1c397d93134aaa7164301d5a3553ce"
"hash": "443b696b5c7ae6bc4b1ef36d170ac7e7"
},
"public/report_content_romhackplaza_entry.html": {
"version_id": 1000000,

View File

@@ -2,7 +2,7 @@
arg-content="{$content}"
arg-user="{$content.User}"
arg-messageHtml="{$content.description}"
arg-contentDate="{$content.request_date}"
arg-contentDate="{$content.club_creation_date}"
arg-typePhraseHtml="Club Request"
arg-headerPhrase="{$content.title}"
arg-spamDetails="{$spamDetails}"

View File

@@ -0,0 +1,13 @@
<xf:title>Delete club : {$club.title}</xf:title>
<xf:form action="{{ link('clubs/delete', $club) }}" class="block">
<div class="block-container">
<div class="block-body">
<xf:inforow rowtype="confirm">
Are you sure you want to delete this club ? <strong>{$club.title}</strong> ?<br />
<span class="u-muted">Deleting this will also delete all threads and posts.</span>
</xf:inforow>
</div>
<xf:submitrow rowtype="simple" icon="delete" submit="Delete" />
</div>
</xf:form>

View File

@@ -0,0 +1,72 @@
<div class="block">
<xf:form action="{{ link('clubs/save', $club ) }}" upload="true" ajax="true" class="block-container">
<div class="block-body">
<xf:textboxrow name="title" value="{$club.title}" label="Title" required="true" maxlength="100" />
<xf:textarearow name="description" value="{$club.description}" label="Description" required="true" rows="4" />
<xf:if is="$club.banner_date">
<xf:formrow label="Current Banner">
<img src="{$club.getBannerUrl()}" style="max-width: 300px; border-radius: 4px;" />
</xf:formrow>
</xf:if>
<xf:uploadrow name="upload_banner" accept=".jpg,.jpeg,.png" label="Banner" />
</div>
<xf:submitrow icon="save" submit="Submit Changes" />
</xf:form>
</div>
<xf:if is="$club.club_id && $club.node_id">
<div class="block u-marginTop">
<div class="block-container">
<h2 class="block-header">Club Moderators ({$subModCount}/5)</h2>
<div class="block-body">
<xf:if is="$moderators is not empty">
<div class="dataList">
<xf:foreach loop="$moderators" value="$mod">
<div class="dataList-row">
<div class="dataList-cell dataList-cell--main">
<strong>{$mod.User.username}</strong>
<xf:if is="$mod.user_id == $club.user_id">
<span class="label label--accent u-marginLeft">Owner</span>
</xf:if>
</div>
<div class="dataList-cell dataList-cell--action">
<xf:if is="$mod.user_id != $club.user_id">
<xf:form action="{{ link('clubs/remove-moderator', $club) }}" ajax="true" class="u-inline">
<input type="hidden" name="user_id" value="{$mod.user_id}" />
<xf:button type="submit" class="button--small button--warn" icon="delete">Remove</xf:button>
</xf:form>
<xf:else />
<span class="u-muted">-</span>
</xf:if>
</div>
</div>
</xf:foreach>
</div>
<xf:else />
<div class="block-row">No moderators for this club.</div>
</xf:if>
</div>
</div>
</div>
<div class="block u-marginTop">
<xf:if is="$subModCount < 5">
<xf:form action="{{ link('clubs/add-moderator', $club) }}" ajax="true" class="block-container">
<h2 class="block-header">Add a moderator</h2>
<div class="block-body">
<xf:textboxrow name="username" label="Username" class="namePredictor" required="true" />
</div>
<xf:submitrow icon="add" submit="Promote Moderator" />
</xf:form>
<xf:else />
<div class="block-container">
<div class="block-row block-row--warning">
<strong>Limit reached:</strong> You have reached the maximum number of 5 moderators for your club. You must remove one before you can add a new one.
</div>
</div>
</xf:if>
</div>
</xf:if>

View File

@@ -5,6 +5,7 @@
<div class="block-body">
<xf:textboxrow name="title" label="Title" required="required" />
<xf:textarearow name="description" label="Description" rows="4" required="required" />
<xf:uploadrow name="upload_banner" accept=".jpg,.jpeg,.jpe,.png" label="Banner" />
</div>
<xf:submitrow submit="Submit" icon="save" />
</div>