Skip to content

Commit

Permalink
Further work to convert participant emails to multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Nov 14, 2019
1 parent 62c1164 commit 5fb827c
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2816,24 +2816,22 @@ public function loadRelatedObjects(&$input, &$ids, $loadAll = FALSE) {
// make sure event exists and is valid
$event = new CRM_Event_BAO_Event();
$event->id = $ids['event'];
if ($ids['event'] &&
!$event->find(TRUE)
) {
if ($ids['event'] && !$event->find(TRUE)) {
throw new Exception("Could not find event: " . $ids['event']);
}

$this->_relatedObjects['event'] = &$event;
$this->_relatedObjects['event'] = $event;

$participant = new CRM_Event_BAO_Participant();
$participant->id = $ids['participant'];
if ($ids['participant'] &&
!$participant->find(TRUE)
) {
throw new Exception("Could not find participant: " . $ids['participant']);
}
$participant->register_date = CRM_Utils_Date::isoToMysql($participant->register_date);
foreach ($ids['participant'] ?? [] as $participantID) {
$participant = new CRM_Event_BAO_Participant();
$participant->id = $participantID;
if (!$participant->find(TRUE)) {
throw new Exception("Could not find participant: " . $participantID);
}
$participant->register_date = CRM_Utils_Date::isoToMysql($participant->register_date);

$this->_relatedObjects['participant'] = &$participant;
$this->_relatedObjects['participant'][] = $participant;
}

// get the payment processor id from event - this is inaccurate see CRM-16923
// in future we should look at throwing an exception here rather than an dubious guess.
Expand Down Expand Up @@ -3129,7 +3127,9 @@ public function _gatherMessageValues($input, &$values, $ids = []) {
}
}
else {
$values = array_merge($values, $this->loadEventMessageTemplateParams((int) $ids['event'], (int) $this->_relatedObjects['participant']->id, $this->id));
$values = array_merge($values,
$this->loadEventMessageTemplateParams((int) $ids['event'], (int) $this->_relatedObjects['participant']->id, $this->id)
);
}

$groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', NULL, $this->id);
Expand Down Expand Up @@ -4477,7 +4477,6 @@ public static function completeOrder($input, &$ids, $objects, $transaction, $rec
$inputContributionWhiteList[] = 'financial_type_id';
}

$participant = CRM_Utils_Array::value('participant', $objects);
$recurContrib = CRM_Utils_Array::value('contributionRecur', $objects);
$recurringContributionID = (empty($recurContrib->id)) ? NULL : $recurContrib->id;
$event = CRM_Utils_Array::value('event', $objects);
Expand Down Expand Up @@ -4570,9 +4569,12 @@ public static function completeOrder($input, &$ids, $objects, $transaction, $rec
// @todo this should be set by the function that sends the mail after sending.
$contributionParams['receipt_date'] = $changeDate;
}
$participantParams['id'] = $participant->id;
$participantParams['status_id'] = 'Registered';
civicrm_api3('Participant', 'create', $participantParams);
foreach ($objects['participant'] as $participantObject) {
// Update all related participants to registered
$participantParams['id'] = $participantObject->id;
$participantParams['status_id'] = 'Registered';
civicrm_api3('Participant', 'create', $participantParams);
}
}
}

Expand Down

0 comments on commit 5fb827c

Please sign in to comment.