Initial commit
This commit is contained in:
68
app/plugins/suggestions/forms.php
Normal file
68
app/plugins/suggestions/forms.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/suggestions/forms.php
|
||||
*
|
||||
* This houses all of the form checking functions for this plugin.
|
||||
*
|
||||
* @package TP Suggest
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Plugins\Suggestions;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
|
||||
class SuggestionForms extends Forms {
|
||||
/**
|
||||
* Adds these functions to the form list.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::addHandler( 'newSuggestion', __CLASS__, 'newSuggestion' );
|
||||
self::addHandler( 'editSuggestion', __CLASS__, 'editSuggestion' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the suggestion create form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function newSuggestion() {
|
||||
if ( !Input::exists( 'title' ) ) {
|
||||
self::addUserError( 'You must specify title' );
|
||||
return false;
|
||||
}
|
||||
if ( !Input::exists( 'suggestion' ) ) {
|
||||
self::addUserError( 'You must write a Suggestion' );
|
||||
return false;
|
||||
}
|
||||
if ( !self::token() ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the suggestion create form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function editSuggestion() {
|
||||
if ( !Input::exists( 'title' ) ) {
|
||||
self::addUserError( 'You must specify title' );
|
||||
return false;
|
||||
}
|
||||
if ( !Input::exists( 'suggestion' ) ) {
|
||||
self::addUserError( 'You must write a Suggestion' );
|
||||
return false;
|
||||
}
|
||||
if ( !self::token() ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
new SuggestionForms;
|
Reference in New Issue
Block a user