Skip to content

Commit

Permalink
fix CRM-3467
Browse files Browse the repository at this point in the history
  • Loading branch information
Donald Lobo committed Jan 12, 2009
1 parent 5a6ee66 commit e745abc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
37 changes: 32 additions & 5 deletions CRM/Mailing/Form/Subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,25 @@ class CRM_Mailing_Form_Subscribe extends CRM_Core_Form
{
protected $_groupID = null;

protected $_redirect = null;

function preProcess( )
{
parent::preProcess( );
$this->_groupID = CRM_Utils_Request::retrieve( 'gid', 'Integer', $this );
$this->_groupID = CRM_Utils_Request::retrieve( 'gid', 'Integer', $this,
false, null, 'REQUEST' );

require_once 'CRM/Utils/Rule.php';
$this->_redirect = CRM_Utils_Request::retrieve( 'url', 'String', $this,
false, null, 'REQUEST' );

if ( ! $this->_redirect ||
! CRM_Utils_Rule::url( $this->_redirect ) ) {
$config =& CRM_Core_Config::singleton( );
$this->_redirect = $config->userFrameworkBaseURL;
}
$session =& CRM_Core_Session::singleton( );
$session->pushUserContext( $this->_redirect );

require_once 'CRM/Contact/BAO/Group.php';

Expand Down Expand Up @@ -123,10 +138,22 @@ public function buildQuickForm( )
$this->addFormRule( array( 'CRM_Mailing_Form_Subscribe', 'formRule' ) );
}

// add captcha
require_once 'CRM/Utils/ReCAPTCHA.php';
$captcha =& CRM_Utils_ReCAPTCHA::singleton( );
$captcha->add( $this );
$addCaptcha = true;

// if this is POST request and came from a block,
// lets add recaptcha only if already present
// gross hack for now
if ( ! empty( $_POST ) &&
! array_key_exists( 'recaptcha_challenge_field', $_POST ) ) {
$addCaptcha = false;
}

if ( $addCaptcha ) {
// add captcha
require_once 'CRM/Utils/ReCAPTCHA.php';
$captcha =& CRM_Utils_ReCAPTCHA::singleton( );
$captcha->add( $this );
}

$this->addButtons( array(
array ( 'type' => 'next',
Expand Down
2 changes: 2 additions & 0 deletions templates/CRM/common/ReCAPTCHA.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{if $recaptchaHTML}
<tr>
<td class="label">&nbsp;</td>
<td>
Expand All @@ -7,3 +8,4 @@
</noscript>
</td>
</tr>
{/if}

0 comments on commit e745abc

Please sign in to comment.