$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();
// 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}",
{if $privacy.do_not_email}<span class="icon privacy-flag do-not-email" title="{ts}Privacy flag: Do Not Email{/ts}"></span>{elseif $item.on_hold}<span class="icon privacy-flag email-hold" title="{ts}Email on hold - generally due to bouncing.{/ts}"></span>{/if}
</div>
<div class="crm-content crm-contact_email {if $item.is_primary eq 1}primary{/if}">
- <a href="mailto:{$item.email}">{$item.email}</a>{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}
+ <a href="{crmURL p="civicrm/activity/email/add" q="action=add&reset=1&email_id=`$item.id`"}" class="crm-popup" title="{ts 1=$item.email}Send email to %1{/ts}">
+ {$item.email}
+ </a>
+ {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}
<span class="signature-link description">
<a href="#" title="{ts}Signature{/ts}" onClick="showHideSignature( '{$blockId}' ); return false;">{ts}(signature){/ts}</a>