From 3992bdad8d3011d4ecaecdf4aabb0770074dad36 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 18 Sep 2019 13:15:36 -0400 Subject: [PATCH] Mailing API - Expose option list for `header_id` and `footer_id` --- CRM/Mailing/DAO/Mailing.php | 14 +++++++++++++- tests/phpunit/api/v3/MailingTest.php | 10 ++++++++++ xml/schema/Mailing/Mailing.xml | 12 ++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CRM/Mailing/DAO/Mailing.php b/CRM/Mailing/DAO/Mailing.php index a3bc2c85c9..9f727b0c26 100644 --- a/CRM/Mailing/DAO/Mailing.php +++ b/CRM/Mailing/DAO/Mailing.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Mailing/Mailing.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:c294c497dac6129fe311fe8484e1e975) + * (GenCodeChecksum:aa54484f6e9b8d5ad8e75680f95cfc67) */ /** @@ -405,6 +405,12 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO { 'bao' => 'CRM_Mailing_BAO_Mailing', 'localizable' => 0, 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent', + 'pseudoconstant' => [ + 'table' => 'civicrm_mailing_component', + 'keyColumn' => 'id', + 'labelColumn' => 'name', + 'condition' => 'component_type = "Header"', + ], ], 'footer_id' => [ 'name' => 'footer_id', @@ -417,6 +423,12 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO { 'bao' => 'CRM_Mailing_BAO_Mailing', 'localizable' => 0, 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent', + 'pseudoconstant' => [ + 'table' => 'civicrm_mailing_component', + 'keyColumn' => 'id', + 'labelColumn' => 'name', + 'condition' => 'component_type = "Footer"', + ], ], 'reply_id' => [ 'name' => 'reply_id', diff --git a/tests/phpunit/api/v3/MailingTest.php b/tests/phpunit/api/v3/MailingTest.php index f8e1d8bc2c..6434ffbfd1 100644 --- a/tests/phpunit/api/v3/MailingTest.php +++ b/tests/phpunit/api/v3/MailingTest.php @@ -132,6 +132,16 @@ class api_v3_MailingTest extends CiviUnitTestCase { $this->assertTrue(isset($types['values']['traditional'])); } + /** + * Check that default header+footer are available. + */ + public function testHeaderFooterOptions() { + $headers = $this->callAPISuccess('Mailing', 'getoptions', ['field' => 'header']); + $this->assertTrue(in_array('Mailing Header', $headers['values'])); + $footers = $this->callAPISuccess('Mailing', 'getoptions', ['field' => 'footer']); + $this->assertTrue(in_array('Mailing Footer', $footers['values'])); + } + /** * The `template_options` field should be treated a JSON object. * diff --git a/xml/schema/Mailing/Mailing.xml b/xml/schema/Mailing/Mailing.xml index 0ef0930f0a..e4f8a0eaee 100644 --- a/xml/schema/Mailing/Mailing.xml +++ b/xml/schema/Mailing/Mailing.xml @@ -39,6 +39,12 @@ header_id Mailing Header int unsigned + + civicrm_mailing_component
+ id + name + component_type = "Header" +
FK to the header component. @@ -51,6 +57,12 @@ footer_id Mailing Footer int unsigned + + civicrm_mailing_component
+ id + name + component_type = "Footer" +
FK to the footer component. -- 2.25.1