Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-15067 use email addresses in profile if present Rebase PR#10079 #10349

Merged
merged 2 commits into from
May 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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