From 8e4aa90cc2032a24a15856b195d64aba5abf6249 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 6 Aug 2014 10:45:44 +0100 Subject: [PATCH] Change contact summary email links from 'mailto' to email activity popup --- CRM/Contact/Form/Task/Email.php | 16 +++++++++++++++- CRM/Contact/Form/Task/EmailCommon.php | 4 ++++ templates/CRM/Contact/Page/Inline/Email.tpl | 9 ++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/Form/Task/Email.php b/CRM/Contact/Form/Task/Email.php index 51d53b9c9e..37370be64c 100644 --- a/CRM/Contact/Form/Task/Email.php +++ b/CRM/Contact/Form/Task/Email.php @@ -104,7 +104,21 @@ class CRM_Contact_Form_Task_Email extends CRM_Contact_Form_Task { $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $cid = CRM_Utils_Request::retrieve('cid', 'String', $this, FALSE); - if ($cid){ + + // Allow request to specify email id rather than contact id + $toEmailId = CRM_Utils_Request::retrieve('email_id', 'String', $this); + if ($toEmailId) { + $toEmail = civicrm_api('email', 'getsingle', array('version' => 3, 'id' => $toEmailId)); + if (!empty($toEmail['email']) && !empty($toEmail['contact_id'])) { + $this->_toEmail = $toEmail; + } + if (!$cid) { + $cid = $toEmail['contact_id']; + $this->set('cid', $cid); + } + } + + if ($cid) { $cid = explode(',',$cid); $displayName = array(); diff --git a/CRM/Contact/Form/Task/EmailCommon.php b/CRM/Contact/Form/Task/EmailCommon.php index 6240778d9f..cfb2f051ec 100644 --- a/CRM/Contact/Form/Task/EmailCommon.php +++ b/CRM/Contact/Form/Task/EmailCommon.php @@ -228,6 +228,10 @@ class CRM_Contact_Form_Task_EmailCommon { // build array's which are used to setdefaults if (in_array($contactId, $form->_toContactIds)) { $form->_toContactDetails[$contactId] = $form->_contactDetails[$contactId]; + // If a particular address has been specified as the default, use that instead of contact's primary email + if (!empty($form->_toEmail) && $form->_toEmail['contact_id'] == $contactId) { + $email = $form->_toEmail['email']; + } $toArray[] = array( 'text' => '"' . $value['sort_name'] . '" <' . $email . '>', 'id' => "$contactId::{$email}", diff --git a/templates/CRM/Contact/Page/Inline/Email.tpl b/templates/CRM/Contact/Page/Inline/Email.tpl index ea4ef84c6c..5173302d54 100644 --- a/templates/CRM/Contact/Page/Inline/Email.tpl +++ b/templates/CRM/Contact/Page/Inline/Email.tpl @@ -48,7 +48,14 @@ {if $privacy.do_not_email}{elseif $item.on_hold}{/if}
- {$item.email}{if $item.on_hold == 2} ({ts}On Hold - Opt Out{/ts}){elseif $item.on_hold} ({ts}On Hold{/ts}){/if}{if $item.is_bulkmail} ({ts}Bulk{/ts}){/if} + {if !$item.on_hold and !$privacy.do_not_email} + + {$item.email} + + {else} + {$item.email} + {/if} + {if $item.on_hold == 2} ({ts}On Hold - Opt Out{/ts}){elseif $item.on_hold} ({ts}On Hold{/ts}){/if}{if $item.is_bulkmail} ({ts}Bulk{/ts}){/if} {if $item.signature_text OR $item.signature_html} {ts}(signature){/ts} -- 2.25.1