CRM_Utils_Migrate_Export - Allow export of specific UFGroups
authorTim Otten <totten@civicrm.org>
Thu, 11 Jul 2013 21:12:14 +0000 (14:12 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 11 Jul 2013 21:12:14 +0000 (14:12 -0700)
CRM/Utils/Migrate/Export.php

index 9045c95d89038d0017a8ed8e54ec6996101c3635..aeac4e693de399b5ae83a09e4d0f64d4cb3ee6d3 100644 (file)
@@ -316,6 +316,43 @@ class CRM_Utils_Migrate_Export {
     $this->fetch('customField', 'CRM_Core_DAO_CustomField', $sql);
   }
 
+  /**
+   * @param array $ufGroupIds list of custom groups to export
+   * @return void
+   */
+  function buildUFGroups($ufGroupIds) {
+    $ufGroupIdsSql = implode(',', array_filter($ufGroupIds, 'is_numeric'));
+    if (empty($ufGroupIdsSql)) {
+      return;
+    }
+
+    $sql = "
+      SELECT cg.*
+      FROM   civicrm_uf_group cg
+      WHERE  cg.id IN ($ufGroupIdsSql)
+
+    ";
+    $this->fetch('profileGroup', 'CRM_Core_DAO_UFGroup', $sql);
+
+    $sql = "
+      SELECT f.*
+      FROM   civicrm_uf_field f,
+             civicrm_uf_group cg
+      WHERE  f.uf_group_id = cg.id
+      AND    cg.id IN ($ufGroupIdsSql)
+    ";
+    $this->fetch('profileField', 'CRM_Core_DAO_UFField', $sql);
+
+    $sql = "
+      SELECT *
+      FROM   civicrm_uf_join
+      WHERE  entity_table IS NULL
+      AND    entity_id    IS NULL
+      AND    uf_group_id  IN ($ufGroupIdsSql)
+    ";
+    $this->fetch('profileJoin', 'CRM_Core_DAO_UFJoin', $sql);
+  }
+
   /**
    * Render the in-memory representation as XML
    *