From 20b223004dd3856da8b7ea27e29cb9ec1f9a3b39 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 17 Sep 2014 00:08:22 -0400 Subject: [PATCH] CRM-15278 - Fix email signature on itinial form load --- CRM/Contact/Form/Task/EmailCommon.php | 13 ++++++++++++- templates/CRM/Mailing/Form/InsertTokens.tpl | 9 +-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CRM/Contact/Form/Task/EmailCommon.php b/CRM/Contact/Form/Task/EmailCommon.php index cfb2f051ec..91d71388e8 100644 --- a/CRM/Contact/Form/Task/EmailCommon.php +++ b/CRM/Contact/Form/Task/EmailCommon.php @@ -46,7 +46,7 @@ class CRM_Contact_Form_Task_EmailCommon { public $_toContactEmails = array(); /** - * @param $form + * @param CRM_Core_Form $form */ static function preProcessFromAddress(&$form) { $form->_single = FALSE; @@ -116,6 +116,17 @@ class CRM_Contact_Form_Task_EmailCommon { } $form->_fromEmails = CRM_Utils_Array::crmArrayMerge($emails, $domainEmails); + + // Add signature + $defaultEmail = civicrm_api3('email', 'getsingle', array('id' => key($form->_fromEmails))); + $defaults = array(); + if (!empty($defaultEmail['signature_html'])) { + $defaults['html_message'] = '

--' . $defaultEmail['signature_html']; + } + if (!empty($defaultEmail['signature_text'])) { + $defaults['text_message'] = "\n\n--\n" . $defaultEmail['signature_text']; + } + $form->setDefaults($defaults); } /** diff --git a/templates/CRM/Mailing/Form/InsertTokens.tpl b/templates/CRM/Mailing/Form/InsertTokens.tpl index 9e6129463c..f7a3b68d2b 100644 --- a/templates/CRM/Mailing/Form/InsertTokens.tpl +++ b/templates/CRM/Mailing/Form/InsertTokens.tpl @@ -433,14 +433,7 @@ CRM.$(function($) { }, 'json'); } } - if (!$().find('div.crm-error').text()) { - $(window).load(function () { - setSignature(); - }); - } - $("#fromEmailAddress").change( function( ) { - setSignature( ); - }); + $("#fromEmailAddress", form).change(setSignature); }); -- 2.25.1