CRM-17797 -- Primary participant can not confirm for additional participants
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 12 Jan 2016 05:27:12 +0000 (10:57 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 12 Jan 2016 05:27:12 +0000 (10:57 +0530)
CRM/Event/BAO/Participant.php
CRM/Event/Form/Registration/AdditionalParticipant.php
CRM/Event/Form/Registration/Register.php

index 221a4997d054ced495be8ffc319b850fbe613a97..c0c43b6499bb85e4cdc2b40b63ec223a2bfa88b6 100644 (file)
@@ -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);
+      }
+    }
+  }
+
 }
index d9692d3a09d57f3579977b36f25e867472078260..4b30cbc9f1b59806e95e700188c602f94a049099 100644 (file)
@@ -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
index 7a39c7e920bd325dd2e87af2f45c85d19dd37d09..d1cef8f286a3b34fbc92dfa29226c633e284f3c8 100644 (file)
@@ -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)) {