Merge pull request #2327 from colemanw/4.4
[civicrm-core.git] / CRM / Contact / BAO / ContactType.php
index e58e2ea5f4dbd78d898c7297365dc0e4e079da71..62719aa01ee66af4fba98b0ca8721d3b643805dd 100644 (file)
@@ -602,8 +602,6 @@ WHERE name = %1";
     $contactType->id = CRM_Utils_Array::value('id', $params);
     $contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0);
 
-
-
     $contactType->save();
     if ($contactType->find(TRUE)) {
       $contactName = $contactType->name;
@@ -812,14 +810,16 @@ WHERE extends = %1 AND " . implode(" OR ", $subTypeClause);
    * @return void
    * @access public
    */
-  function deleteCustomRowsOfSubtype($gID, $subtypes = array(
-    )) {
+  public static function deleteCustomRowsOfSubtype($gID, $subtypes = array()) {
     if (!$gID or empty($subtypes)) {
       return FALSE;
     }
 
     $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $gID, 'table_name');
 
+    // drop triggers CRM-13587
+    CRM_Core_DAO::dropTriggers($tableName);
+
     $subtypeClause = array();
     foreach ($subtypes as $subtype) {
       $subtype = CRM_Utils_Type::escape($subtype, 'String');
@@ -831,7 +831,11 @@ WHERE extends = %1 AND " . implode(" OR ", $subTypeClause);
 FROM {$tableName} custom
 INNER JOIN civicrm_contact ON civicrm_contact.id = custom.entity_id
 WHERE ($subtypeClause)";
-    return CRM_Core_DAO::singleValueQuery($query);
+
+    CRM_Core_DAO::singleValueQuery($query);
+
+    // rebuild triggers CRM-13587
+    CRM_Core_DAO::triggerRebuild($tableName);
   }
 
   /**