Compare commits

..

3 Commits

Author SHA1 Message Date
4415a2e8c4 A lot of things. 2026-06-08 16:25:52 +02:00
8eb94ff05d Club System 2026-06-02 20:54:38 +02:00
f4dc336c88 Club System 2026-06-02 20:54:08 +02:00
91 changed files with 1647 additions and 72 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace RomhackPlaza\Master\Api\Controller;
use XF\Api\Controller\AbstractController;
use XF\Mvc\Reply\AbstractReply;
class EntryController extends AbstractController
{
public function actionPostUpdateEntryCount(): AbstractReply
{
$userId = $this->filter('user_id', 'uint');
$count = $this->filter('count', 'uint');
$user = $this->assertRecordExists('XF:User', $userId);
$user->rhpz_entry_count = $count;
$user->save();
$trophyRepo = $this->repository('XF:Trophy');
$trophyRepo->updateTrophiesForUser($user);
return $this->apiSuccess(['success' => true,'user_id' => $user->user_id,'count' => $count]);
}
}

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()
]);
}
}

76
ApprovalQueue/Club.php Normal file
View File

@@ -0,0 +1,76 @@
<?php
namespace RomhackPlaza\Master\ApprovalQueue;
use XF\ApprovalQueue\AbstractHandler;
use XF\Mvc\Entity\Entity;
class Club extends AbstractHandler
{
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'];
}
public function actionApprove(\RomhackPlaza\Master\Entity\Club $club)
{
$club->club_state = 'visible';
$club->save();
$node = \XF::em()->create('XF:Node');
$node->node_type_id = 'Forum';
$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();
$forum = \XF::em()->create('XF:Forum');
$forum->node_id = $node->node_id;
$forum->allow_posting = true;
$forum->save();
$club->node_id = $node->node_id;
$club->save();
$user = $club->User;
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);
$permissionUpdater->updatePermissions(\RomhackPlaza\Master\Entity\Club::MOD_PERMISSIONS);
\XF::app()->jobManager()->enqueueUnique('permissionRebuild', 'XF:PermissionRebuild');
}
}
public function actionReject(\RomhackPlaza\Master\Entity\Club $club)
{
$club->club_state = 'rejected';
$club->save();
}
public function getTemplateName()
{
return 'public:approval_item_club_request';
}
}

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();
}
}

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'];
}
}

182
Pub/Controller/Club.php Normal file
View File

@@ -0,0 +1,182 @@
<?php
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();
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();
$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." );
}
}

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
);
}
}

View File

@@ -1,36 +0,0 @@
<?php
namespace RomhackPlaza\Master\Pub\Controller;
use XF\Mvc\Controller;
use XF\Mvc\Reply\AbstractReply;
class Webhook extends Controller
{
public function actionUpdateUserEntryCount(): AbstractReply
{
$this->assertPostOnly();
$token = $this->filter('_token', 'str');
$secret = \XF::options()->rhpz_webhook_secret ?? '';
if( !$secret || !hash_equals($secret, $token) ){
return $this->error('Unauthorized', 401);
}
$userId = $this->filter('user_id', 'uint');
$count = $this->filter('count', 'uint');
$user = \XF::em()->find('XF:User', $userId);
if( !$user ){
return $this->error('User not found', 404);
}
$user->rhpz_entry_count = $count;
$user->save();
$trophyService = \XF::service('XF:Trophy\Notify', $user);
$trophyService->checkAndAwardTrophies();
return $this->apiSuccess(['count' => $count]);
}
}

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,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

@@ -6,6 +6,7 @@ use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait; use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait; use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait; use XF\AddOn\StepRunnerUpgradeTrait;
use XF\Db\Schema\Create;
class Setup extends AbstractSetup class Setup extends AbstractSetup
{ {
@@ -23,10 +24,35 @@ class Setup extends AbstractSetup
}); });
} }
/**
* Create club table.
* @return void
*/
public function installStep2(): void
{
$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('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');
});
}
public function uninstallStep1(): void public function uninstallStep1(): void
{ {
$this->schemaManager()->alterTable('xf_user', function($table) { $this->schemaManager()->alterTable('xf_user', function($table) {
$table->dropColumns(['rhpz_entry_count']); $table->dropColumns(['rhpz_entry_count']);
}); });
} }
public function uninstallStep2(): void
{
$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;
}
}

