Bugfixes and Bootstrap 5 finalized
This commit is contained in:
@ -25,9 +25,10 @@ use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
use TheTempusProject\Hermes\Functions\Redirect;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
use TheTempusProject\Models\Comments as CommentModel;
|
||||
use TheTempusProject\Models\Comments as CommentsModel;
|
||||
|
||||
class Comments extends Plugin {
|
||||
protected static $comments;
|
||||
public $pluginName = 'TP Comments';
|
||||
public $pluginAuthor = 'JoeyK';
|
||||
public $pluginWebsite = 'https://TheTempusProject.com';
|
||||
@ -61,7 +62,6 @@ class Comments extends Plugin {
|
||||
]
|
||||
],
|
||||
];
|
||||
public $comments;
|
||||
|
||||
public function __construct( $load = false ) {
|
||||
if ( !empty(App::$activePerms) ) {
|
||||
@ -75,11 +75,16 @@ class Comments extends Plugin {
|
||||
'replace' => ( App::$isMod ? '$1' : '' ),
|
||||
'enabled' => true,
|
||||
];
|
||||
$this->getModel();
|
||||
self::$comments = new CommentsModel;
|
||||
parent::__construct( $load );
|
||||
}
|
||||
|
||||
public function formPost( $type, $content, $redirect ) {
|
||||
if ( ! $this->checkEnabled() ) {
|
||||
Debug::info( 'Comments Plugin is disabled in the control panel.' );
|
||||
Issues::add( 'error', 'Comments are disabled.' );
|
||||
return false;
|
||||
}
|
||||
if ( !App::$isLoggedIn ) {
|
||||
Session::flash( 'notice', 'You must be logged in to post comments.' );
|
||||
return Redirect::to( $redirect . $content->ID );
|
||||
@ -88,7 +93,7 @@ class Comments extends Plugin {
|
||||
Session::flash( 'error', [ 'There was a problem with your comment form.' => Check::userErrors() ] );
|
||||
return Redirect::to( $redirect . $content->ID );
|
||||
}
|
||||
if ( !$this->comments->create( $type, $content->ID, Input::post( 'comment' ) ) ) {
|
||||
if ( !self::$comments->create( $type, $content->ID, Input::post( 'comment' ) ) ) {
|
||||
Session::flash( 'error', [ 'There was a problem posting your comment.' => Check::userErrors() ] );
|
||||
} else {
|
||||
Session::flash( 'success', 'Comment posted' );
|
||||
@ -97,6 +102,11 @@ class Comments extends Plugin {
|
||||
}
|
||||
|
||||
public function formEdit( $type, $content, $redirect ) {
|
||||
if ( ! $this->checkEnabled() ) {
|
||||
Debug::info( 'Comments Plugin is disabled in the control panel.' );
|
||||
Issues::add( 'error', 'Comments are disabled.' );
|
||||
return false;
|
||||
}
|
||||
if ( !App::$isLoggedIn ) {
|
||||
Session::flash( 'notice', 'You must be logged in to do that.' );
|
||||
return Redirect::to( $type );
|
||||
@ -112,7 +122,7 @@ class Comments extends Plugin {
|
||||
Issues::add( 'error', [ 'There was a problem editing your comment.' => Check::userErrors() ] );
|
||||
return Views::view( 'comments.admin.edit', $content );
|
||||
}
|
||||
if ( !$this->comments->update( $content->ID, Input::post( 'comment' ) ) ) {
|
||||
if ( !self::$comments->update( $content->ID, Input::post( 'comment' ) ) ) {
|
||||
Issues::add( 'error', [ 'There was a problem editing your comment.' => Check::userErrors() ] );
|
||||
return Views::view( 'comments.admin.edit', $content );
|
||||
}
|
||||
@ -121,6 +131,11 @@ class Comments extends Plugin {
|
||||
}
|
||||
|
||||
public function formDelete( $type, $content, $redirect ) {
|
||||
if ( ! $this->checkEnabled() ) {
|
||||
Debug::info( 'Comments Plugin is disabled in the control panel.' );
|
||||
Issues::add( 'error', 'Comments are disabled.' );
|
||||
return false;
|
||||
}
|
||||
if ( !App::$isLoggedIn ) {
|
||||
Session::flash( 'notice', 'You must be logged in to do that.' );
|
||||
return Redirect::to( $type );
|
||||
@ -129,18 +144,11 @@ class Comments extends Plugin {
|
||||
Session::flash( 'error', 'You do not have permission to edit this comment' );
|
||||
return Redirect::to( $type );
|
||||
}
|
||||
if ( !$this->comments->delete( (array) $content->ID ) ) {
|
||||
if ( !self::$comments->delete( (array) $content->ID ) ) {
|
||||
Session::flash( 'error', 'There was an error with your request.' );
|
||||
} else {
|
||||
Session::flash( 'success', 'Comment has been deleted' );
|
||||
}
|
||||
return Redirect::to( $redirect . $content->contentID );
|
||||
}
|
||||
|
||||
public function getModel() {
|
||||
if ( empty($this->comments) ) {
|
||||
$this->comments = new CommentModel;
|
||||
}
|
||||
return $this->comments;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user