3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
14 * @copyright CiviCRM LLC https://civicrm.org/licensing
18 * This class generates form components for processing Event.
20 class CRM_Event_Form_Registration
extends CRM_Core_Form
{
22 use CRM_Financial_Form_FrontEndPaymentFormTrait
;
25 * How many locationBlocks should we display?
30 const LOCATION_BLOCKS
= 1;
33 * The id of the event we are proceessing.
40 * The array of ids of all the participant we are proceessing.
44 protected $_participantIDS = NULL;
47 * The id of the participant we are proceessing.
51 protected $_participantId;
54 * Is participant able to walk registration wizard.
58 public $_allowConfirmation;
61 * Is participant requires approval.
65 public $_requireApproval;
68 * Is event configured for waitlist.
72 public $_allowWaitlist;
75 * Store additional participant ids.
76 * when there are pre-registered.
80 public $_additionalParticipantIds;
83 * The values for the contribution db object.
90 * The paymentProcessor attributes for this page.
94 public $_paymentProcessor;
97 * The params submitted by the form and computed by the app.
104 * The fields involved in this contribution page.
111 * The billing location id for this contribiution page.
118 * Price Set ID, if the new price set method is used
122 public $_priceSetId = NULL;
125 * Array of fields for the price set.
136 * Is event already full.
143 public $_isEventFull;
147 public $_lineItemParticipantsCount;
149 public $_availableRegistrations;
155 public $_isBillingAddressRequiredForPayLater;
158 * Is this a back office form
162 public $isBackOffice = FALSE;
165 * Payment instrument iD for the transaction.
167 * This will generally be drawn from the payment processor and is ignored for
172 public $paymentInstrumentID;
175 * Set variables up before form is built.
177 public function preProcess() {
178 $this->_eventId
= CRM_Utils_Request
::retrieve('id', 'Positive', $this, TRUE);
179 $this->_action
= CRM_Utils_Request
::retrieve('action', 'Alphanumeric', $this, FALSE, CRM_Core_Action
::ADD
);
181 $this->_participantId
= CRM_Utils_Request
::retrieve('participantId', 'Positive', $this);
182 $this->setPaymentMode();
184 $this->_values
= $this->get('values');
185 $this->_fields
= $this->get('fields');
186 $this->_bltID
= $this->get('bltID');
187 $this->_paymentProcessor
= $this->get('paymentProcessor');
188 $this->_priceSetId
= $this->get('priceSetId');
189 $this->_priceSet
= $this->get('priceSet');
190 $this->_lineItem
= $this->get('lineItem');
191 $this->_isEventFull
= $this->get('isEventFull');
192 $this->_lineItemParticipantsCount
= $this->get('lineItemParticipants');
193 if (!is_array($this->_lineItem
)) {
194 $this->_lineItem
= [];
196 if (!is_array($this->_lineItemParticipantsCount
)) {
197 $this->_lineItemParticipantsCount
= [];
199 $this->_availableRegistrations
= $this->get('availableRegistrations');
200 $this->_participantIDS
= $this->get('participantIDs');
202 //check if participant allow to walk registration wizard.
203 $this->_allowConfirmation
= $this->get('allowConfirmation');
205 // check for Approval
206 $this->_requireApproval
= $this->get('requireApproval');
208 // check for waitlisting.
209 $this->_allowWaitlist
= $this->get('allowWaitlist');
211 //get the additional participant ids.
212 $this->_additionalParticipantIds
= $this->get('additionalParticipantIds');
213 $config = CRM_Core_Config
::singleton();
215 if (!$this->_values
) {
216 // create redirect URL to send folks back to event info page is registration not available
217 $infoUrl = CRM_Utils_System
::url('civicrm/event/info', "reset=1&id={$this->_eventId}",
218 FALSE, NULL, FALSE, TRUE
221 // this is the first time we are hitting this, so check for permissions here
222 if (!CRM_Core_Permission
::event(CRM_Core_Permission
::EDIT
, $this->_eventId
, 'register for events')) {
223 CRM_Core_Error
::statusBounce(ts('You do not have permission to register for this event'), $infoUrl);
226 // get all the values from the dao object
227 $this->_values
= $this->_fields
= [];
229 //retrieve event information
230 $params = ['id' => $this->_eventId
];
231 CRM_Event_BAO_Event
::retrieve($params, $this->_values
['event']);
232 // check for is_monetary status
233 $isMonetary = $this->_values
['event']['is_monetary'] ??
NULL;
234 // check for ability to add contributions of type
236 && CRM_Financial_BAO_FinancialType
::isACLFinancialTypeStatus()
237 && !CRM_Core_Permission
::check('add contributions of type ' . CRM_Contribute_PseudoConstant
::financialType($this->_values
['event']['financial_type_id']))
239 CRM_Core_Error
::statusBounce(ts('You do not have permission to access this page.'));
242 $this->checkValidEvent($infoUrl);
243 // get the participant values, CRM-4320
244 $this->_allowConfirmation
= FALSE;
245 if ($this->_participantId
) {
246 $this->processFirstParticipant($this->_participantId
);
248 //check for additional participants.
249 if ($this->_allowConfirmation
&& $this->_values
['event']['is_multiple_registrations']) {
250 $additionalParticipantIds = CRM_Event_BAO_Participant
::getAdditionalParticipantIds($this->_participantId
);
252 foreach ($additionalParticipantIds as $additionalParticipantId) {
253 $this->_additionalParticipantIds
[$cnt] = $additionalParticipantId;
256 $this->set('additionalParticipantIds', $this->_additionalParticipantIds
);
259 $eventFull = CRM_Event_BAO_Participant
::eventFull($this->_eventId
, FALSE,
260 CRM_Utils_Array
::value('has_waitlist', $this->_values
['event'])
263 $this->_allowWaitlist
= $this->_isEventFull
= FALSE;
264 if ($eventFull && !$this->_allowConfirmation
) {
265 $this->_isEventFull
= TRUE;
266 //lets redirecting to info only when to waiting list.
267 $this->_allowWaitlist
= $this->_values
['event']['has_waitlist'] ??
NULL;
268 if (!$this->_allowWaitlist
) {
269 CRM_Utils_System
::redirect($infoUrl);
272 $this->set('isEventFull', $this->_isEventFull
);
273 $this->set('allowWaitlist', $this->_allowWaitlist
);
275 //check for require requires approval.
276 $this->_requireApproval
= FALSE;
277 if (!empty($this->_values
['event']['requires_approval']) && !$this->_allowConfirmation
) {
278 $this->_requireApproval
= TRUE;
280 $this->set('requireApproval', $this->_requireApproval
);
282 if (isset($this->_values
['event']['default_role_id'])) {
283 $participant_role = CRM_Core_OptionGroup
::values('participant_role');
284 $this->_values
['event']['participant_role'] = $participant_role["{$this->_values['event']['default_role_id']}"];
286 $isPayLater = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event', $this->_eventId
, 'is_pay_later');
287 $this->setPayLaterLabel($isPayLater ?
$this->_values
['event']['pay_later_text'] : '');
288 //check for various combinations for paylater, payment
289 //process with paid event.
290 if ($isMonetary && (!$isPayLater ||
!empty($this->_values
['event']['payment_processor']))) {
291 $this->_paymentProcessorIDs
= explode(CRM_Core_DAO
::VALUE_SEPARATOR
, CRM_Utils_Array
::value('payment_processor',
292 $this->_values
['event']
294 $this->assignPaymentProcessor($isPayLater);
297 self
::initEventFee($this, $this->_eventId
);
299 // get the profile ids
301 'entity_table' => 'civicrm_event',
302 // CRM-4377:Â CiviEvent for the main participant, CiviEvent_Additional for additional participants
303 'module' => 'CiviEvent',
304 'entity_id' => $this->_eventId
,
306 list($this->_values
['custom_pre_id'],
307 $this->_values
['custom_post_id']
308 ) = CRM_Core_BAO_UFJoin
::getUFGroupIds($ufJoinParams);
310 // set profiles for additional participants
311 if ($this->_values
['event']['is_multiple_registrations']) {
312 // CRM-4377:Â CiviEvent for the main participant, CiviEvent_Additional for additional participants
313 $ufJoinParams['module'] = 'CiviEvent_Additional';
315 list($this->_values
['additional_custom_pre_id'],
316 $this->_values
['additional_custom_post_id'], $preActive, $postActive
317 ) = CRM_Core_BAO_UFJoin
::getUFGroupIds($ufJoinParams);
319 // CRM-4377:Â we need to maintain backward compatibility, hence if there is profile for main contact
320 // set same profile for additional contacts.
321 if ($this->_values
['custom_pre_id'] && !$this->_values
['additional_custom_pre_id']) {
322 $this->_values
['additional_custom_pre_id'] = $this->_values
['custom_pre_id'];
325 if ($this->_values
['custom_post_id'] && !$this->_values
['additional_custom_post_id']) {
326 $this->_values
['additional_custom_post_id'] = $this->_values
['custom_post_id'];
328 // now check for no profile condition, in that case is_active = 0
329 if (isset($preActive) && !$preActive) {
330 unset($this->_values
['additional_custom_pre_id']);
332 if (isset($postActive) && !$postActive) {
333 unset($this->_values
['additional_custom_post_id']);
337 $this->assignBillingType();
339 if ($this->_values
['event']['is_monetary']) {
340 CRM_Core_Payment_Form
::setPaymentFieldsByProcessor($this, $this->_paymentProcessor
);
342 $params = ['entity_id' => $this->_eventId
, 'entity_table' => 'civicrm_event'];
343 $this->_values
['location'] = CRM_Core_BAO_Location
::getValues($params, TRUE);
345 $this->set('values', $this->_values
);
346 $this->set('fields', $this->_fields
);
348 $this->_availableRegistrations
349 = CRM_Event_BAO_Participant
::eventFull(
350 $this->_values
['event']['id'], TRUE,
351 CRM_Utils_Array
::value('has_waitlist', $this->_values
['event'])
353 $this->set('availableRegistrations', $this->_availableRegistrations
);
355 $this->assign_by_ref('paymentProcessor', $this->_paymentProcessor
);
357 // check if this is a paypal auto return and redirect accordingly
358 if (CRM_Core_Payment
::paypalRedirect($this->_paymentProcessor
)) {
359 $url = CRM_Utils_System
::url('civicrm/event/register',
360 "_qf_ThankYou_display=1&qfKey={$this->controller->_key}"
362 CRM_Utils_System
::redirect($url);
364 // The concept of contributeMode is deprecated.
365 $this->_contributeMode
= $this->get('contributeMode');
366 $this->assign('contributeMode', $this->_contributeMode
);
368 $this->setTitle($this->_values
['event']['title']);
370 $this->assign('paidEvent', $this->_values
['event']['is_monetary']);
372 // we do not want to display recently viewed items on Registration pages
373 $this->assign('displayRecent', FALSE);
375 $isShowLocation = $this->_values
['event']['is_show_location'] ??
NULL;
376 $this->assign('isShowLocation', $isShowLocation);
378 $pcpId = CRM_Utils_Request
::retrieve('pcpId', 'Positive', $this);
380 $pcp = CRM_PCP_BAO_PCP
::handlePcp($pcpId, 'event', $this->_values
['event']);
381 $this->_pcpId
= $pcp['pcpId'];
382 $this->_values
['event']['intro_text'] = $pcp['pcpInfo']['intro_text'] ??
NULL;
385 // assign all event properties so wizard templates can display event info.
386 $this->assign('event', $this->_values
['event']);
387 $this->assign('location', $this->_values
['location']);
388 $this->assign('bltID', $this->_bltID
);
389 $isShowLocation = $this->_values
['event']['is_show_location'] ??
NULL;
390 $this->assign('isShowLocation', $isShowLocation);
391 CRM_Contribute_BAO_Contribution_Utils
::overrideDefaultCurrency($this->_values
['event']);
393 //lets allow user to override campaign.
394 $campID = CRM_Utils_Request
::retrieve('campID', 'Positive', $this);
395 if ($campID && CRM_Core_DAO
::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
396 $this->_values
['event']['campaign_id'] = $campID;
399 // Set the same value for is_billing_required as contribution page so code can be shared.
400 $this->_values
['is_billing_required'] = $this->_values
['event']['is_billing_required'] ??
NULL;
401 // check if billing block is required for pay later
402 // note that I have started removing the use of isBillingAddressRequiredForPayLater in favour of letting
403 // the CRM_Core_Payment_Manual class handle it - but there are ~300 references to it in the code base so only
404 // removing in very limited cases.
405 if (!empty($this->_values
['event']['is_pay_later'])) {
406 $this->_isBillingAddressRequiredForPayLater
= $this->_values
['event']['is_billing_required'] ??
NULL;
407 $this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater
);
412 * Assign the minimal set of variables to the template.
414 public function assignToTemplate() {
415 //process only primary participant params
416 $this->_params
= $this->get('params');
417 if (isset($this->_params
[0])) {
418 $params = $this->_params
[0];
421 if (!empty($params['billing_first_name'])) {
422 $name = $params['billing_first_name'];
425 if (!empty($params['billing_middle_name'])) {
426 $name .= " {$params['billing_middle_name']}";
429 if (!empty($params['billing_last_name'])) {
430 $name .= " {$params['billing_last_name']}";
432 $this->assign('billingName', $name);
433 $this->set('name', $name);
444 foreach ($vars as $v) {
445 if (!empty($params[$v])) {
446 if ($v == 'receive_date') {
447 $this->assign($v, CRM_Utils_Date
::mysqlToIso($params[$v]));
450 $this->assign($v, $params[$v]);
453 elseif (empty($params['amount'])) {
454 $this->assign($v, CRM_Utils_Array
::value($v, $params));
458 $this->assign('address', CRM_Utils_Address
::getFormattedBillingAddressFieldsFromParameters($params, $this->_bltID
));
460 // The concept of contributeMode is deprecated.
461 if ($this->_contributeMode
== 'direct' && empty($params['is_pay_later'])) {
462 $date = CRM_Utils_Date
::format(CRM_Utils_Array
::value('credit_card_exp_date', $params));
463 $date = CRM_Utils_Date
::mysqlToIso($date);
464 $this->assign('credit_card_exp_date', $date);
465 $this->assign('credit_card_number',
466 CRM_Utils_System
::mungeCreditCard(CRM_Utils_Array
::value('credit_card_number', $params))
470 // get the email that the confirmation would have been sent to
471 $session = CRM_Core_Session
::singleton();
473 // assign is_email_confirm to templates
474 if (isset($this->_values
['event']['is_email_confirm'])) {
475 $this->assign('is_email_confirm', $this->_values
['event']['is_email_confirm']);
478 // assign pay later stuff
479 $params['is_pay_later'] = CRM_Utils_Array
::value('is_pay_later', $params, FALSE);
480 $this->assign('is_pay_later', $params['is_pay_later']);
481 if ($params['is_pay_later']) {
482 $this->assign('pay_later_text', $this->getPayLaterLabel());
483 $this->assign('pay_later_receipt', $this->_values
['event']['pay_later_receipt']);
486 // also assign all participantIDs to the template
487 // useful in generating confirmation numbers if needed
488 $this->assign('participantIDs', $this->_participantIDS
);
492 * Add the custom fields.
495 * @param string $name
496 * @param bool $viewOnly
498 public function buildCustom($id, $name, $viewOnly = FALSE) {
500 $button = substr($this->controller
->getButtonName(), -4);
501 $cid = CRM_Utils_Request
::retrieve('cid', 'Positive', $this);
502 $session = CRM_Core_Session
::singleton();
503 $contactID = $session->get('userID');
505 // we don't allow conflicting fields to be
506 // configured via profile
508 'participant_fee_amount' => 1,
509 'participant_fee_level' => 1,
515 foreach ($id as $profileID) {
516 $field = CRM_Core_BAO_UFGroup
::getFields($profileID, FALSE, CRM_Core_Action
::ADD
,
517 NULL, NULL, FALSE, NULL,
518 FALSE, NULL, CRM_Core_Permission
::CREATE
,
521 $fields = array_merge($fields, $field);
525 if (CRM_Core_BAO_UFGroup
::filterUFGroups($id, $contactID)) {
526 $fields = CRM_Core_BAO_UFGroup
::getFields($id, FALSE, CRM_Core_Action
::ADD
,
527 NULL, NULL, FALSE, NULL,
528 FALSE, NULL, CRM_Core_Permission
::CREATE
,
535 $fields = CRM_Core_BAO_UFGroup
::getFields($id, FALSE, CRM_Core_Action
::ADD
,
536 NULL, NULL, FALSE, NULL,
537 FALSE, NULL, CRM_Core_Permission
::CREATE
,
542 if (array_intersect_key($fields, $fieldsToIgnore)) {
543 $fields = array_diff_key($fields, $fieldsToIgnore);
544 CRM_Core_Session
::setStatus(ts('Some of the profile fields cannot be configured for this page.'));
548 if (!empty($this->_fields
)) {
549 $fields = @array_diff_assoc
($fields, $this->_fields
);
552 if (empty($this->_params
[0]['additional_participants']) &&
555 CRM_Core_BAO_Address
::checkContactSharedAddressFields($fields, $contactID);
557 $this->assign($name, $fields);
558 if (is_array($fields)) {
559 foreach ($fields as $key => $field) {
561 isset($field['data_type']) &&
562 $field['data_type'] == 'File' ||
($viewOnly && $field['name'] == 'image_URL')
564 // ignore file upload fields
567 //make the field optional if primary participant
568 //have been skip the additional participant.
569 if ($button == 'skip') {
570 $field['is_required'] = FALSE;
572 // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
573 elseif ($field['add_captcha'] && !$contactID) {
574 // only add captcha for first page
577 list($prefixName, $index) = CRM_Utils_System
::explode('-', $key, 2);
578 CRM_Core_BAO_UFGroup
::buildProfile($this, $field, CRM_Profile_Form
::MODE_CREATE
, $contactID, TRUE);
580 $this->_fields
[$key] = $field;
584 if ($addCaptcha && !$viewOnly) {
585 CRM_Utils_ReCAPTCHA
::enableCaptchaOnForm($this);
591 * Initiate event fee.
593 * @param CRM_Core_Form $form
594 * @param int $eventID
595 * @param bool $includeExpiredFields
600 public static function initEventFee(&$form, $eventID, $includeExpiredFields = TRUE) {
603 // retrive all active price set fields.
604 $discountId = CRM_Core_BAO_Discount
::findSet($eventID, 'civicrm_event');
605 if (property_exists($form, '_discountId') && $form->_discountId
) {
606 $discountId = $form->_discountId
;
610 $priceSetId = CRM_Core_DAO
::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'price_set_id');
611 CRM_Price_BAO_PriceSet
::initSet($form, 'civicrm_event', $includeExpiredFields, $priceSetId);
614 $priceSetId = CRM_Price_BAO_PriceSet
::getFor('civicrm_event', $eventID);
615 CRM_Price_BAO_PriceSet
::initSet($form, 'civicrm_event', $includeExpiredFields, $priceSetId);
618 if (property_exists($form, '_context') && ($form->_context
== 'standalone'
619 ||
$form->_context
== 'participant')
621 $discountedEvent = CRM_Core_BAO_Discount
::getOptionGroup($eventID, 'civicrm_event');
622 if (is_array($discountedEvent)) {
623 foreach ($discountedEvent as $key => $priceSetId) {
624 $priceSet = CRM_Price_BAO_PriceSet
::getSetDetail($priceSetId);
625 $priceSet = $priceSet[$priceSetId] ??
NULL;
626 $form->_values
['discount'][$key] = $priceSet['fields'] ??
NULL;
627 $fieldID = key($form->_values
['discount'][$key]);
628 $form->_values
['discount'][$key][$fieldID]['name'] = CRM_Core_DAO
::getFieldValue(
629 'CRM_Price_DAO_PriceSet',
636 $eventFee = $form->_values
['fee'] ??
NULL;
637 if (!is_array($eventFee) ||
empty($eventFee)) {
638 $form->_values
['fee'] = [];
641 //fix for non-upgraded price sets.CRM-4256.
642 if (isset($form->_isPaidEvent
)) {
643 $isPaidEvent = $form->_isPaidEvent
;
646 $isPaidEvent = $form->_values
['event']['is_monetary'] ??
NULL;
648 if (CRM_Financial_BAO_FinancialType
::isACLFinancialTypeStatus()
649 && !empty($form->_values
['fee'])
651 foreach ($form->_values
['fee'] as $k => $fees) {
652 foreach ($fees['options'] as $options) {
653 if (!CRM_Core_Permission
::check('add contributions of type ' . CRM_Contribute_PseudoConstant
::financialType($options['financial_type_id']))) {
654 unset($form->_values
['fee'][$k]);
659 if ($isPaidEvent && empty($form->_values
['fee'])) {
660 if (!in_array(CRM_Utils_System
::getClassName($form), ['CRM_Event_Form_Participant', 'CRM_Event_Form_Task_Register'])) {
661 CRM_Core_Error
::statusBounce(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', [1 => CRM_Utils_System
::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId
)]));
667 * Handle process after the confirmation of payment by User.
669 * @param int $contactID
670 * @param \CRM_Contribute_BAO_Contribution $contribution
672 * @throws \CiviCRM_API3_Exception
674 public function confirmPostProcess($contactID = NULL, $contribution = NULL) {
675 // add/update contact information
676 unset($this->_params
['note']);
678 //to avoid conflict overwrite $this->_params
679 $this->_params
= $this->get('value');
681 //get the amount of primary participant
682 if (!empty($this->_params
['is_primary'])) {
683 $this->_params
['fee_amount'] = $this->get('primaryParticipantAmount');
686 // add participant record
687 $participant = $this->addParticipant($this, $contactID);
688 $this->_participantIDS
[] = $participant->id
;
690 //setting register_by_id field and primaryContactId
691 if (!empty($this->_params
['is_primary'])) {
692 $this->set('registerByID', $participant->id
);
693 $this->set('primaryContactId', $contactID);
696 $this->processFirstParticipant($participant->id
);
699 if (!empty($this->_params
['is_primary'])) {
700 $this->_params
['participantID'] = $participant->id
;
701 $this->set('primaryParticipant', $this->_params
);
704 CRM_Core_BAO_CustomValueTable
::postProcess($this->_params
,
705 'civicrm_participant',
710 $createPayment = (CRM_Utils_Array
::value('amount', $this->_params
, 0) != 0) ?
TRUE : FALSE;
712 // force to create zero amount payment, CRM-5095
713 // we know the amout is zero since createPayment is false
714 if (!$createPayment &&
715 (isset($contribution) && $contribution->id
) &&
716 $this->_priceSetId
&&
719 $createPayment = TRUE;
722 if ($createPayment && $this->_values
['event']['is_monetary'] && !empty($this->_params
['contributionID'])) {
724 'participant_id' => $participant->id
,
725 'contribution_id' => $contribution->id
,
727 civicrm_api3('ParticipantPayment', 'create', $paymentParams);
730 $this->assign('action', $this->_action
);
733 if (!empty($this->_params
['cms_create_account'])) {
734 $this->_params
['contactID'] = $contactID;
736 if (array_key_exists('email-5', $this->_params
)) {
740 foreach ($this->_params
as $name => $dontCare) {
741 if (substr($name, 0, 5) == 'email') {
748 // we should use primary email for
749 // 1. pay later participant.
750 // 2. waiting list participant.
751 // 3. require approval participant.
752 if (!empty($this->_params
['is_pay_later']) ||
753 $this->_allowWaitlist ||
$this->_requireApproval
755 $mail = 'email-Primary';
758 if (!CRM_Core_BAO_CMSUser
::create($this->_params
, $mail)) {
759 CRM_Core_Error
::statusBounce(ts('Your profile is not saved and Account is not created.'));
765 * Process the participant.
767 * @param CRM_Core_Form $form
768 * @param int $contactID
770 * @return \CRM_Event_BAO_Participant
771 * @throws \CiviCRM_API3_Exception
773 protected function addParticipant(&$form, $contactID) {
774 if (empty($form->_params
)) {
777 // Note this used to be shared with the backoffice form & no longer is, some code may no longer be required.
778 $params = $form->_params
;
779 $transaction = new CRM_Core_Transaction();
781 // handle register date CRM-4320
782 $registerDate = NULL;
783 if (!empty($form->_allowConfirmation
) && $form->_participantId
) {
784 $registerDate = $params['participant_register_date'];
786 elseif (!empty($params['participant_register_date']) &&
787 is_array($params['participant_register_date']) &&
788 !empty($params['participant_register_date'])
790 $registerDate = CRM_Utils_Date
::format($params['participant_register_date']);
793 $participantFields = CRM_Event_DAO_Participant
::fields();
794 $participantParams = [
795 'id' => $params['participant_id'] ??
NULL,
796 'contact_id' => $contactID,
797 'event_id' => $form->_eventId ?
$form->_eventId
: $params['event_id'],
798 'status_id' => CRM_Utils_Array
::value('participant_status',
801 'role_id' => CRM_Utils_Array
::value('participant_role_id', $params) ?
: CRM_Event_BAO_Participant
::getDefaultRoleID(),
802 'register_date' => ($registerDate) ?
$registerDate : date('YmdHis'),
803 'source' => CRM_Utils_String
::ellipsify(
804 isset($params['participant_source']) ? CRM_Utils_Array
::value('participant_source', $params) : CRM_Utils_Array
::value('description', $params),
805 $participantFields['participant_source']['maxlength']
807 'fee_level' => $params['amount_level'] ??
NULL,
808 'is_pay_later' => CRM_Utils_Array
::value('is_pay_later', $params, 0),
809 'fee_amount' => $params['fee_amount'] ??
NULL,
810 'registered_by_id' => $params['registered_by_id'] ??
NULL,
811 'discount_id' => $params['discount_id'] ??
NULL,
812 'fee_currency' => $params['currencyID'] ??
NULL,
813 'campaign_id' => $params['campaign_id'] ??
NULL,
816 if ($form->_action
& CRM_Core_Action
::PREVIEW || CRM_Utils_Array
::value('mode', $params) == 'test') {
817 $participantParams['is_test'] = 1;
820 $participantParams['is_test'] = 0;
823 if (!empty($form->_params
['note'])) {
824 $participantParams['note'] = $form->_params
['note'];
826 elseif (!empty($form->_params
['participant_note'])) {
827 $participantParams['note'] = $form->_params
['participant_note'];
830 // reuse id if one already exists for this one (can happen
831 // with back button being hit etc)
832 if (!$participantParams['id'] && !empty($params['contributionID'])) {
833 $pID = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_ParticipantPayment',
834 $params['contributionID'],
838 $participantParams['id'] = $pID;
840 $participantParams['discount_id'] = CRM_Core_BAO_Discount
::findSet($form->_eventId
, 'civicrm_event');
842 if (!$participantParams['discount_id']) {
843 $participantParams['discount_id'] = "null";
846 $participant = CRM_Event_BAO_Participant
::create($participantParams);
848 $transaction->commit();
854 * Calculate the total participant count as per params.
856 * @param CRM_Core_Form $form
857 * @param array $params
859 * @param bool $skipCurrent
863 public static function getParticipantCount(&$form, $params, $skipCurrent = FALSE) {
865 if (!is_array($params) ||
empty($params)) {
869 $priceSetId = $form->get('priceSetId');
870 $addParticipantNum = substr($form->_name
, 12);
871 $priceSetFields = $priceSetDetails = [];
872 $hasPriceFieldsCount = FALSE;
874 $priceSetDetails = $form->get('priceSet');
875 if (isset($priceSetDetails['optionsCountTotal'])
876 && $priceSetDetails['optionsCountTotal']
878 $hasPriceFieldsCount = TRUE;
879 $priceSetFields = $priceSetDetails['optionsCountDetails']['fields'];
883 $singleFormParams = FALSE;
884 foreach ($params as $key => $val) {
885 if (!is_numeric($key)) {
886 $singleFormParams = TRUE;
891 //first format the params.
892 if ($singleFormParams) {
893 $params = self
::formatPriceSetParams($form, $params);
897 foreach ($params as $key => $values) {
898 if (!is_numeric($key) ||
900 ($skipCurrent && ($addParticipantNum == $key))
907 $cacheCount = $form->_lineItemParticipantsCount
[$key] ??
NULL;
908 if ($cacheCount && is_numeric($cacheCount)) {
909 $count = $cacheCount;
913 if (!$usedCache && $hasPriceFieldsCount) {
915 foreach ($values as $valKey => $value) {
916 if (strpos($valKey, 'price_') === FALSE) {
919 $priceFieldId = substr($valKey, 6);
920 if (!$priceFieldId ||
922 !array_key_exists($priceFieldId, $priceSetFields)
926 foreach ($value as $optId => $optVal) {
927 $currentCount = $priceSetFields[$priceFieldId]['options'][$optId] * $optVal;
929 $count +
= $currentCount;
937 $totalCount +
= $count;
947 * Format user submitted price set params.
949 * Convert price set each param as an array.
951 * @param CRM_Core_Form $form
952 * @param array $params
953 * An array of user submitted params.
956 * Formatted price set params.
958 public static function formatPriceSetParams(&$form, $params) {
959 if (!is_array($params) ||
empty($params)) {
963 $priceSetId = $form->get('priceSetId');
967 $priceSetDetails = $form->get('priceSet');
969 foreach ($params as $key => & $value) {
971 if (strpos($key, 'price_') !== FALSE) {
972 $fieldId = substr($key, 6);
973 if (!array_key_exists($fieldId, $priceSetDetails['fields']) ||
979 $field = $priceSetDetails['fields'][$fieldId];
980 if ($field['html_type'] == 'Text') {
981 $fieldOption = current($field['options']);
982 $value = [$fieldOption['id'] => $value];
985 $value = [$value => TRUE];
994 * Calculate total count for each price set options.
996 * - currently selected by user.
998 * @param CRM_Core_Form $form
1002 * array of each option w/ count total.
1004 public static function getPriceSetOptionCount(&$form) {
1005 $params = $form->get('params');
1006 $priceSet = $form->get('priceSet');
1007 $priceSetId = $form->get('priceSetId');
1011 !is_array($priceSet) ||
1013 !is_array($params) ||
1016 return $optionsCount;
1019 $priceSetFields = $priceMaxFieldDetails = [];
1020 if (!empty($priceSet['optionsCountTotal'])) {
1021 $priceSetFields = $priceSet['optionsCountDetails']['fields'];
1024 if (!empty($priceSet['optionsMaxValueTotal'])) {
1025 $priceMaxFieldDetails = $priceSet['optionsMaxValueDetails']['fields'];
1028 $addParticipantNum = substr($form->_name
, 12);
1029 foreach ($params as $pCnt => $values) {
1030 if ($values == 'skip' ||
1031 $pCnt === $addParticipantNum
1036 foreach ($values as $valKey => $value) {
1037 if (strpos($valKey, 'price_') === FALSE) {
1041 $priceFieldId = substr($valKey, 6);
1042 if (!$priceFieldId ||
1043 !is_array($value) ||
1044 !(array_key_exists($priceFieldId, $priceSetFields) ||
array_key_exists($priceFieldId, $priceMaxFieldDetails))
1049 foreach ($value as $optId => $optVal) {
1050 if (CRM_Utils_Array
::value('html_type', $priceSet['fields'][$priceFieldId]) == 'Text') {
1051 $currentCount = $optVal;
1057 if (isset($priceSetFields[$priceFieldId]) && isset($priceSetFields[$priceFieldId]['options'][$optId])) {
1058 $currentCount = $priceSetFields[$priceFieldId]['options'][$optId] * $optVal;
1061 $optionsCount[$optId] = $currentCount + CRM_Utils_Array
::value($optId, $optionsCount, 0);
1066 return $optionsCount;
1070 * Check if template file exists.
1072 * @param string $suffix
1074 * @return null|string
1076 public function checkTemplateFileExists($suffix = '') {
1077 if ($this->_eventId
) {
1078 $templateName = $this->_name
;
1079 if (substr($templateName, 0, 12) == 'Participant_') {
1080 $templateName = 'AdditionalParticipant';
1083 $templateFile = "CRM/Event/Form/Registration/{$this->_eventId}/{$templateName}.{$suffix}tpl";
1084 $template = CRM_Core_Form
::getTemplate();
1085 if ($template->template_exists($templateFile)) {
1086 return $templateFile;
1093 * Get template file name.
1095 * @return null|string
1097 public function getTemplateFileName() {
1098 $fileName = $this->checkTemplateFileExists();
1099 return $fileName ?
$fileName : parent
::getTemplateFileName();
1103 * Override extra template name.
1105 * @return null|string
1107 public function overrideExtraTemplateFileName() {
1108 $fileName = $this->checkTemplateFileExists('extra.');
1109 return $fileName ?
$fileName : parent
::overrideExtraTemplateFileName();
1113 * Reset values for all options those are full.
1115 * @param array $optionFullIds
1116 * @param CRM_Core_Form $form
1118 public static function resetElementValue($optionFullIds = [], &$form) {
1119 if (!is_array($optionFullIds) ||
1120 empty($optionFullIds) ||
1121 !$form->isSubmitted()
1126 foreach ($optionFullIds as $fldId => $optIds) {
1127 $name = "price_$fldId";
1128 if (!$form->elementExists($name)) {
1132 $element = $form->getElement($name);
1133 $eleType = $element->getType();
1135 $resetSubmitted = FALSE;
1138 if ($element->getValue() && $element->isFrozen()) {
1139 $label = "{$element->getLabel()}<tt>(x)</tt>";
1140 $element->setLabel($label);
1141 $element->setPersistantFreeze();
1142 $resetSubmitted = TRUE;
1147 if (is_array($element->_elements
)) {
1148 foreach ($element->_elements
as $child) {
1149 $childType = $child->getType();
1150 $methodName = 'getName';
1152 $methodName = 'getValue';
1154 if (in_array($child->{$methodName}(), $optIds) && $child->isFrozen()) {
1155 $resetSubmitted = TRUE;
1156 $child->setPersistantFreeze();
1163 $value = $element->getValue();
1164 if (in_array($value[0], $optIds)) {
1165 foreach ($element->_options
as $option) {
1166 if ($option['attr']['value'] === "crm_disabled_opt-{$value[0]}") {
1167 $placeholder = html_entity_decode($option['text'], ENT_QUOTES
, "UTF-8");
1168 $element->updateAttributes(['placeholder' => $placeholder]);
1172 $resetSubmitted = TRUE;
1177 //finally unset values from submitted.
1178 if ($resetSubmitted) {
1179 self
::resetSubmittedValue($name, $optIds, $form);
1185 * Reset submitted value.
1187 * @param string $elementName
1188 * @param array $optionIds
1189 * @param CRM_Core_Form $form
1191 public static function resetSubmittedValue($elementName, $optionIds = [], &$form) {
1192 if (empty($elementName) ||
1193 !$form->elementExists($elementName) ||
1194 !$form->getSubmitValue($elementName)
1198 foreach (['constantValues', 'submitValues', 'defaultValues'] as $val) {
1199 $values = $form->{"_$val"};
1200 if (!is_array($values) ||
empty($values)) {
1203 $eleVal = $values[$elementName] ??
NULL;
1204 if (empty($eleVal)) {
1207 if (is_array($eleVal)) {
1209 foreach ($eleVal as $keyId => $ignore) {
1210 if (in_array($keyId, $optionIds)) {
1212 unset($values[$elementName][$keyId]);
1215 if ($found && empty($values[$elementName][$keyId])) {
1216 $values[$elementName][$keyId] = NULL;
1220 if (!empty($keyId)) {
1221 $values[$elementName][$keyId] = NULL;
1228 * Validate price set submitted params for price option limit.
1230 * User should select at least one price field option.
1232 * @param CRM_Core_Form $form
1233 * @param array $params
1237 public static function validatePriceSet(&$form, $params) {
1239 $hasOptMaxValue = FALSE;
1240 if (!is_array($params) ||
empty($params)) {
1244 $currentParticipantNum = substr($form->_name
, 12);
1245 if (!$currentParticipantNum) {
1246 $currentParticipantNum = 0;
1249 $priceSetId = $form->get('priceSetId');
1250 $priceSetDetails = $form->get('priceSet');
1253 !is_array($priceSetDetails) ||
1254 empty($priceSetDetails)
1259 $optionsCountDetails = $optionsMaxValueDetails = [];
1261 isset($priceSetDetails['optionsMaxValueTotal'])
1262 && $priceSetDetails['optionsMaxValueTotal']
1264 $hasOptMaxValue = TRUE;
1265 $optionsMaxValueDetails = $priceSetDetails['optionsMaxValueDetails']['fields'];
1268 isset($priceSetDetails['optionsCountTotal'])
1269 && $priceSetDetails['optionsCountTotal']
1271 $hasOptCount = TRUE;
1272 $optionsCountDetails = $priceSetDetails['optionsCountDetails']['fields'];
1274 $feeBlock = $form->_feeBlock
;
1276 if (empty($feeBlock)) {
1277 $feeBlock = $priceSetDetails['fields'];
1280 $optionMaxValues = $fieldSelected = [];
1281 foreach ($params as $pNum => $values) {
1282 if (!is_array($values) ||
$values == 'skip') {
1286 foreach ($values as $valKey => $value) {
1287 if (strpos($valKey, 'price_') === FALSE) {
1290 $priceFieldId = substr($valKey, 6);
1291 $noneOptionValueSelected = FALSE;
1292 if (!$feeBlock[$priceFieldId]['is_required'] && $value == 0) {
1293 $noneOptionValueSelected = TRUE;
1298 (!$noneOptionValueSelected && !is_array($value))
1303 $fieldSelected[$pNum] = TRUE;
1305 if (!$hasOptMaxValue ||
!is_array($value)) {
1309 foreach ($value as $optId => $optVal) {
1310 if (CRM_Utils_Array
::value('html_type', $feeBlock[$priceFieldId]) == 'Text') {
1311 $currentMaxValue = $optVal;
1314 $currentMaxValue = 1;
1317 if (isset($optionsCountDetails[$priceFieldId]) && isset($optionsCountDetails[$priceFieldId]['options'][$optId])) {
1318 $currentMaxValue = $optionsCountDetails[$priceFieldId]['options'][$optId] * $optVal;
1320 if (empty($optionMaxValues)) {
1321 $optionMaxValues[$priceFieldId][$optId] = $currentMaxValue;
1324 $optionMaxValues[$priceFieldId][$optId]
1325 = $currentMaxValue + CRM_Utils_Array
::value($optId, CRM_Utils_Array
::value($priceFieldId, $optionMaxValues), 0);
1327 $soldOutPnum[$optId] = $pNum;
1331 //validate for price field selection.
1332 if (empty($fieldSelected[$pNum])) {
1333 $errors[$pNum]['_qf_default'] = ts('SELECT at least one OPTION FROM EVENT Fee(s).');
1337 //validate for option max value.
1338 foreach ($optionMaxValues as $fieldId => $values) {
1339 $options = CRM_Utils_Array
::value('options', $feeBlock[$fieldId], []);
1340 foreach ($values as $optId => $total) {
1341 $optMax = $optionsMaxValueDetails[$fieldId]['options'][$optId];
1342 $opDbCount = CRM_Utils_Array
::value('db_total_count', $options[$optId], 0);
1343 $total +
= $opDbCount;
1344 if ($optMax && ($total > $optMax)) {
1345 if ($opDbCount && ($opDbCount >= $optMax)) {
1346 $errors[$soldOutPnum[$optId]]["price_{$fieldId}"]
1347 = ts('Sorry, this option is currently sold out.');
1349 elseif (($optMax - $opDbCount) == 1) {
1350 $errors[$soldOutPnum[$optId]]["price_{$fieldId}"]
1351 = ts('Sorry, currently only a single space is available for this option.', [1 => ($optMax - $opDbCount)]);
1354 $errors[$soldOutPnum[$optId]]["price_{$fieldId}"]
1355 = ts('Sorry, currently only %1 spaces are available for this option.', [1 => ($optMax - $opDbCount)]);
1364 * Set the first participant ID if not set.
1368 * @param int $participantID
1370 public function processFirstParticipant($participantID) {
1371 $this->_participantId
= $participantID;
1372 $this->set('participantId', $this->_participantId
);
1374 $ids = $participantValues = [];
1375 $participantParams = ['id' => $this->_participantId
];
1376 CRM_Event_BAO_Participant
::getValues($participantParams, $participantValues, $ids);
1377 $this->_values
['participant'] = $participantValues[$this->_participantId
];
1378 $this->set('values', $this->_values
);
1380 // also set the allow confirmation stuff
1381 if (array_key_exists(
1382 $this->_values
['participant']['status_id'],
1383 CRM_Event_PseudoConstant
::participantStatus(NULL, "class = 'Pending'")
1385 $this->_allowConfirmation
= TRUE;
1386 $this->set('allowConfirmation', TRUE);
1391 * Check if event is valid.
1393 * @param string $redirect
1395 * @todo - combine this with CRM_Event_BAO_Event::validRegistrationRequest
1396 * (probably extract relevant values here & call that with them & handle bounces & redirects here -as
1397 * those belong in the form layer)
1400 public function checkValidEvent($redirect = NULL) {
1401 // is the event active (enabled)?
1402 if (!$this->_values
['event']['is_active']) {
1403 // form is inactive, die a fatal death
1404 CRM_Core_Error
::statusBounce(ts('The event you requested is currently unavailable (contact the site administrator for assistance).'));
1407 // is online registration is enabled?
1408 if (!$this->_values
['event']['is_online_registration']) {
1409 CRM_Core_Error
::statusBounce(ts('Online registration is not currently available for this event (contact the site administrator for assistance).'), $redirect);
1412 // is this an event template ?
1413 if (!empty($this->_values
['event']['is_template'])) {
1414 CRM_Core_Error
::statusBounce(ts('Event templates are not meant to be registered.'), $redirect);
1417 $now = date('YmdHis');
1418 $startDate = CRM_Utils_Date
::processDate(CRM_Utils_Array
::value('registration_start_date',
1419 $this->_values
['event']
1426 CRM_Core_Error
::statusBounce(ts('Registration for this event begins on %1', [1 => CRM_Utils_Date
::customFormat(CRM_Utils_Array
::value('registration_start_date', $this->_values
['event']))]), $redirect, ts('Sorry'));
1429 $regEndDate = CRM_Utils_Date
::processDate(CRM_Utils_Array
::value('registration_end_date',
1430 $this->_values
['event']
1432 $eventEndDate = CRM_Utils_Date
::processDate(CRM_Utils_Array
::value('event_end_date', $this->_values
['event']));
1433 if (($regEndDate && ($regEndDate < $now)) ||
(empty($regEndDate) && !empty($eventEndDate) && ($eventEndDate < $now))) {
1434 $endDate = CRM_Utils_Date
::customFormat(CRM_Utils_Array
::value('registration_end_date', $this->_values
['event']));
1435 if (empty($regEndDate)) {
1436 $endDate = CRM_Utils_Date
::customFormat(CRM_Utils_Array
::value('event_end_date', $this->_values
['event']));
1438 CRM_Core_Error
::statusBounce(ts('Registration for this event ended on %1', [1 => $endDate]), $redirect, ts('Sorry'));
1443 * Get the amount level for the event payment.
1445 * The amount level is the string stored on the contribution record that describes the purchase.
1447 * @param array $params
1448 * @param int|null $discountID
1452 protected function getAmountLevel($params, $discountID) {
1453 // @todo move handling of discount ID to the BAO function - preferably by converting it to a price_set with
1455 if (!empty($this->_values
['discount'][$discountID])) {
1456 return $this->_values
['discount'][$discountID][$params['amount']]['label'];
1458 if (empty($params['priceSetId'])) {
1459 // CRM-17509 An example of this is where the person is being waitlisted & there is no payment.
1460 // ideally we would have calculated amount first & only call this is there is an
1461 // amount but the flow needs more changes for that.
1464 return CRM_Price_BAO_PriceSet
::getAmountLevelText($params);
1468 * Process Registration of free event.
1470 * @param array $params
1472 * @param int $contactID
1474 * @throws \CiviCRM_API3_Exception
1476 public function processRegistration($params, $contactID = NULL) {
1477 $session = CRM_Core_Session
::singleton();
1478 $this->_participantInfo
= [];
1480 // CRM-4320, lets build array of cancelled additional participant ids
1481 // those are drop or skip by primary at the time of confirmation.
1482 // get all in and then unset those are confirmed.
1483 $cancelledIds = $this->_additionalParticipantIds
;
1485 $participantCount = [];
1486 foreach ($params as $participantNum => $record) {
1487 if ($record == 'skip') {
1488 $participantCount[$participantNum] = 'skip';
1490 elseif ($participantNum) {
1491 $participantCount[$participantNum] = 'participant';
1495 $registerByID = NULL;
1496 foreach ($params as $key => $value) {
1497 if ($value != 'skip') {
1500 // setting register by Id and unset contactId.
1501 if (empty($value['is_primary'])) {
1503 $registerByID = $this->get('registerByID');
1504 if ($registerByID) {
1505 $value['registered_by_id'] = $registerByID;
1507 // get an email if one exists for the participant
1508 $participantEmail = '';
1509 foreach (array_keys($value) as $valueName) {
1510 if (substr($valueName, 0, 6) == 'email-') {
1511 $participantEmail = $value[$valueName];
1514 if ($participantEmail) {
1515 $this->_participantInfo
[] = $participantEmail;
1518 $this->_participantInfo
[] = $value['first_name'] . ' ' . $value['last_name'];
1521 elseif (!empty($value['contact_id'])) {
1522 $contactID = $value['contact_id'];
1525 $contactID = $this->getContactID();
1528 CRM_Event_Form_Registration_Confirm
::fixLocationFields($value, $fields, $this);
1529 //for free event or additional participant, dont create billing email address.
1530 if (empty($value['is_primary']) ||
!$this->_values
['event']['is_monetary']) {
1531 unset($value["email-{$this->_bltID}"]);
1534 $contactID = CRM_Event_Form_Registration_Confirm
::updateContactFields($contactID, $value, $fields, $this);
1536 // lets store the contactID in the session
1537 // we dont store in userID in case the user is doing multiple
1539 // for things like tell a friend
1540 if (!$this->getContactID() && !empty($value['is_primary'])) {
1541 $session->set('transaction.userID', $contactID);
1544 //lets get the status if require approval or waiting.
1546 $waitingStatuses = CRM_Event_PseudoConstant
::participantStatus(NULL, "class = 'Waiting'");
1547 if ($this->_allowWaitlist
&& !$this->_allowConfirmation
) {
1548 $value['participant_status_id'] = $value['participant_status'] = array_search('On waitlist', $waitingStatuses);
1550 elseif ($this->_requireApproval
&& !$this->_allowConfirmation
) {
1551 $value['participant_status_id'] = $value['participant_status'] = array_search('Awaiting approval', $waitingStatuses);
1554 $this->set('value', $value);
1555 $this->confirmPostProcess($contactID, NULL);
1557 //lets get additional participant id to cancel.
1558 if ($this->_allowConfirmation
&& is_array($cancelledIds)) {
1559 $additonalId = $value['participant_id'] ??
NULL;
1560 if ($additonalId && $key = array_search($additonalId, $cancelledIds)) {
1561 unset($cancelledIds[$key]);
1567 // update status and send mail to cancelled additional participants, CRM-4320
1568 if ($this->_allowConfirmation
&& is_array($cancelledIds) && !empty($cancelledIds)) {
1569 $cancelledId = array_search('Cancelled',
1570 CRM_Event_PseudoConstant
::participantStatus(NULL, "class = 'Negative'")
1572 CRM_Event_BAO_Participant
::transitionParticipants($cancelledIds, $cancelledId);
1575 //set information about additional participants if exists
1576 if (count($this->_participantInfo
)) {
1577 $this->set('participantInfo', $this->_participantInfo
);
1580 //send mail Confirmation/Receipt
1581 if ($this->_contributeMode
!= 'checkout' ||
1582 $this->_contributeMode
!= 'notify'
1584 $this->sendMails($params, $registerByID, $participantCount);
1589 * Send Mail to participants.
1592 * @param $registerByID
1593 * @param array $participantCount
1595 * @throws \CiviCRM_API3_Exception
1597 private function sendMails($params, $registerByID, array $participantCount) {
1599 if ($this->_action
& CRM_Core_Action
::PREVIEW
) {
1603 //handle if no additional participant.
1604 if (!$registerByID) {
1605 $registerByID = $this->get('registerByID');
1607 $primaryContactId = $this->get('primaryContactId');
1609 //build an array of custom profile and assigning it to template.
1610 $additionalIDs = CRM_Event_BAO_Event
::buildCustomProfile($registerByID, NULL,
1611 $primaryContactId, $isTest, TRUE
1614 //lets carry all participant params w/ values.
1615 foreach ($additionalIDs as $participantID => $contactId) {
1616 $participantNum = NULL;
1617 if ($participantID == $registerByID) {
1618 $participantNum = 0;
1621 if ($participantNum = array_search('participant', $participantCount)) {
1622 unset($participantCount[$participantNum]);
1626 if ($participantNum === NULL) {
1630 //carry the participant submitted values.
1631 $this->_values
['params'][$participantID] = $params[$participantNum];
1634 //lets send mails to all with meanigful text, CRM-4320.
1635 $this->assign('isOnWaitlist', $this->_allowWaitlist
);
1636 $this->assign('isRequireApproval', $this->_requireApproval
);
1638 foreach ($additionalIDs as $participantID => $contactId) {
1639 if ($participantID == $registerByID) {
1640 //set as Primary Participant
1641 $this->assign('isPrimary', 1);
1643 $customProfile = CRM_Event_BAO_Event
::buildCustomProfile($participantID, $this->_values
, NULL, $isTest);
1645 if (count($customProfile)) {
1646 $this->assign('customProfile', $customProfile);
1647 $this->set('customProfile', $customProfile);
1651 $this->assign('isPrimary', 0);
1652 $this->assign('customProfile', NULL);
1655 //send Confirmation mail to Primary & additional Participants if exists
1656 CRM_Event_BAO_Event
::sendMail($contactId, $this->_values
, $participantID, $isTest);