Initial commit
This commit is contained in:
69
app/plugins/comments/forms.php
Normal file
69
app/plugins/comments/forms.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/comments/forms.php
|
||||
*
|
||||
* This houses all of the form checking functions for this plugin.
|
||||
*
|
||||
* @package TP Comments
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Plugins\Feedback;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
|
||||
class CommentsForms extends Forms {
|
||||
/**
|
||||
* Adds these functions to the form list.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::addHandler( 'newComment', __CLASS__, 'newComment' );
|
||||
self::addHandler( 'editComment', __CLASS__, 'editComment' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the new comment form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function newComment() {
|
||||
if ( !Input::exists( 'comment' ) ) {
|
||||
Check::addUserError( 'You cannot post a blank comment.' );
|
||||
return false;
|
||||
}
|
||||
if ( !Input::exists( 'contentId' ) ) {
|
||||
Check::addUserError( 'Content ID was missing.' );
|
||||
return false;
|
||||
}
|
||||
// these are disabled because i need to figure out a solution for pages where images are wrong
|
||||
// a missing image loads a new token and messes this up
|
||||
// if ( !Check::token() ) {
|
||||
// return false;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the edit comment form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function editComment() {
|
||||
if ( !Input::exists( 'comment' ) ) {
|
||||
Check::addUserError( 'You cannot post a blank comment.' );
|
||||
return false;
|
||||
}
|
||||
// these are disabled because i need to figure out a solution for pages where images are wrong
|
||||
// a missing image loads a new token and messes this up
|
||||
// if ( !Check::token() ) {
|
||||
// return false;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
new CommentsForms;
|
Reference in New Issue
Block a user