Club System
This commit is contained in:
32
Pub/Controller/Club.php
Normal file
32
Pub/Controller/Club.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza\Master\Pub\Controller;
|
||||
|
||||
use XF\Mvc\ParameterBag;
|
||||
use XF\Pub\Controller\AbstractController;
|
||||
|
||||
class Club extends AbstractController
|
||||
{
|
||||
|
||||
public function actionSubmit(ParameterBag $params)
|
||||
{
|
||||
$this->assertRegistrationRequired();
|
||||
|
||||
return $this->view('RomhackPlaza\Master:Club\Request', 'club_request_form');
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
return $this->redirect($this->buildLink('clubs'), "Your club creation request has been submitted and is awaiting approval by a staff member.");
|
||||
}
|
||||
}
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user