|
|
@@ -8,7 +8,6 @@ use Cake\Core\Configure;
|
|
|
|
use Cake\Datasource\EntityInterface;
|
|
|
|
use Cake\Datasource\EntityInterface;
|
|
|
|
use Cake\Http\Response;
|
|
|
|
use Cake\Http\Response;
|
|
|
|
use Cake\I18n\DateTime;
|
|
|
|
use Cake\I18n\DateTime;
|
|
|
|
use Cake\Log\Log;
|
|
|
|
|
|
|
|
use Cake\ORM\Table;
|
|
|
|
use Cake\ORM\Table;
|
|
|
|
use Cake\ORM\TableRegistry;
|
|
|
|
use Cake\ORM\TableRegistry;
|
|
|
|
use CakeContactUs\CakeContactUsPlugin;
|
|
|
|
use CakeContactUs\CakeContactUsPlugin;
|
|
|
@@ -55,7 +54,6 @@ 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->getController()->viewBuilder()->addHelpers(['Captcha.Captcha']);
|
|
|
|
$this->getController()->viewBuilder()->addHelpers(['Captcha.Captcha']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -64,7 +62,7 @@ class ContactUsComponent extends Component {
|
|
|
|
* @return \Cake\Datasource\EntityInterface|\CakeContactUs\Model\Entity\ContactUsFormSubmission
|
|
|
|
* @return \Cake\Datasource\EntityInterface|\CakeContactUs\Model\Entity\ContactUsFormSubmission
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function newContactUsForm() {
|
|
|
|
public function newContactUsForm() {
|
|
|
|
if ($this->getConfig('requireCaptcha')) {
|
|
|
|
if ($this->getConfig('requireCaptcha') && PHP_SAPI !== 'cli') {
|
|
|
|
$this->ContactUsFormSubmissions->addBehavior('Captcha.Captcha');
|
|
|
|
$this->ContactUsFormSubmissions->addBehavior('Captcha.Captcha');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -80,8 +78,7 @@ class ContactUsComponent extends Component {
|
|
|
|
if (!isset($postData)) {
|
|
|
|
if (!isset($postData)) {
|
|
|
|
$postData = $this->getController()->getRequest()->getData();
|
|
|
|
$postData = $this->getController()->getRequest()->getData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$postData['client_ip'] = array_key_exists('client_ip', $postData) && $postData['client_ip'] ?
|
|
|
|
$postData['client_ip'] = $postData['client_ip'] ??
|
|
|
|
$postData['client_ip'] :
|
|
|
|
|
|
|
|
($this->getConfig('clientIpHeader') ?
|
|
|
|
($this->getConfig('clientIpHeader') ?
|
|
|
|
$this->getController()->getRequest()->getHeaderLine($this->getConfig('clientIpHeader')) :
|
|
|
|
$this->getController()->getRequest()->getHeaderLine($this->getConfig('clientIpHeader')) :
|
|
|
|
$this->getController()->getRequest()->clientIp()
|
|
|
|
$this->getController()->getRequest()->clientIp()
|
|
|
@@ -92,14 +89,9 @@ class ContactUsComponent extends Component {
|
|
|
|
'contactUsFormSubmission' => $contactUsFormSubmission,
|
|
|
|
'contactUsFormSubmission' => $contactUsFormSubmission,
|
|
|
|
], $this->getController());
|
|
|
|
], $this->getController());
|
|
|
|
$result = $event->getResult();
|
|
|
|
$result = $event->getResult();
|
|
|
|
|
|
|
|
|
|
|
|
if ($result instanceof EntityInterface) {
|
|
|
|
if ($result instanceof EntityInterface) {
|
|
|
|
$postData = $result->toArray();
|
|
|
|
$postData = $result->toArray();
|
|
|
|
$contactUsFormSubmission = $this->ContactUsFormSubmissions->patchEntity($contactUsFormSubmission, $postData);
|
|
|
|
$contactUsFormSubmission = $this->ContactUsFormSubmissions->patchEntity($contactUsFormSubmission, $postData);
|
|
|
|
if ($contactUsFormSubmission->getErrors()) {
|
|
|
|
|
|
|
|
Log::debug(print_r('$contactUsFormSubmission->getErrors()', true));
|
|
|
|
|
|
|
|
Log::debug(print_r($contactUsFormSubmission->getErrors(), true));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$contactUsFormSubmissionSaved = $this->ContactUsFormSubmissions->save($contactUsFormSubmission);
|
|
|
|
$contactUsFormSubmissionSaved = $this->ContactUsFormSubmissions->save($contactUsFormSubmission);
|
|
|
|
if ($contactUsFormSubmissionSaved) {
|
|
|
|
if ($contactUsFormSubmissionSaved) {
|
|
|
|
return $this->_afterFormSaved($contactUsFormSubmissionSaved);
|
|
|
|
return $this->_afterFormSaved($contactUsFormSubmissionSaved);
|
|
|
@@ -115,11 +107,6 @@ class ContactUsComponent extends Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$contactUsFormSubmission = $this->ContactUsFormSubmissions->patchEntity($contactUsFormSubmission, $postData);
|
|
|
|
$contactUsFormSubmission = $this->ContactUsFormSubmissions->patchEntity($contactUsFormSubmission, $postData);
|
|
|
|
if ($contactUsFormSubmission->getErrors()) {
|
|
|
|
|
|
|
|
Log::debug(print_r('$contactUsFormSubmission->getErrors()', true));
|
|
|
|
|
|
|
|
Log::debug(print_r($contactUsFormSubmission->getErrors(), true));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$contactUsFormSubmissionSaved = $this->ContactUsFormSubmissions->save($contactUsFormSubmission);
|
|
|
|
$contactUsFormSubmissionSaved = $this->ContactUsFormSubmissions->save($contactUsFormSubmission);
|
|
|
|
|
|
|
|
|
|
|
|
if ($contactUsFormSubmissionSaved) {
|
|
|
|
if ($contactUsFormSubmissionSaved) {
|
|
|
|