From 9d7cae22abfc66189064cd3f8b717bc4e6abe66b Mon Sep 17 00:00:00 2001 From: Dave Greenberg Date: Thu, 12 Jun 2014 15:34:49 -0700 Subject: [PATCH] CRM-14851 - Validation of profile type for on behalf of profiles was checking the wrong profile. ---------------------------------------- * CRM-14851: https://issues.civicrm.org/jira/browse/CRM-14851 --- CRM/Contribute/Form/Contribution/Main.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 3de6ec707d..cfa8c8a2cd 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -140,13 +140,21 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu //CRM-5001 if (!empty($this->_values['is_for_organization'])) { $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.'); - if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) { - $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID); + $ufJoinParams = array( + 'module' => 'onBehalf', + 'entity_table' => 'civicrm_contribution_page', + 'entity_id' => $this->_id, + ); + $onBehalfProfileIDs = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); + // getUFGroupIDs returns an array with the first item being the ID we need + $onBehalfProfileID = $onBehalfProfileIDs[0]; + if ($onBehalfProfileID) { + $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($onBehalfProfileID); foreach (array( 'Individual', 'Organization', 'Household') as $contactType) { - if (in_array($contactType, $preProfile) && - (in_array('Membership', $preProfile) || - in_array('Contribution', $preProfile) + if (in_array($contactType, $onBehalfProfile) && + (in_array('Membership', $onBehalfProfile) || + in_array('Contribution', $onBehalfProfile) ) ) { CRM_Core_Error::fatal($msg); -- 2.25.1