Initial commit
This commit is contained in:
73
app/plugins/subscribe/forms.php
Normal file
73
app/plugins/subscribe/forms.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/subscribe/forms.php
|
||||
*
|
||||
* This houses all of the form checking functions for this plugin.
|
||||
*
|
||||
* @package TP Subscribe
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Plugins\Subscribe;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
|
||||
class SubscribeForms extends Forms {
|
||||
/**
|
||||
* Adds these functions to the form list.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::addHandler( 'subscribe', __CLASS__, 'subscribe' );
|
||||
self::addHandler( 'unsubscribe', __CLASS__, 'unsubscribe' );
|
||||
self::addHandler( 'newSubscription', __CLASS__, 'newSubscription' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the subscribe form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function subscribe() {
|
||||
if ( !self::email( Input::post( 'email' ) ) ) {
|
||||
self::addUserError( 'Invalid email.' );
|
||||
return false;
|
||||
}
|
||||
if ( !self::token() ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the unsubscribe form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function unsubscribe() {
|
||||
if ( !self::email( Input::post( 'email' ) ) ) {
|
||||
self::addUserError( 'Invalid email.' );
|
||||
return false;
|
||||
}
|
||||
if ( !self::token() ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the new subscription form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function newSubscription() {
|
||||
if ( !self::token() ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
new SubscribeForms;
|
Reference in New Issue
Block a user