only load captcha helper if requiring captcha, use our own constant for mysql datetime

This commit is contained in:
Brandon Shipley 2025-01-10 01:34:02 -08:00
parent 798635bb33
commit 77f09055c9
3 changed files with 5 additions and 3 deletions

View File

@ -17,7 +17,7 @@ class CakeContactUsPlugin extends BasePlugin
{ {
public const EVENT_BEFORE_CONTACT_US_FORM_SAVED = 'ContactUs.Global.beforeRegister'; public const EVENT_BEFORE_CONTACT_US_FORM_SAVED = 'ContactUs.Global.beforeRegister';
public const EVENT_AFTER_CONTACT_US_FORM_SAVED = 'ContactUs.Global.afterRegister'; public const EVENT_AFTER_CONTACT_US_FORM_SAVED = 'ContactUs.Global.afterRegister';
public const CAKE_CONTACT_US_MYSQL_DATETIME = 'Y-m-d H:i:s';
/** /**
* Load all the plugin configuration and bootstrap logic. * Load all the plugin configuration and bootstrap logic.
* *

View File

@ -57,7 +57,8 @@ class ContactUsComponent extends Component
$this->setConfig('requireEmail', Configure::readOrFail('ContactUs.fields.email')); $this->setConfig('requireEmail', Configure::readOrFail('ContactUs.fields.email'));
$this->setConfig('requireCaptcha', $requireCaptcha); $this->setConfig('requireCaptcha', $requireCaptcha);
if ($requireCaptcha) { if ($requireCaptcha) {
$this->_registry->load('Captcha.Captcha'); // $this->_registry->load('Captcha.Captcha');
$this->getController()->viewBuilder()->addHelpers(['Captcha.Captcha']);
} }
} }

View File

@ -15,6 +15,7 @@ use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker; use Cake\ORM\RulesChecker;
use Cake\ORM\Table; use Cake\ORM\Table;
use Cake\Validation\Validator; use Cake\Validation\Validator;
use CakeContactUs\CakeContactUsPlugin;
use CakeContactUs\Model\Entity\ContactUsFormSubmission; use CakeContactUs\Model\Entity\ContactUsFormSubmission;
use Closure; use Closure;
use Psr\SimpleCache\CacheInterface; use Psr\SimpleCache\CacheInterface;
@ -126,7 +127,7 @@ class ContactUsFormSubmissionsTable extends Table
if (!$contactUsFormSubmission->isNew()) { if (!$contactUsFormSubmission->isNew()) {
return; return;
} }
$now = DateTime::now()->format(DATETIME_MYSQL); $now = DateTime::now()->format(CakeContactUsPlugin::CAKE_CONTACT_US_MYSQL_DATETIME);
$updateData = []; $updateData = [];
if (Configure::read('ContactUs.email.confirmation.enabled') && isset($contactUsFormSubmission->email)) { if (Configure::read('ContactUs.email.confirmation.enabled') && isset($contactUsFormSubmission->email)) {
$mailer = Configure::read('ContactUs.email.mailerClass', 'CakeContactUs.ContactUsFormSubmissions'); $mailer = Configure::read('ContactUs.email.mailerClass', 'CakeContactUs.ContactUsFormSubmissions');