_participantIds as $participantId) { if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantId)) { $this->assign('additionalParticipants', TRUE); } } } /** * Build the form object * * * @return void */ public function buildQuickForm() { $deleteParticipants = array( 1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.'), ); $this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '
'); $this->setDefaults(array('delete_participant' => 1)); $this->addDefaultButtons(ts('Delete Participations'), 'done'); } /** * Process the form after the input has been submitted and validated * * * @return void */ public function postProcess() { $params = $this->controller->exportValues($this->_name); if (CRM_Utils_Array::value('delete_participant', $params) == 2) { $links = array(); foreach ($this->_participantIds as $participantId) { $additionalId = (CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId)); $participantLinks = (CRM_Event_BAO_Participant::getAdditionalParticipantUrl($additionalId)); } } $deletedParticipants = $additionalCount = 0; foreach ($this->_participantIds as $participantId) { if (CRM_Utils_Array::value('delete_participant', $params) == 1) { if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantId)) { $additionalIds = (CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId)); $additionalCount = count($additionalIds); foreach ($additionalIds as $value) { CRM_Event_BAO_Participant::deleteParticipant($value); } CRM_Event_BAO_Participant::deleteParticipant($participantId); } $deletedParticipants++; } else { CRM_Event_BAO_Participant::deleteParticipant($participantId); $deletedParticipants++; } } if ($additionalCount) { $deletedParticipants += $additionalCount; } $status = array( ts('Participant(s) Deleted: %1 (Total Selected: %2)', array( 1 => $deletedParticipants, 2 => count($this->_participantIds), )), ); if (!empty($participantLinks)) { $status[] = ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') . '
' . $participantLinks; } foreach ($status as $text) { CRM_Core_Session::setStatus($text, '', 'info'); } } }