--fixed for CRM-12155
authorPradeep Nayak <pradeep@pradeep.(none)>
Mon, 25 Mar 2013 11:33:16 +0000 (17:03 +0530)
committerPradeep Nayak <pradeep@pradeep.(none)>
Mon, 25 Mar 2013 11:33:16 +0000 (17:03 +0530)
CRM/Contact/BAO/Contact.php
CRM/Contribute/BAO/Contribution.php
CRM/Event/BAO/Participant.php

index 194e12da9610dc920afc3ecf4b3f5eb3bb48d663..5988ab2d52263ef9590c80308fb4ac5e16b2ca58 100644 (file)
@@ -772,7 +772,13 @@ WHERE     civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer');
       $logDAO->entity_table = 'civicrm_contact';
       $logDAO->entity_id = $id;
       $logDAO->delete();
+      
+      // delete contact participants CRM-12155
+      CRM_Event_BAO_Participant::deleteContactParticipant($id);
 
+      // delete contact contributions CRM-12155
+      CRM_Contribute_BAO_Contribution::deleteContactContribution($id);
+      
       // do activity cleanup, CRM-5604
       CRM_Activity_BAO_Activity::cleanupActivity($id);
 
index 664c381154c441263387b01c01d8677f7b274204..6c76df04ac892de569c8923b6096dd70c3f7c903 100644 (file)
@@ -2963,4 +2963,23 @@ WHERE  contribution_id = %1 ";
       $errors['contribution_status_id'] = ts("Cannot change contribution status from %1 to %2.", array(1 => $contributionStatuses[$values['contribution_status_id']], 2 => $contributionStatuses[$fields['contribution_status_id']]));
     }
   }
+
+  /**
+   * Function to delete contribution of contact
+   *
+   * CRM-12155
+   *
+   * @param integer $contactId contact id 
+   *
+   * @access public
+   * @static
+   */
+  static function deleteContactContribution($contactId) {
+    $contribution = new CRM_Contribute_DAO_Contribution();
+    $contribution->contact_id = $contactId;
+    $contribution->find();
+    while ($contribution->fetch()) {
+      self::deleteContribution($contribution->id);
+    }
+  }
 }
index 1448b2fb389e9e37af5dea03e7a330bfb5fd7e29..ee1797400e44772f573403658a6988257124dffb 100644 (file)
@@ -1759,5 +1759,24 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
     }
     return;
   }
+
+  /**
+   * Function to delete participants of contact
+   *
+   * CRM-12155
+   *
+   * @param integer $contactId contact id 
+   *
+   * @access public
+   * @static
+   */
+  static function deleteContactParticipant($contactId) {
+    $participant = new CRM_Event_DAO_Participant();
+    $participant->contact_id = $contactId;
+    $participant->find();
+    while ($participant->fetch()) {
+      self::deleteParticipant($participant->id);
+    }
+  }
 }