From cc50ef3a1dd04465b1a3a658c1c9455edb64a11a Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 26 Apr 2021 22:53:23 +0100 Subject: [PATCH 1/2] Use CRM_Utils_ReCAPTCHA::enableCaptchaOnForm directly in ContributionBase --- CRM/Contribute/Form/Contribution/Main.php | 2 +- CRM/Contribute/Form/ContributionBase.php | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index b6c29b41fcc0..4af70d3c8ec3 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -292,7 +292,7 @@ public function buildQuickForm() { if (count($this->_paymentProcessors) >= 1 && !$this->get_template_vars("isCaptcha") && $this->hasToAddForcefully()) { if (!$this->_userID) { - $this->enableCaptchaOnForm(); + CRM_Utils_ReCAPTCHA::enableCaptchaOnForm($this); } else { $this->displayCaptchaWarning(); diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 9749d03e47fe..c90648d8ea69 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -756,19 +756,12 @@ public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = } if ($addCaptcha && !$viewOnly) { - $this->enableCaptchaOnForm(); + CRM_Utils_ReCAPTCHA::enableCaptchaOnForm($this); } } } } - /** - * Enable ReCAPTCHA on Contribution form - */ - protected function enableCaptchaOnForm() { - CRM_Utils_ReCAPTCHA::enableCaptchaOnForm($this); - } - /** * Assign payment field information to the template. * From 6a3bb72a250834c936490ee65e67a9428b04f260 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 26 Apr 2021 23:29:47 +0100 Subject: [PATCH 2/2] Remove warning about reCaptcha missing key from contribution page --- CRM/Contribute/Form/Contribution/Main.php | 3 --- CRM/Contribute/Form/ContributionBase.php | 11 ----------- templates/CRM/Contribute/Form/Contribution/Main.tpl | 6 ------ 3 files changed, 20 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 4af70d3c8ec3..3efe523d922f 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -294,9 +294,6 @@ public function buildQuickForm() { if (!$this->_userID) { CRM_Utils_ReCAPTCHA::enableCaptchaOnForm($this); } - else { - $this->displayCaptchaWarning(); - } } // Build payment processor form diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index c90648d8ea69..58e15df2afd7 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -820,17 +820,6 @@ public function assignPaymentFields() { } } - /** - * Display ReCAPTCHA warning on Contribution form - */ - protected function displayCaptchaWarning() { - if (CRM_Core_Permission::check("administer CiviCRM")) { - if (!CRM_Utils_ReCAPTCHA::hasSettingsAvailable()) { - $this->assign('displayCaptchaWarning', TRUE); - } - } - } - /** * Check if ReCAPTCHA has to be added on Contribution form forcefully. */ diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index 1a8d2180539e..fcbb26bfac41 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -50,12 +50,6 @@ {include file="CRM/Contribute/Form/Contribution/PreviewHeader.tpl"} {/if} - {if $displayCaptchaWarning} -
- {ts}To display reCAPTCHA on form you must get an API key from
https://www.google.com/recaptcha/admin/create{/ts} -
- {/if} - {if call_user_func(array('CRM_Core_Permission','check'), 'administer CiviCRM') } {capture assign="buttonTitle"}{ts}Configure Contribution Page{/ts}{/capture} {crmButton target="_blank" p="civicrm/admin/contribute/settings" q="reset=1&action=update&id=`$contributionPageID`" fb=1 title="$buttonTitle" icon="fa-wrench"}{ts}Configure{/ts}{/crmButton}