Skip to content

Commit

Permalink
veda-consulting-company#103 - Option to enable reCaptcha in GDPR Comm…
Browse files Browse the repository at this point in the history
…unication preference form
  • Loading branch information
Rajesh Kumar authored and Rajesh Kumar committed May 23, 2018
1 parent 1e3b523 commit d95cdd6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CRM/Gdpr/Form/CommunicationsPreferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,22 @@ public function buildQuickForm() {
false
);
$descriptions['use_as_mailing_subscribe'] = E::ts('Check to use the Communications Preferences page instead of the default Mailing Subscribe page.');
$this->add(
'advcheckbox',
'add_captcha',
E::ts('Include reCAPTCHA?'),
'',
false
);
$recaptchaSettingsUrl = CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1');
$descriptions['add_captcha'] = E::ts('Check to use reCAPTCHA in Communications Preferences page. Make sure you have configured the <a href="'.$recaptchaSettingsUrl.'">reCAPTCHA keys</a>.');
// Let the template know about elements in this section.
$page_elements = array(
'page_title',
'page_intro',
'profile',
'use_as_mailing_subscribe'
'use_as_mailing_subscribe',
'add_captcha'
);
$this->assign('page_elements', $page_elements);
// Comms prefs channels
Expand Down
8 changes: 8 additions & 0 deletions CRM/Gdpr/Form/UpdatePreference.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ public function buildQuickForm() {
$this->assign('page_intro', $introText);
}

//Include reCAPTCHA?
$addCaptcha = $this->commPrefSettings['add_captcha'];
if ($addCaptcha) {
$captcha = CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign('isCaptcha', TRUE);
}

//Check the channels are enabled ?
$channelEleNames = array();
$isChannelsEnabled = $this->commPrefSettings['enable_channels'];
Expand Down
4 changes: 4 additions & 0 deletions templates/CRM/Gdpr/Form/UpdatePreference.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@
</div>
</fieldset>

{if $isCaptcha}
{include file='CRM/common/ReCAPTCHA.tpl'}
{/if}

<div class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="bottom"}
</div>
Expand Down

0 comments on commit d95cdd6

Please sign in to comment.