CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE);
$this->_fields[$key] = $field;
- if ($field['add_captcha']) {
+ // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
+ if ($field['add_captcha'] && !$this->_contactId) {
$addCaptcha = TRUE;
}
}
// initialize the state country map
CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
- if ($addCaptcha &&
- !$viewOnly
- ) {
+ if ($addCaptcha && !$viewOnly) {
$captcha = CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign("isCaptcha", TRUE);
);
$this->_fields[$key] = $field;
}
- if ($field['add_captcha']) {
+ // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
+ if ($field['add_captcha'] && !$this->_userID) {
$addCaptcha = TRUE;
}
}
//have been skip the additional participant.
if ($button == 'skip') {
$field['is_required'] = FALSE;
- }
- elseif ($field['add_captcha']) {
+ }
+ // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
+ elseif ($field['add_captcha'] && !$contactID) {
// only add captcha for first page
$addCaptcha = TRUE;
}
-
list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2);
if ($prefixName == 'state_province' || $prefixName == 'country' || $prefixName == 'county') {
if (!array_key_exists($index, $stateCountryMap)) {
$addCaptcha = TRUE;
- // if recaptcha is not set, then dont add it
+ // if recaptcha is not configured, then dont add it
+ // CRM-11316 Only enable ReCAPTCHA for anonymous visitors
$config = CRM_Core_Config::singleton();
+ $session = CRM_Core_Session::singleton();
+ $contactID = $session->get('userID');
+
if (empty($config->recaptchaPublicKey) ||
- empty($config->recaptchaPrivateKey)
- ) {
+ empty($config->recaptchaPrivateKey) ||
+ $contactID) {
$addCaptcha = FALSE;
}
else {
// add captcha
$captcha = CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
+ $this->assign('isCaptcha', TRUE);
}
$this->addButtons(array(
*/
public $_single;
+ /**
+ * the default values for the form
+ *
+ * @var array
+ * @protected
+ */
+ protected $_defaults;
+
+
public function preProcess() {
$session = CRM_Core_Session::singleton();
$config = CRM_Core_Config::singleton();
}
function setDefaultValues() {
+ $this->_defaults = array();
if ($this->_contactID) {
foreach ($this->_fields as $name => $dontcare) {
$fields[$name] = 1;
}
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
$this->_fields[$key] = $field;
- if ($field['add_captcha']) {
+
+ // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
+ if ($field['add_captcha'] && !$this->_contactID) {
$addCaptcha = TRUE;
}
}
{include file="CRM/Campaign/Form/Petition/Block.tpl" fields=$petitionActivityProfile}
</div>
+ {if $isCaptcha}
+ {include file='CRM/common/ReCAPTCHA.tpl'}
+ {/if}
+
<div class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="bottom"}
</div>
{/if}
{if $isCaptcha}
- {include file='CRM/common/ReCAPTCHA.tpl'}
+ {include file='CRM/common/ReCAPTCHA.tpl'}
{/if}
<div id="crm-submit-buttons" class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="bottom"}
{include file="CRM/UF/Form/Block.tpl" fields=$customPost}
{if $isCaptcha}
- {include file='CRM/common/ReCAPTCHA.tpl'}
+ {include file='CRM/common/ReCAPTCHA.tpl'}
{/if}
<div id="crm-submit-buttons" class="crm-submit-buttons">
</td>
</tr>
</table>
-{include file='CRM/common/ReCAPTCHA.tpl'}
+{if $isCaptcha}
+ {include file='CRM/common/ReCAPTCHA.tpl'}
+{/if}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
</div><!-- end crm-block -->