Skip to content

Commit

Permalink
Merge pull request #20166 from mattwire/recaptchacontributionbase
Browse files Browse the repository at this point in the history
Simplify reCAPTCHA on ContributionBase form
  • Loading branch information
eileenmcnaughton authored Apr 27, 2021
2 parents 86c9f98 + 6a3bb72 commit 6e53da3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
5 changes: 1 addition & 4 deletions CRM/Contribute/Form/Contribution/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,7 @@ public function buildQuickForm() {

if (count($this->_paymentProcessors) >= 1 && !$this->get_template_vars("isCaptcha") && $this->hasToAddForcefully()) {
if (!$this->_userID) {
$this->enableCaptchaOnForm();
}
else {
$this->displayCaptchaWarning();
CRM_Utils_ReCAPTCHA::enableCaptchaOnForm($this);
}
}

Expand Down
20 changes: 1 addition & 19 deletions CRM/Contribute/Form/ContributionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -827,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.
*/
Expand Down
6 changes: 0 additions & 6 deletions templates/CRM/Contribute/Form/Contribution/Main.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@
{include file="CRM/Contribute/Form/Contribution/PreviewHeader.tpl"}
{/if}

{if $displayCaptchaWarning}
<div class="messages status no-popup">
{ts}To display reCAPTCHA on form you must get an API key from<br /> <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>{/ts}
</div>
{/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}
Expand Down

0 comments on commit 6e53da3

Please sign in to comment.