From: Kartik Kathuria Date: Sat, 1 May 2021 09:49:40 +0000 (+0530) Subject: add form function has been altered to avoid checking variable isCaptcha X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=171d74bc5596b5ffd82063047fe7cb657d1c9166;p=civicrm-core.git add form function has been altered to avoid checking variable isCaptcha --- diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index b05aba6bbc..6f1450dfe6 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -290,7 +290,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $this->buildComponentForm($this->_id, $this); } - if (!$this->get_template_vars("isCaptcha") && \Civi::settings()->get('forceRecaptcha')) { + if (\Civi::settings()->get('forceRecaptcha')) { if (!$this->_userID) { CRM_Utils_ReCAPTCHA::enableCaptchaOnForm($this); } diff --git a/ext/recaptcha/CRM/Utils/ReCAPTCHA.php b/ext/recaptcha/CRM/Utils/ReCAPTCHA.php index c5e8417818..7c77951df4 100644 --- a/ext/recaptcha/CRM/Utils/ReCAPTCHA.php +++ b/ext/recaptcha/CRM/Utils/ReCAPTCHA.php @@ -62,31 +62,33 @@ class CRM_Utils_ReCAPTCHA { */ public static function add(&$form) { $error = NULL; + + // If statement has been altered so that we do not need to check !$this->get_template_vars("isCaptcha") in CRM/Contribute/Form/Contribution/Main.php if (!function_exists('recaptcha_get_html')) { require_once E::path('lib/recaptcha/recaptchalib.php'); - } - // Load the Recaptcha api.js over HTTPS - $useHTTPS = TRUE; + // Load the Recaptcha api.js over HTTPS + $useHTTPS = TRUE; - $html = recaptcha_get_html(\Civi::settings()->get('recaptchaPublicKey'), $error, $useHTTPS); + $html = recaptcha_get_html(\Civi::settings()->get('recaptchaPublicKey'), $error, $useHTTPS); - $form->assign('recaptchaHTML', $html); - $form->assign('recaptchaOptions', \Civi::settings()->get('recaptchaOptions')); - $form->add( - 'text', - 'g-recaptcha-response', - 'reCaptcha', - NULL, - TRUE - ); - $form->registerRule('recaptcha', 'callback', 'validate', 'CRM_Utils_ReCAPTCHA'); - $form->addRule('g-recaptcha-response', E::ts('Please go back and complete the CAPTCHA at the bottom of this form.'), 'recaptcha'); - if ($form->isSubmitted() && empty($form->_submitValues['g-recaptcha-response'])) { - $form->setElementError( + $form->assign('recaptchaHTML', $html); + $form->assign('recaptchaOptions', \Civi::settings()->get('recaptchaOptions')); + $form->add( + 'text', 'g-recaptcha-response', - E::ts('Please go back and complete the CAPTCHA at the bottom of this form.') + 'reCaptcha', + NULL, + TRUE ); + $form->registerRule('recaptcha', 'callback', 'validate', 'CRM_Utils_ReCAPTCHA'); + $form->addRule('g-recaptcha-response', E::ts('Please go back and complete the CAPTCHA at the bottom of this form.'), 'recaptcha'); + if ($form->isSubmitted() && empty($form->_submitValues['g-recaptcha-response'])) { + $form->setElementError( + 'g-recaptcha-response', + E::ts('Please go back and complete the CAPTCHA at the bottom of this form.') + ); + } } }