From 0051bad38249263b754b10bead872ace0887aba2 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 17 Jan 2017 01:41:39 -0800 Subject: [PATCH] CRM-19690 - Task_AdhocMailing - Use highest-priority template type If you perform a contact search and create a new mailing, it would use `template_type=traditional`, even if another template type had greater priority. With this patch, it respects the priority. Note: I considered changing the default in Mailing.create API to always match most-preferred template-type. However, that would break some existing API consumers (e.g. headless consumers or ones who define their own UI). For external API-based integrations, we should preserve the default semantics of `body_text`/`body_html` by defaulting to `template_type=traditional`. The preference in CRM-19690 is that any use-case based on the screen `civicrm/a/#/mailing/{id}` should have its default determined by weight. --- CRM/Mailing/Form/Task/AdhocMailing.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CRM/Mailing/Form/Task/AdhocMailing.php b/CRM/Mailing/Form/Task/AdhocMailing.php index 32f99d5a3c..6a06b30e86 100644 --- a/CRM/Mailing/Form/Task/AdhocMailing.php +++ b/CRM/Mailing/Form/Task/AdhocMailing.php @@ -38,11 +38,14 @@ class CRM_Mailing_Form_Task_AdhocMailing extends CRM_Contact_Form_Task { public function preProcess() { parent::preProcess(); + $templateTypes = CRM_Mailing_BAO_Mailing::getTemplateTypes(); list ($groupId, $ssId) = $this->createHiddenGroup(); $mailing = civicrm_api3('Mailing', 'create', array( 'name' => "", 'campaign_id' => NULL, 'replyto_email' => "", + 'template_type' => $templateTypes[0]['name'], + 'template_options' => array('nonce' => 1), 'subject' => "", 'body_html' => "", 'body_text' => "", -- 2.25.1