Example #1
0
 /**
  * Delete the records that are associated with this participation.
  *
  * @param int $id
  *   Id of the participation to delete.
  *
  * @return \CRM_Event_DAO_Participant
  */
 public static function deleteParticipant($id)
 {
     CRM_Utils_Hook::pre('delete', 'Participant', $id, CRM_Core_DAO::$_nullArray);
     $transaction = new CRM_Core_Transaction();
     //delete activity record
     $params = array('source_record_id' => $id, 'activity_type_id' => 5);
     CRM_Activity_BAO_Activity::deleteActivity($params);
     // delete the participant payment record
     // we need to do this since the cascaded constraints
     // dont work with join tables
     $p = array('participant_id' => $id);
     CRM_Event_BAO_ParticipantPayment::deleteParticipantPayment($p);
     // cleanup line items.
     $participantsId = array();
     $participantsId = self::getAdditionalParticipantIds($id);
     $participantsId[] = $id;
     CRM_Price_BAO_LineItem::deleteLineItems($participantsId, 'civicrm_participant');
     //delete note when participant deleted.
     $note = CRM_Core_BAO_Note::getNote($id, 'civicrm_participant');
     $noteId = key($note);
     if ($noteId) {
         CRM_Core_BAO_Note::del($noteId, FALSE);
     }
     $participant = new CRM_Event_DAO_Participant();
     $participant->id = $id;
     $participant->delete();
     $transaction->commit();
     CRM_Utils_Hook::post('delete', 'Participant', $participant->id, $participant);
     // delete the recently created Participant
     $participantRecent = array('id' => $id, 'type' => 'Participant');
     CRM_Utils_Recent::del($participantRecent);
     return $participant;
 }
 /**                          
  * Delete the record that are associated with this participation
  * 
  * @param  int  $id id of the participation to delete                                                                           
  * 
  * @return void
  * @access public 
  * @static 
  */
 static function deleteParticipant($id)
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     //delete activity record
     require_once "CRM/Activity/BAO/Activity.php";
     $params = array('source_record_id' => $id, 'activity_type_id' => 5);
     // activity type id for event registration
     CRM_Activity_BAO_Activity::deleteActivity($params);
     // delete the participant payment record
     // we need to do this since the cascaded constraints
     // dont work with join tables
     require_once 'CRM/Event/BAO/ParticipantPayment.php';
     $p = array('participant_id' => $id);
     CRM_Event_BAO_ParticipantPayment::deleteParticipantPayment($p);
     // cleanup line items.
     require_once 'CRM/Price/BAO/LineItem.php';
     $participantsId = array();
     $participantsId = self::getAdditionalParticipantIds($id);
     $participantsId[] = $id;
     CRM_Price_BAO_LineItem::deleteLineItems($participantsId, 'civicrm_participant');
     $participant = new CRM_Event_DAO_Participant();
     $participant->id = $id;
     $participant->delete();
     $transaction->commit();
     // delete the recently created Participant
     require_once 'CRM/Utils/Recent.php';
     $participantRecent = array('id' => $id, 'type' => 'Participant');
     CRM_Utils_Recent::del($participantRecent);
     return $participant;
 }