Initial commit
This commit is contained in:
6
app/plugins/tablefinder/config/constants.php
Normal file
6
app/plugins/tablefinder/config/constants.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
# bugTracker
|
||||
define( 'TABLE_FINDER_PLAYER_STATUS_APPLIED', 'Potential Player' );
|
||||
define( 'TABLE_FINDER_PLAYER_STATUS_LEFT', 'Former Player' );
|
||||
define( 'TABLE_FINDER_PLAYER_STATUS_ACCEPTED', 'Player' );
|
||||
define( 'TABLE_FINDER_PLAYER_STATUS_DENIED', 'Shunned' );
|
99
app/plugins/tablefinder/controllers/tablefinder.php
Normal file
99
app/plugins/tablefinder/controllers/tablefinder.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/tablefinder/controllers/tablefinder.php
|
||||
*
|
||||
* This is the table finder controller.
|
||||
*
|
||||
* @package TP TableFinder
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Controllers;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Hermes\Functions\Redirect;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Classes\Controller;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
use TheTempusProject\Models\Tables;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
use TheTempusProject\Models\Comments as CommentsModel;
|
||||
use TheTempusProject\Plugins\Comments;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
|
||||
class TableFinder extends Controller {
|
||||
protected static $suggestions;
|
||||
protected static $comments;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
if ( !App::$isLoggedIn ) {
|
||||
Session::flash( 'notice', 'You must be logged in to use this feature.' );
|
||||
return Redirect::home();
|
||||
}
|
||||
self::$suggestions = new Tables;
|
||||
self::$title = 'Table Finder - {SITENAME}';
|
||||
self::$pageDescription = 'On this page you can find or create a new table. Tables are essentially just a group of players who meet online or in-person to play tabletop games..';
|
||||
}
|
||||
|
||||
public function index() {
|
||||
Views::view( 'suggestions.list', self::$suggestions->recent() );
|
||||
}
|
||||
|
||||
public function view( $id = null ) {
|
||||
$data = self::$suggestions->findById( $id );
|
||||
if ( $data == false ) {
|
||||
Issues::add( 'error', 'Suggestion not found.' );
|
||||
return $this->index();
|
||||
}
|
||||
if ( empty( self::$comments ) ) {
|
||||
self::$comments = new CommentsModel;
|
||||
}
|
||||
if ( Input::exists( 'contentId' ) ) {
|
||||
$this->comments( 'post', Input::post( 'contentId' ) );
|
||||
}
|
||||
Components::set( 'CONTENT_ID', $id );
|
||||
Components::set( 'COMMENT_TYPE', 'suggestions' );
|
||||
Components::set( 'NEWCOMMENT', Views::simpleView( 'comments.create' ) );
|
||||
Components::set( 'count', self::$comments->count( 'suggestion', $id ) );
|
||||
Components::set( 'COMMENTS', Views::simpleView( 'comments.list', self::$comments->display( 10, self::$suggestions->tableName, $id ) ) );
|
||||
Views::view( 'suggestions.view', $data );
|
||||
}
|
||||
|
||||
public function create() {
|
||||
if ( !Input::exists() ) {
|
||||
return Views::view( 'suggestions.create' );
|
||||
}
|
||||
if ( !Forms::check( 'newSuggestion' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your suggestion.' => Check::userErrors() ] );
|
||||
return Views::view( 'suggestions.create' );
|
||||
}
|
||||
if ( !self::$suggestions->create( Input::post( 'title' ), Input::post( 'suggestion' ) ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your suggestion.' => Check::userErrors() ] );
|
||||
return Views::view( 'suggestions.create' );
|
||||
}
|
||||
Session::flash( 'success', 'Your Suggestion has been received. We must verify all suggestions before they are published, but as long as it doesn\'t violate our code of conduct, it should be available to view and comment on publicly within 24 hours.' );
|
||||
Redirect::to( 'suggestions/index' );
|
||||
}
|
||||
|
||||
public function edit( $data = null ) {
|
||||
if ( !Input::exists( 'submit' ) ) {
|
||||
return Views::view( 'suggestions.edit', self::$suggestions->findById( $data ) );
|
||||
}
|
||||
if ( !Forms::check( 'editSuggestion' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
return Views::view( 'suggestions.edit', self::$suggestions->findById( $data ) );
|
||||
}
|
||||
if ( self::$suggestions->update( $data, Input::post( 'title' ), Input::post( 'suggestion' ) ) ) {
|
||||
Issues::add( 'success', 'Suggestion updated' );
|
||||
} else {
|
||||
return Views::view( 'suggestions.edit', self::$suggestions->findById( $data ) );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
}
|
137
app/plugins/tablefinder/models/players.php
Normal file
137
app/plugins/tablefinder/models/players.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/tablefinder/models/players.php
|
||||
*
|
||||
* This class is used for the manipulation of the feedback database table.
|
||||
*
|
||||
* @package TP TableFinder
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Models;
|
||||
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Classes\DatabaseModel;
|
||||
use TheTempusProject\Plugins\Tablefinder as Plugin;
|
||||
|
||||
class Players extends DatabaseModel {
|
||||
public $tableName = 'players';
|
||||
public $databaseMatrix = [
|
||||
[ 'userID', 'int', '10' ],
|
||||
[ 'tableID', 'int', '10' ],
|
||||
[ 'characterID', 'int', '10' ],
|
||||
[ 'applicationDate', 'int', '10' ],
|
||||
[ 'rejectionDate', 'int', '10' ],
|
||||
[ 'joinDate', 'int', '10' ],
|
||||
[ 'leaveDate', 'int', '10' ],
|
||||
];
|
||||
public $plugin;
|
||||
|
||||
/**
|
||||
* The model constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->plugin = new Plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a player to the db.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function create( $userID, $tableID, $type = 'apply', $characterID = 0 ) {
|
||||
if ( !$this->plugin->checkEnabled() ) {
|
||||
Debug::info( 'TableFinder is disabled in the config.' );
|
||||
return false;
|
||||
}
|
||||
$fields = [
|
||||
'userID' => $userID,
|
||||
'tableID' => $tableID,
|
||||
];
|
||||
|
||||
if ( ! empty( $characterID ) ) {
|
||||
$fields['characterID'] = $characterID;
|
||||
}
|
||||
if ( 'apply' == $type ) {
|
||||
$fields['applicationDate'] = time();
|
||||
} else {
|
||||
$fields['joinDate'] = time();
|
||||
}
|
||||
if ( !self::$db->insert( $this->tableName, $fields ) ) {
|
||||
Debug::info( 'TableFinder::create - failed to insert to db' );
|
||||
return false;
|
||||
}
|
||||
return self::$db->lastId();
|
||||
}
|
||||
|
||||
public function listPlayersByUser( $userID, $type = 'applied' ) {
|
||||
if ( !$this->plugin->checkEnabled() ) {
|
||||
Debug::info( 'TableFinder is disabled in the config.' );
|
||||
return false;
|
||||
}
|
||||
switch ($type) {
|
||||
case 'applied':
|
||||
$type = 'applicationDate';
|
||||
break;
|
||||
case 'denied':
|
||||
$type = 'rejectionDate';
|
||||
break;
|
||||
case 'joined':
|
||||
$type = 'joinDate';
|
||||
break;
|
||||
case 'left':
|
||||
$type = 'leaveDate';
|
||||
break;
|
||||
default:
|
||||
// simple way to not limit the results
|
||||
$type = 'id';
|
||||
break;
|
||||
}
|
||||
$terms = [ 'userID', '=', $userID, 'AND', $type, '>', 0 ];
|
||||
|
||||
$results = self::$db->get( $this->tableName, $terms );
|
||||
if ( $results->count() == 0 ) {
|
||||
Debug::info( 'Failed to mark message as read.' );
|
||||
return false;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function listPlayersByTable( $tableID, $type = 'applied' ) {
|
||||
if ( !$this->plugin->checkEnabled() ) {
|
||||
Debug::info( 'TableFinder is disabled in the config.' );
|
||||
return false;
|
||||
}
|
||||
switch ($type) {
|
||||
case 'applied':
|
||||
$type = 'applicationDate';
|
||||
break;
|
||||
case 'denied':
|
||||
$type = 'rejectionDate';
|
||||
break;
|
||||
case 'joined':
|
||||
$type = 'joinDate';
|
||||
break;
|
||||
case 'left':
|
||||
$type = 'leaveDate';
|
||||
break;
|
||||
default:
|
||||
// simple way to not limit the results
|
||||
$type = 'id';
|
||||
break;
|
||||
}
|
||||
$terms = [ 'tableID', '=', $tableID, 'AND', $type, '>', 0 ];
|
||||
|
||||
$results = self::$db->get( $this->tableName, $terms );
|
||||
if ( $results->count() == 0 ) {
|
||||
Debug::info( 'Failed to mark message as read.' );
|
||||
return false;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
}
|
93
app/plugins/tablefinder/models/tables.php
Normal file
93
app/plugins/tablefinder/models/tables.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/tablefinder/models/players.php
|
||||
*
|
||||
* This class is used for the manipulation of the feedback database table.
|
||||
*
|
||||
* @package TP TableFinder
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Models;
|
||||
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Classes\DatabaseModel;
|
||||
use TheTempusProject\Plugins\Tablefinder as Plugin;
|
||||
|
||||
class Players extends DatabaseModel {
|
||||
public $tableName = 'players';
|
||||
public $databaseMatrix = [
|
||||
[ 'name', 'int', '10' ],
|
||||
[ 'description', 'int', '10' ],
|
||||
[ 'rules', 'int', '10' ],
|
||||
[ 'gmID', 'int', '10' ],
|
||||
[ 'createdAt', 'int', '10' ],
|
||||
[ 'createdBy', 'int', '10' ],
|
||||
[ 'calendarID', 'int', '10' ],
|
||||
[ 'preferredSessionFrequency', 'int', '10' ],
|
||||
// weekly
|
||||
// bi-weekly
|
||||
// monthly
|
||||
// undefined
|
||||
[ 'preferredSessionLength', 'int', '10' ],
|
||||
[ 'minimumSessionLength', 'int', '10' ],
|
||||
[ 'maximumSessionLength', 'int', '10' ],
|
||||
[ 'gamePlatform', 'int', '10' ],
|
||||
[ 'gameVersion', 'int', '10' ],
|
||||
[ 'playType', 'int', '10' ],
|
||||
// in-person
|
||||
// online
|
||||
[ 'location', 'int', '10' ],
|
||||
];
|
||||
|
||||
public $plugin;
|
||||
|
||||
/**
|
||||
* The model constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->plugin = new Plugin;
|
||||
}
|
||||
|
||||
public function create(
|
||||
$name,
|
||||
$description = '',
|
||||
$rules = '',
|
||||
$frequency = 'Weekly',
|
||||
$lengthPref = '4h',
|
||||
$lengthMin = '30m',
|
||||
$lengthMax = '12h',
|
||||
$platform = 'Dungeons & Dragons',
|
||||
$version = '5e',
|
||||
$playType = 'Online',
|
||||
$location = 'TBD'
|
||||
) {
|
||||
if ( !$this->plugin->checkEnabled() ) {
|
||||
Debug::info( 'TableFinder is disabled in the config.' );
|
||||
return false;
|
||||
}
|
||||
$fields = [
|
||||
'userID' => $userID,
|
||||
'tableID' => $tableID,
|
||||
];
|
||||
|
||||
if ( ! empty( $characterID ) ) {
|
||||
$fields['characterID'] = $characterID;
|
||||
}
|
||||
if ( 'apply' == $type ) {
|
||||
$fields['applicationDate'] = time();
|
||||
} else {
|
||||
$fields['joinDate'] = time();
|
||||
}
|
||||
if ( !self::$db->insert( $this->tableName, $fields ) ) {
|
||||
Debug::info( 'TableFinder::create - failed to insert to db' );
|
||||
return false;
|
||||
}
|
||||
return self::$db->lastId();
|
||||
}
|
||||
}
|
76
app/plugins/tablefinder/plugin.php
Normal file
76
app/plugins/tablefinder/plugin.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/tablefinder/plugin.php
|
||||
*
|
||||
* This houses all of the main plugin info and functionality.
|
||||
*
|
||||
* @package TP TableFinder
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Plugins;
|
||||
|
||||
use TheTempusProject\Classes\Plugin;
|
||||
|
||||
class Tablefinder extends Plugin {
|
||||
public $pluginName = 'TP TableFinder';
|
||||
public $pluginAuthor = 'JoeyK';
|
||||
public $pluginWebsite = 'https://TheTempusProject.com';
|
||||
public $modelVersion = '1.0';
|
||||
public $pluginVersion = '3.0';
|
||||
public $pluginDescription = 'A simple plugin which adds a D&D fifth edition character creator.';
|
||||
public $configName = 'tablefinder';
|
||||
public $configMatrix = [
|
||||
'enabled' => [
|
||||
'type' => 'radio',
|
||||
'pretty' => 'Enable the table finder.',
|
||||
'default' => true,
|
||||
],
|
||||
];
|
||||
public $permissionMatrix = [
|
||||
'useTableFinder' => [
|
||||
'pretty' => 'Can use the table finder',
|
||||
'default' => true,
|
||||
],
|
||||
];
|
||||
public $main_links = [
|
||||
[
|
||||
'text' => 'Table Finder ',
|
||||
'url' => '{ROOT_URL}creator/index',
|
||||
],
|
||||
];
|
||||
public $supported_games = [
|
||||
'Dungeons and Dragons' => [
|
||||
'5e'
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Availability needs to be handled through the plugin
|
||||
// basically show 4-week calendar after the current week
|
||||
// assume everything is unavailable and have people draw green for available
|
||||
// uses calendar plugin for calendar management
|
||||
|
||||
|
||||
|
||||
|
||||
// I should be able to delete a campaign
|
||||
// I should be able to update name, description, dmId
|
||||
// Creates and assigns the calendar automatically
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
6
app/plugins/tablefinder/views/index.html
Normal file
6
app/plugins/tablefinder/views/index.html
Normal file
@ -0,0 +1,6 @@
|
||||
<legend>Tables</legend>
|
||||
<div class="row">
|
||||
<div class="col-xlg-12 col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
{tableList}
|
||||
</div>
|
||||
</div>
|
0
app/plugins/tablefinder/views/players/list.html
Normal file
0
app/plugins/tablefinder/views/players/list.html
Normal file
93
app/plugins/tablefinder/views/tables/create.html
Normal file
93
app/plugins/tablefinder/views/tables/create.html
Normal file
@ -0,0 +1,93 @@
|
||||
<form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
|
||||
<legend>Start a Table</legend>
|
||||
<div class="form-group">
|
||||
<label for="title" class="col-lg-3 control-label">Title</label>
|
||||
<div class="col-lg-3">
|
||||
<input type="text" class="form-check-input" name="title" id="title">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="blogPost" class="col-lg-3 control-label">Post</label>
|
||||
<div class="col-lg-6">
|
||||
<textarea class="form-control" name="blogPost" maxlength="2000" rows="10" cols="50" id="blogPost"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-6 col-lg-offset-3">
|
||||
<button name="submit" value="publish" type="submit" class="btn btn-lg btn-primary">Publish</button>
|
||||
<button name="submit" value="saveDraft" type="submit" class="btn btn-lg btn-primary">Save as Draft</button>
|
||||
<button name="submit" value="preview" type="submit" class="btn btn-lg btn-primary">Preview</button>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="token" value="{TOKEN}">
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[ 'name', 'int', '10' ],
|
||||
[ 'description', 'int', '10' ],
|
||||
[ 'rules', 'int', '10' ],
|
||||
[ 'gmID', 'int', '10' ],
|
||||
[ 'createdAt', 'int', '10' ],
|
||||
[ 'createdBy', 'int', '10' ],
|
||||
[ 'calendarID', 'int', '10' ],
|
||||
[ 'preferredSessionFrequency', 'int', '10' ],
|
||||
// weekly
|
||||
// bi-weekly
|
||||
// monthly
|
||||
// undefined
|
||||
[ 'preferredSessionLength', 'int', '10' ],
|
||||
[ 'minimumSessionLength', 'int', '10' ],
|
||||
[ 'maximumSessionLength', 'int', '10' ],
|
||||
[ 'gamePlatform', 'int', '10' ],
|
||||
[ 'gameVersion', 'int', '10' ],
|
||||
[ 'playType', 'int', '10' ],
|
||||
// in-person
|
||||
// online
|
||||
[ 'location', 'int', '10' ],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<form action="" method="post" class="form-horizontal">
|
||||
<legend>New Route</legend>
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label for="nickname" class="col-lg-6 control-label">Nickname:</label>
|
||||
<div class="col-lg-2">
|
||||
<input class="form-control" type="text" name="nickname" id="nickname">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="original_url" class="col-lg-6 control-label">Original URL:</label>
|
||||
<div class="col-lg-2">
|
||||
<input class="form-control" type="text" name="original_url" id="original_url">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="forwarded_url" class="col-lg-6 control-label">Forward URL:</label>
|
||||
<div class="col-lg-2">
|
||||
<input class="form-control" type="text" name="forwarded_url" id="forwarded_url">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="redirect_type" class="col-lg-6 control-label">Redirect Type:</label>
|
||||
<div class="col-lg-2">
|
||||
<select name="redirect_type" id="redirect_type" class="">
|
||||
<option value='internal' selected>Internal</option>
|
||||
<option value='external'>External</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<input type="hidden" name="token" value="{TOKEN}">
|
||||
<button name="submit" value="submit" type="submit" class="btn btn-lg btn-primary center-block">Create</button><br>
|
||||
</form>
|
||||
|
0
app/plugins/tablefinder/views/tables/list.html
Normal file
0
app/plugins/tablefinder/views/tables/list.html
Normal file
Reference in New Issue
Block a user