Merge pull request #15458 from eileenmcnaughton/excetp
authorMatthew Wire <mjw@mjwconsult.co.uk>
Sun, 13 Oct 2019 15:37:42 +0000 (16:37 +0100)
committerGitHub <noreply@github.com>
Sun, 13 Oct 2019 15:37:42 +0000 (16:37 +0100)
[REF] move definition of important values & retrieval outside payment…

1  2 
CRM/Event/Form/Registration.php
CRM/Event/Form/Registration/Confirm.php

index c313e911d93164b5a577c4e22ec6e728b6220e85,d0c51c77222ea962d15df64dc7174b19359dee26..dbc974bdbeaac717c24bf4a4522563bcfe3f38d7
@@@ -394,6 -394,9 +394,6 @@@ class CRM_Event_Form_Registration exten
  
      // we do not want to display recently viewed items on Registration pages
      $this->assign('displayRecent', FALSE);
 -    // Registration page values are cleared from session, so can't use normal Printer Friendly view.
 -    // Use Browser Print instead.
 -    $this->assign('browserPrint', TRUE);
  
      $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
      $this->assign('isShowLocation', $isShowLocation);
     * Handle process after the confirmation of payment by User.
     *
     * @param int $contactID
 -   * @param null $contribution
 -   * @param null $payment
 +   * @param \CRM_Contribute_BAO_Contribution $contribution
     */
 -  public function confirmPostProcess($contactID = NULL, $contribution = NULL, $payment = NULL) {
 +  public function confirmPostProcess($contactID = NULL, $contribution = NULL) {
      // add/update contact information
 -    $fields = array();
      unset($this->_params['note']);
  
      //to avoid conflict overwrite $this->_params
        // CRM-10032
        $this->processFirstParticipant($participant->id);
      }
+     $this->_params['participantID'] = $participant->id;
+     $this->set('primaryParticipant', $this->_params);
  
      CRM_Core_BAO_CustomValueTable::postProcess($this->_params,
        'civicrm_participant',
        $paymentPartcipant = CRM_Event_BAO_ParticipantPayment::create($paymentParams);
      }
  
-     //set only primary participant's params for transfer checkout.
-     // The concept of contributeMode is deprecated.
-     if (($this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') && !empty($this->_params['is_primary'])) {
-       $this->_params['participantID'] = $participant->id;
-       $this->set('primaryParticipant', $this->_params);
-     }
      $this->assign('action', $this->_action);
  
      // create CMS user
          }
  
          $this->set('value', $value);
 -        $this->confirmPostProcess($contactID, NULL, NULL);
 +        $this->confirmPostProcess($contactID, NULL);
  
          //lets get additional participant id to cancel.
          if ($this->_allowConfirmation && is_array($cancelledIds)) {
index 65d6560c50e05f4548798e2ec336869141814d02,6076724b3d0719f36313128ea4985af7e278104a..8a326a4cf2af3bc7353f716a4f8f96f93ce4d6b4
@@@ -92,7 -92,12 +92,7 @@@ class CRM_Event_Form_Registration_Confi
        $registerParams = $this->_params[0];
        $registerParams = $this->prepareParamsForPaymentProcessor($registerParams);
  
 -      if (isset($registerParams['credit_card_exp_date'])) {
 -        $registerParams['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($registerParams);
 -        $registerParams['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($registerParams);
 -      }
        if ($this->_values['event']['is_monetary']) {
 -        $registerParams['ip_address'] = CRM_Utils_System::ipAddress();
          $registerParams['currencyID'] = $this->_params[0]['currencyID'];
        }
        //assign back primary participant params.
      $payment = $registerByID = $primaryCurrencyID = $contribution = NULL;
      $paymentObjError = ts('The system did not record payment details for this payment and so could not process the transaction. Please report this error to the site administrator.');
  
 -    $this->participantIDS = [];
      $fields = [];
      foreach ($params as $key => $value) {
        CRM_Event_Form_Registration_Confirm::fixLocationFields($value, $fields, $this);
        }
        $this->assign('register_date', $registerDate);
  
 -      $this->confirmPostProcess($contactID, $contribution, $payment);
 +      $this->confirmPostProcess($contactID, $contribution);
      }
  
      //handle if no additional participant.
        $isTest = TRUE;
      }
  
+     $primaryParticipant = $this->get('primaryParticipant');
+     if (empty($primaryParticipant['participantID'])) {
+       CRM_Core_Error::deprecatedFunctionWarning('This line is not logically reachable.');
+       $primaryParticipant['participantID'] = $registerByID;
+     }
+     //otherwise send mail Confirmation/Receipt
+     $primaryContactId = $this->get('primaryContactId');
      // for Transfer checkout.
      // The concept of contributeMode is deprecated.
      if (($this->_contributeMode == 'checkout' ||
        $this->_totalAmount > 0
      ) {
  
-       $primaryParticipant = $this->get('primaryParticipant');
-       if (empty($primaryParticipant['participantID'])) {
-         $primaryParticipant['participantID'] = $registerByID;
-       }
        //build an array of custom profile and assigning it to template
        $customProfile = CRM_Event_BAO_Event::buildCustomProfile($registerByID, $this->_values, NULL, $isTest);
        if (count($customProfile)) {
        }
      }
      else {
-       //otherwise send mail Confirmation/Receipt
-       $primaryContactId = $this->get('primaryContactId');
  
        //build an array of cId/pId of participants
        $additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($registerByID,
      }
  
      //get email primary first if exist
 -    $subscribtionEmail = ['email' => CRM_Utils_Array::value('email-Primary', $params)];
 -    if (!$subscribtionEmail['email']) {
 -      $subscribtionEmail['email'] = CRM_Utils_Array::value("email-{$form->_bltID}", $params);
 +    $subscriptionEmail = ['email' => CRM_Utils_Array::value('email-Primary', $params)];
 +    if (!$subscriptionEmail['email']) {
 +      $subscriptionEmail['email'] = CRM_Utils_Array::value("email-{$form->_bltID}", $params);
      }
      // subscribing contact to groups
 -    if (!empty($subscribeGroupIds) && $subscribtionEmail['email']) {
 -      CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($subscribeGroupIds, $subscribtionEmail, $contactID);
 +    if (!empty($subscribeGroupIds) && $subscriptionEmail['email']) {
 +      CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($subscribeGroupIds, $subscriptionEmail, $contactID);
      }
  
      return $contactID;