Esempio n. 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;
 }
Esempio n. 2
0
 /**                          
  * 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;
 }
/**
 * Deletes an existing Participant Payment
 *
 * This API is used for deleting a Participant Payment
 *
 * @param  Int  $participantPaymentID   Id of the Participant Payment to be deleted
 *
 * @return array API result
 * @example ParticipantPaymentDelete.php
 * {@getfields ParticipantPayment_delete}
 * @access public
 */
function civicrm_api3_participant_payment_delete($params)
{
    $participant = new CRM_Event_BAO_ParticipantPayment();
    return $participant->deleteParticipantPayment($params) ? civicrm_api3_create_success() : civicrm_api3_create_error('Error while deleting participantPayment');
}
/**
 * Deletes an existing Participant Payment
 *
 * This API is used for deleting a Participant Payment
 *
 * @param  Int  $participantPaymentID   Id of the Participant Payment to be deleted
 *
 * @return null if successfull, array with is_error=1 otherwise
 * @access public
 */
function civicrm_participant_payment_delete(&$params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        $error = civicrm_create_error('Params is not an array');
        return $error;
    }
    if (!CRM_Utils_Array::value('id', $params)) {
        $error = civicrm_create_error('Invalid or no value for Participant payment ID');
        return $error;
    }
    require_once 'CRM/Event/BAO/ParticipantPayment.php';
    $participant = new CRM_Event_BAO_ParticipantPayment();
    return $participant->deleteParticipantPayment($params) ? civicrm_create_success() : civicrm_create_error('Error while deleting participantPayment');
}