From: jitendrapurohit Date: Tue, 12 Jan 2016 05:27:12 +0000 (+0530) Subject: CRM-17797 -- Primary participant can not confirm for additional participants X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c7d52684b0908cc725058d836447c763da7096da;p=civicrm-core.git CRM-17797 -- Primary participant can not confirm for additional participants --- diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 221a4997d0..c0c43b6499 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -2225,4 +2225,32 @@ WHERE (entity_table = 'civicrm_participant' AND entity_id = {$participantId} AND return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); } + /** + *CRM-17797 -- Format fields and setDefaults for primary and additional participants profile + *@param int $contactId + *@param $form array + */ + public static function formatFieldsAndSetProfileDefaults($contactId, &$form) { + if (!$contactId) { + return; + } + $fields = array(); + if (!empty($form->_fields)) { + $removeCustomFieldTypes = array('Participant'); + + foreach ($form->_fields as $name => $dontCare) { + if ((substr($name, 0, 7) == 'custom_' && !$form->_allowConfirmation + && !CRM_Core_BAO_CustomGroup::checkCustomField(substr($name, 7), $removeCustomFieldTypes)) + || substr($name, 0, 12) == 'participant_') { + continue; + } + $fields[$name] = 1; + } + + if (!empty($fields)) { + CRM_Core_BAO_UFGroup::setProfileDefaults($contactId, $fields, $form->_defaults); + } + } + } + } diff --git a/CRM/Event/Form/Registration/AdditionalParticipant.php b/CRM/Event/Form/Registration/AdditionalParticipant.php index d9692d3a09..4b30cbc9f1 100644 --- a/CRM/Event/Form/Registration/AdditionalParticipant.php +++ b/CRM/Event/Form/Registration/AdditionalParticipant.php @@ -125,6 +125,8 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R $this->_discountId = $discountId; $this->_pId = $this->_additionalParticipantId; $this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_additionalParticipantId, 'contact_id'); + + CRM_Event_BAO_Participant::formatFieldsAndSetProfileDefaults($this->_contactId, $this); $participantDefaults = CRM_Event_Form_EventFees::setDefaultValues($this); $participantDefaults = array_merge($this->_defaults, $participantDefaults); // use primary email address if billing email address is empty diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index 7a39c7e920..d1cef8f286 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -132,32 +132,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $contactID = $this->getContactID(); CRM_Core_Payment_Form::setDefaultValues($this, $contactID); - if ($contactID) { - $fields = array(); - - if (!empty($this->_fields)) { - $removeCustomFieldTypes = array('Participant'); - foreach ($this->_fields as $name => $dontCare) { - if (substr($name, 0, 7) == 'custom_') { - $id = substr($name, 7); - if (!$this->_allowConfirmation && - !CRM_Core_BAO_CustomGroup::checkCustomField($id, $removeCustomFieldTypes) - ) { - continue; - } - // ignore component fields - } - elseif ((substr($name, 0, 12) == 'participant_')) { - continue; - } - $fields[$name] = 1; - } - } - } - - if (!empty($fields)) { - CRM_Core_BAO_UFGroup::setProfileDefaults($contactID, $fields, $this->_defaults); - } + CRM_Event_BAO_Participant::formatFieldsAndSetProfileDefaults($contactID, $this); // Set default payment processor as default payment_processor radio button value if (!empty($this->_paymentProcessors)) {