From a304337bc062f09d5715df3ed3965418720af33f Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 11 Jul 2013 14:12:14 -0700 Subject: [PATCH] CRM_Utils_Migrate_Export - Allow export of specific UFGroups --- CRM/Utils/Migrate/Export.php | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/CRM/Utils/Migrate/Export.php b/CRM/Utils/Migrate/Export.php index 9045c95d89..aeac4e693d 100644 --- a/CRM/Utils/Migrate/Export.php +++ b/CRM/Utils/Migrate/Export.php @@ -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 * -- 2.25.1