18
XF/Entity/User.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
namespace RomhackPlaza\Master\XF\Entity;
use XF\Mvc\Entity\Structure;
use XF\Mvc\Entity\Entity;
class User extends XFCP_User
{
public static function getStructure(Structure $structure): Structure
{
$structure = parent::getStructure($structure);
$structure->columns['rhpz_entry_count'] = [ 'type' => self::UINT, 'default' => 0 ];
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

@@ -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,8 @@
{
"XF-Entity-Forum_RomhackPlaza-Master-XF-Entity-Forum.json": {
"hash": "c7747b6ea6bd924d2d02e82917ff0df3"
},
"XF-Entity-User_RomhackPlaza-Master-XF-Entity-User.json": {
"hash": "811593d6f012a53b9fa2ced871de96a9"
}
}

View File

@@ -0,0 +1,14 @@
{
"club-approval_queue_handler_class.json": {
"hash": "468464999ab50b9de400a6eae27625ac"
},
"club-entity.json": {
"hash": "ed572323131987e295051165e4ec3c5e"
},
"romhackplaza_entry-entity.json": {
"hash": "8686ffd261eb8c1698a3ec6e31118f02"
},
"romhackplaza_entry-report_handler_class.json": {
"hash": "3e3d009b1b4671a506accc2e920307b2"
}
}

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

@@ -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,15 @@
<?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_Forum extends \XF\Entity\Forum {}
class XFCP_User extends \XF\Entity\User {}
}

View File

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

View File

@@ -1,6 +1,6 @@
{ {
"parent_navigation_id": "pages", "parent_navigation_id": "pages",
"display_order": 2, "display_order": 200,
"navigation_type_id": "basic", "navigation_type_id": "basic",
"type_config": { "type_config": {
"link": "{$xf.options.homePageUrl}/pages/about", "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": "", "parent_navigation_id": "",
"display_order": 50, "display_order": 300,
"navigation_type_id": "basic", "navigation_type_id": "basic",
"type_config": { "type_config": {
"link": "", "link": "",

View File

@@ -1,9 +1,9 @@
{ {
"parent_navigation_id": "pages", "parent_navigation_id": "pages",
"display_order": 3, "display_order": 300,
"navigation_type_id": "basic", "navigation_type_id": "basic",
"type_config": { "type_config": {
"link": "{$xf.options.homePageUrl}/pages/contact-us", "link": "{{ link('misc/contact') }}",
"display_condition": "", "display_condition": "",
"extra_attributes": { "extra_attributes": {
"icon": "at-sign" "icon": "at-sign"

View File

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

View File

@@ -1,6 +1,6 @@
{ {
"parent_navigation_id": "community", "parent_navigation_id": "community",
"display_order": 2, "display_order": 300,
"navigation_type_id": "basic", "navigation_type_id": "basic",
"type_config": { "type_config": {
"link": "{$xf.options.homePageUrl}/discord", "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", "parent_navigation_id": "community",
"display_order": 1, "display_order": 100,
"navigation_type_id": "basic", "navigation_type_id": "basic",
"type_config": { "type_config": {
"link": "{$xf.options.boardUrl}", "link": "{$xf.options.boardUrl}",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,9 @@
{ {
"parent_navigation_id": "website", "parent_navigation_id": "website",
"display_order": 3, "display_order": 300,
"navigation_type_id": "basic", "navigation_type_id": "basic",
"type_config": { "type_config": {
"link": "{$xf.options.homePageUrl}/submissions-queue", "link": "{$xf.options.homePageUrl}/queue",
"display_condition": "", "display_condition": "",
"extra_attributes": { "extra_attributes": {
"icon": "gavel" "icon": "gavel"

View File

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

View File

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

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

@@ -1,7 +1,31 @@
{ {
"romhackplaza-canEditMyEntries.json": {
"hash": "4fa023f096147e72d0ca94e5ce231228"
},
"romhackplaza-canEditOthersEntries.json": {
"hash": "c2e1c6213b7266fa56ead62676784a26"
},
"romhackplaza-canModerateEntries.json": {
"hash": "dfee0d9b78d1833c648d9c5047c29a33"
},
"romhackplaza-canSeeHiddenEntries.json": {
"hash": "3a71377fae8f064eafaef3ac0f8bed68"
},
"romhackplaza-canSeeLockedEntries.json": {
"hash": "f0907b5c0da0c465195a19babd671343"
},
"romhackplaza-canSeeOthersDrafts.json": {
"hash": "fbd94dac811e001e8923ed28da460367"
},
"romhackplaza-canSeeRejectedEntries.json": {
"hash": "5c015bf4b7012720a4f7bcfdb8eb9521"
},
"romhackplaza-canSubmitEntry.json": { "romhackplaza-canSubmitEntry.json": {
"hash": "6eeb397b6596b6774af70dbbf5454106" "hash": "6eeb397b6596b6774af70dbbf5454106"
}, },
"romhackplaza-canSubmitEntryInPublished.json": {
"hash": "39acd4f2cc864663e5978b18cb390a5c"
},
"romhackplaza-canSubmitTempFile.json": { "romhackplaza-canSubmitTempFile.json": {
"hash": "d514bba0211dc91897efce276c499131" "hash": "d514bba0211dc91897efce276c499131"
}, },

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

@@ -5,6 +5,12 @@
"version_string": "1.0.0", "version_string": "1.0.0",
"hash": "8f7f4c1ce7a4f933663d10543562b096" "hash": "8f7f4c1ce7a4f933663d10543562b096"
}, },
"nav.clubs.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "bc56e1ae1e30e7123ffc5030f108f2a0"
},
"nav.community.txt": { "nav.community.txt": {
"global_cache": false, "global_cache": false,
"version_id": 1000000, "version_id": 1000000,
@@ -29,6 +35,12 @@
"version_string": "1.0.0", "version_string": "1.0.0",
"hash": "8f5cc6430613f1c12f36965050bb7197" "hash": "8f5cc6430613f1c12f36965050bb7197"
}, },
"nav.drafts.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "bc67af65fab4a8b1848ccedf29c3b733"
},
"nav.forum.txt": { "nav.forum.txt": {
"global_cache": false, "global_cache": false,
"version_id": 1000000, "version_id": 1000000,
@@ -101,12 +113,84 @@
"version_string": "1.0.0", "version_string": "1.0.0",
"hash": "15bbb9d0bbf25e8d2978de1168c749dc" "hash": "15bbb9d0bbf25e8d2978de1168c749dc"
}, },
"option.rhpz_club_node_id.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "e73496f262c162a1a35bd9e990b36825"
},
"option_explain.rhpz_club_node_id.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "d41d8cd98f00b204e9800998ecf8427e"
},
"option_group.romhackplaza.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "4b206b2374c877bad80e7cd2303936be"
},
"option_group_description.romhackplaza.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "d41d8cd98f00b204e9800998ecf8427e"
},
"permission.romhackplaza_canEditMyEntries.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "1a932031ffdf7a07800d30b2d898fc34"
},
"permission.romhackplaza_canEditOthersEntries.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "83d885098bc54e2afa37b3045c8048f3"
},
"permission.romhackplaza_canModerateEntries.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "7ab831a3557b53a4a63ac279cd33fc36"
},
"permission.romhackplaza_canSeeHiddenEntries.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "20fbb37e0be574bb4060c16c1caf6d50"
},
"permission.romhackplaza_canSeeLockedEntries.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "4738ddb90744d6caf4e46335eeac511a"
},
"permission.romhackplaza_canSeeOthersDrafts.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "4c2c7800c562085f51a3b486dfb8e5bb"
},
"permission.romhackplaza_canSeeRejectedEntries.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "827c586329fad5466cccf547f5011bea"
},
"permission.romhackplaza_canSubmitEntry.txt": { "permission.romhackplaza_canSubmitEntry.txt": {
"global_cache": false, "global_cache": false,
"version_id": 1000000, "version_id": 1000000,
"version_string": "1.0.0", "version_string": "1.0.0",
"hash": "d62432dfaf4d83315ed838ce10794fa1" "hash": "d62432dfaf4d83315ed838ce10794fa1"
}, },
"permission.romhackplaza_canSubmitEntryInPublished.txt": {
"global_cache": false,
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "40e2c757fc3f0056a40aa98dec7d2d25"
},
"permission.romhackplaza_canSubmitTempFile.txt": { "permission.romhackplaza_canSubmitTempFile.txt": {
"global_cache": false, "global_cache": false,
"version_id": 1000000, "version_id": 1000000,

View File

@@ -0,0 +1 @@
Clubs

View File

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

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,14 @@
{
"api_romhackplaza_entry_.json": {
"hash": "5f1609f559980b44af09fd85c3b34a30"
},
"api_threads_undelete.json": {
"hash": "3376251e185807693e0fb7dc6dcc9ee0"
},
"public_clubs_.json": {
"hash": "4fbb4a364e108ff5b30dfd57692205aa"
},
"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": "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

@@ -0,0 +1,11 @@
{
"route_type": "public",
"route_prefix": "clubs",
"sub_name": "",
"format": ":int<club_id>/",
"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 @@
{
"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

@@ -3,5 +3,30 @@
"version_id": 1000000, "version_id": 1000000,
"version_string": "1.0.0", "version_string": "1.0.0",
"hash": "19cd05c4ab254dbad0abfd0c6b8c3456" "hash": "19cd05c4ab254dbad0abfd0c6b8c3456"
},
"public/approval_item_club_request.html": {
"version_id": 1000000,
"version_string": "1.0.0",
"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": "443b696b5c7ae6bc4b1ef36d170ac7e7"
},
"public/report_content_romhackplaza_entry.html": {
"version_id": 1000000,
"version_string": "1.0.0",
"hash": "d6c5c25a9af81a7da2bd8e2b9f74229e"
} }
} }

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.club_creation_date}"
arg-typePhraseHtml="Club Request"
arg-headerPhrase="{$content.title}"
arg-spamDetails="{$spamDetails}"
arg-unapprovedItem="{$unapprovedItem}"
arg-handler="{$handler}"
/>

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

@@ -0,0 +1,12 @@
<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" />
<xf:uploadrow name="upload_banner" accept=".jpg,.jpeg,.jpe,.png" label="Banner" />
</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>