Initial commit
This commit is contained in:
93
app/plugins/reviews/forms.php
Normal file
93
app/plugins/reviews/forms.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/reviews/forms.php
|
||||
*
|
||||
* This houses all of the form checking functions for this plugin.
|
||||
*
|
||||
* @package TP Reviews
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Plugins\Reviews;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
|
||||
class ReviewForms extends Forms {
|
||||
/**
|
||||
* Adds these functions to the form list.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::addHandler( 'createReview', __CLASS__, 'createReview' );
|
||||
self::addHandler( 'editReview', __CLASS__, 'editReview' );
|
||||
self::addHandler( 'categoryCreate', __CLASS__, 'categoryCreate' );
|
||||
self::addHandler( 'categoryEdit', __CLASS__, 'categoryEdit' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the createReview form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function createReview() {
|
||||
if ( ! Input::exists( 'review' ) ) {
|
||||
Check::addUserError( 'You must provide a review.' );
|
||||
return false;
|
||||
}
|
||||
if ( ! Input::exists( 'title' ) ) {
|
||||
Check::addUserError( 'You must provide a title.' );
|
||||
return false;
|
||||
}
|
||||
if ( ! Input::exists( 'rating' ) ) {
|
||||
Check::addUserError( 'You must provide a rating.' );
|
||||
return false;
|
||||
}
|
||||
if ( ! Input::exists( 'review_category_id' ) ) {
|
||||
Check::addUserError( 'You must provide a review_category_id.' );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static function editReview() {
|
||||
if ( ! Input::exists( 'review' ) ) {
|
||||
Check::addUserError( 'You must provide a review.' );
|
||||
return false;
|
||||
}
|
||||
if ( ! Input::exists( 'title' ) ) {
|
||||
Check::addUserError( 'You must provide a title.' );
|
||||
return false;
|
||||
}
|
||||
if ( ! Input::exists( 'rating' ) ) {
|
||||
Check::addUserError( 'You must provide a rating.' );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static function categoryCreate() {
|
||||
if ( ! Input::exists( 'name' ) ) {
|
||||
Check::addUserError( 'You must provide a name.' );
|
||||
return false;
|
||||
}
|
||||
if ( ! Input::exists( 'slug' ) ) {
|
||||
Check::addUserError( 'You must provide a slug.' );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static function categoryEdit() {
|
||||
if ( ! Input::exists( 'name' ) ) {
|
||||
Check::addUserError( 'You must provide a name.' );
|
||||
return false;
|
||||
}
|
||||
if ( ! Input::exists( 'slug' ) ) {
|
||||
Check::addUserError( 'You must provide a slug.' );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
new ReviewForms;
|
Reference in New Issue
Block a user