CRM-15048 - Respect custom field text_length during export
authorColeman Watts <coleman@civicrm.org>
Wed, 6 Aug 2014 11:59:25 +0000 (12:59 +0100)
committerColeman Watts <coleman@civicrm.org>
Wed, 6 Aug 2014 12:05:27 +0000 (13:05 +0100)
CRM/Core/BAO/CustomField.php
CRM/Export/BAO/Export.php

index 854831b33f9ae7499a8962786f88d8005622be04..3336e02f20179c74ac6c1fee1f4cfc7a996154a8 100644 (file)
@@ -643,6 +643,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         'import' => 1,
         'custom_field_id' => $id,
         'options_per_line' => CRM_Utils_Array::value('options_per_line', $values),
+        'text_length' => CRM_Utils_Array::value('text_length', $values, 255),
         'data_type' => CRM_Utils_Array::value('data_type', $values),
         'html_type' => CRM_Utils_Array::value('html_type', $values),
         'is_search_range' => CRM_Utils_Array::value('is_search_range', $values),
index 0d7e74958e6dea7e68cf1a1cd480c885c6a04e7f..d2d56fa09c5dbcff7afcc764c6db2089dbe6e653 100644 (file)
@@ -1367,10 +1367,14 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
           if (isset($query->_fields[$field]['data_type'])) {
 
             switch ($query->_fields[$field]['data_type']) {
+              case 'String':
+                $length = empty($query->_fields[$field]['text_length']) ? 255 : $query->_fields[$field]['text_length'];
+                $sqlColumns[$fieldName] = "$fieldName varchar($length)";
+                break;
+
               case 'Country':
               case 'StateProvince':
               case 'Link':
-              case 'String':
                 $sqlColumns[$fieldName] = "$fieldName varchar(255)";
                 break;