This commit is contained in:
Joey Kimsey
2025-02-25 14:03:12 -05:00
parent c40b29e812
commit 46390c2447
21 changed files with 197 additions and 60 deletions

View File

@ -21,6 +21,7 @@ use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Bedrock\Functions\Session;
use TheTempusProject\Hermes\Functions\Redirect;
use TheTempusProject\Models\Contact as ContactModel;
use TheTempusProject\Plugins\Turnstile;
class Contact extends Controller {
protected static $contact;
@ -29,13 +30,28 @@ class Contact extends Controller {
self::$contact = new ContactModel;
self::$title = 'Contact - {SITENAME}';
self::$pageDescription = 'At {SITENAME}, we value our users\' input. You can provide any contact or suggestions using this form.';
if ( !Input::exists() ) {
$turnstile = '';
if ( class_exists( 'TheTempusProject\Plugins\Turnstile' ) ) {
$turnstile = new Turnstile;
if ( ! $turnstile->checkEnabled() ) {
Components::set( 'TURNSTILE_WIDGET', '' );
$turnstile = '';
}
} else {
Components::set( 'TURNSTILE_WIDGET', '' );
}
if ( ! Input::exists() ) {
return Views::view( 'contact.create' );
}
if ( !Forms::check( 'contact' ) ) {
if ( ! Forms::check( 'contact' ) ) {
Issues::add( 'error', [ 'There was an error with your form, please check your submission and try again.' => Check::userErrors() ] );
return Views::view( 'contact.create' );
}
if ( ! empty( $turnstile ) ) {
if ( empty( $turnstile->verify() ) ) {
return Views::view( 'contact.create' );
}
}
$result = self::$contact->create( Input::post( 'name' ), Input::post( 'contactEmail' ), Input::post( 'entry' ) );
if ( $result ) {
Session::flash( 'success', 'Thank you! Your contact has been received.' );