Skip to content

Commit

Permalink
Merge pull request #10349 from kcristiano/15067
Browse files Browse the repository at this point in the history
CRM-15067 use email addresses in profile if present Rebase PR#10079
  • Loading branch information
colemanw authored May 13, 2017
2 parents cf1b10c + d4b2ab5 commit 090269a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
14 changes: 8 additions & 6 deletions CRM/Contribute/Form/Contribution/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,14 @@ public function buildQuickForm() {

$this->applyFilter('__ALL__', 'trim');
if (empty($this->_ccid)) {
$this->add('text', "email-{$this->_bltID}",
ts('Email Address'),
array('size' => 30, 'maxlength' => 60, 'class' => 'email'),
TRUE
);
$this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
if ($this->_emailExists == FALSE) {
$this->add('text', "email-{$this->_bltID}",
ts('Email Address'),
array('size' => 30, 'maxlength' => 60, 'class' => 'email'),
TRUE
);
$this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
}
}
else {
$this->addElement('hidden', "email-{$this->_bltID}", 1);
Expand Down
23 changes: 17 additions & 6 deletions CRM/Contribute/Form/ContributionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
*/
public $_isBillingAddressRequiredForPayLater;

/**
* Flag if email field exists in embedded profile
*
* @var bool
*/
public $_emailExists = FALSE;

/**
* Is this a backoffice form
* (this will affect whether paypal express code is displayed)
Expand Down Expand Up @@ -639,10 +646,12 @@ public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType =
);

if ($fields) {
// unset any email-* fields since we already collect it, CRM-2888
foreach (array_keys($fields) as $fieldName) {
if (substr($fieldName, 0, 6) == 'email-' && !in_array($profileContactType, array('honor', 'onbehalf'))) {
unset($fields[$fieldName]);
// determine if email exists in profile so we know if we need to manually insert CRM-2888, CRM-15067
foreach ($fields as $key => $field) {
if (substr($key, 0, 6) == 'email-' &&
!in_array($profileContactType, array('honor', 'onbehalf'))
) {
$this->_emailExists = TRUE;
}
}

Expand Down Expand Up @@ -834,11 +843,13 @@ public function buildComponentForm($id, $form) {
if (empty($member['is_active'])) {
$msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
$onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($form->_values['onbehalf_profile_id']);
foreach (array(
foreach (
array(
'Individual',
'Organization',
'Household',
) as $contactType) {
) as $contactType
) {
if (in_array($contactType, $onBehalfProfile) &&
(in_array('Membership', $onBehalfProfile) ||
in_array('Contribution', $onBehalfProfile)
Expand Down

0 comments on commit 090269a

Please sign in to comment.