Move definition of phone_type_id to the xml.
authoreileen <emcnaughton@wikimedia.org>
Sat, 28 Jul 2018 05:35:42 +0000 (17:35 +1200)
committereileen <emcnaughton@wikimedia.org>
Mon, 30 Jul 2018 10:30:55 +0000 (22:30 +1200)
This has the side effect of making it such that it only gets 16 char rather than 255. I thnk this is 'ok' here but there is a separate issue open to increase the varchar for all fields on export

CRM/Core/DAO/Phone.php
CRM/Export/BAO/Export.php
tests/phpunit/CRM/Export/BAO/ExportTest.php
xml/schema/Core/Phone.xml

index 034f0d54af1eedefd73245e9b5aec7dd4dd963a7..660ca3f05276703975d18f3b733d91e917217c4d 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Core/Phone.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:661faad4886dd1a40784d465b906f447)
+ * (GenCodeChecksum:22802e5d7d8dfce93626004aaf6cd2e2)
  */
 
 /**
@@ -258,6 +258,10 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Phone Type'),
           'description' => 'Which type of phone does this number belongs.',
+          'export' => TRUE,
+          'where' => 'civicrm_phone.phone_type_id',
+          'headerPattern' => '',
+          'dataPattern' => '',
           'table_name' => 'civicrm_phone',
           'entity' => 'Phone',
           'bao' => 'CRM_Core_BAO_Phone',
index c1f5d148d7545d87e5c76bc7cd8ae1452ac33a03..19865c7a800666faff0e664fb3d626afc98e654d 100644 (file)
@@ -1414,20 +1414,15 @@ WHERE  {$whereClause}";
   public static function setHeaderRows($field, $headerRows, $sqlColumns, $processor, $value, $phoneTypes, $imProviders, $relationQuery) {
 
     $queryFields = $processor->getQueryFields();
-    // Split campaign into 2 fields for id and title
-    if (substr($field, -14) == 'campaign_title') {
-      $headerRows[] = ts('Campaign Title');
-    }
-    elseif (substr($field, -11) == 'campaign_id') {
+    if (substr($field, -11) == 'campaign_id') {
+      // @todo - set this correctly in the xml rather than here.
       $headerRows[] = ts('Campaign ID');
     }
     elseif (isset($queryFields[$field]['title'])) {
       $headerRows[] = $queryFields[$field]['title'];
     }
-    elseif ($field == 'phone_type_id') {
-      $headerRows[] = ts('Phone Type');
-    }
     elseif ($field == 'provider_id') {
+      // @todo - set this correctly in the xml rather than here.
       $headerRows[] = ts('IM Service Provider');
     }
     elseif ($processor->isRelationshipTypeKey($field)) {
index b3116f586c2de86e481121a9b4698f5c36b6d5bd..4d1631b72c6cb71656886f40ae8e24c6c73e154c 100644 (file)
@@ -1765,26 +1765,26 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
         66 => 'Country',
         67 => 'Phone',
         68 => 'Phone Extension',
-        69 => 'Email',
-        70 => 'On Hold',
-        71 => 'Use for Bulk Mail',
-        72 => 'Signature Text',
-        73 => 'Signature Html',
-        74 => 'IM Provider',
-        75 => 'IM Screen Name',
-        76 => 'OpenID',
-        77 => 'World Region',
-        78 => 'Website',
-        79 => 'Group(s)',
-        80 => 'Tag(s)',
-        81 => 'Note(s)',
-        82 => 'Phone Type',
+        69 => 'Phone Type',
+        70 => 'Email',
+        71 => 'On Hold',
+        72 => 'Use for Bulk Mail',
+        73 => 'Signature Text',
+        74 => 'Signature Html',
+        75 => 'IM Provider',
+        76 => 'IM Screen Name',
+        77 => 'OpenID',
+        78 => 'World Region',
+        79 => 'Website',
+        80 => 'Group(s)',
+        81 => 'Tag(s)',
+        82 => 'Note(s)',
         83 => 'IM Service Provider',
       ];
     if (!$isContactExport) {
-      unset($headers[79]);
       unset($headers[80]);
       unset($headers[81]);
+      unset($headers[82]);
     }
     return $headers;
   }
@@ -2063,6 +2063,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
       'country' => 'country varchar(64)',
       'phone' => 'phone varchar(32)',
       'phone_ext' => 'phone_ext varchar(16)',
+      'phone_type_id' => 'phone_type_id varchar(16)',
       'email' => 'email varchar(254)',
       'on_hold' => 'on_hold varchar(16)',
       'is_bulkmail' => 'is_bulkmail varchar(16)',
@@ -2076,7 +2077,6 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
       'groups' => 'groups text',
       'tags' => 'tags text',
       'notes' => 'notes text',
-      'phone_type_id' => 'phone_type_id varchar(255)',
       'provider_id' => 'provider_id varchar(255)',
     ];
     if (!$isContactExport) {
@@ -2260,7 +2260,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
       'openid' => 'openid varchar(255)',
       'world_region' => 'world_region varchar(128)',
       'url' => 'url varchar(128)',
-      'phone_type_id' => 'phone_type_id varchar(255)',
+      'phone_type_id' => 'phone_type_id varchar(16)',
       'provider_id' => 'provider_id varchar(255)',
       'financial_type' => 'financial_type varchar(64)',
       'contribution_source' => 'contribution_source varchar(255)',
index 29b17c1df38aa935d4c2b7acb08f5cdf5b960829..f3703dc8f585ef43dd683a96d850c261ab3170b3 100644 (file)
     <name>phone_type_id</name>
     <title>Phone Type</title>
     <type>int unsigned</type>
+    <export>true</export>
     <comment>Which type of phone does this number belongs.</comment>
     <pseudoconstant>
       <optionGroupName>phone_type</optionGroupName>