From 2a7e1ddc0c496d6dd02384429a8519ca206a2c3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Sch=C3=BCttler?= Date: Mon, 10 Jul 2017 17:01:58 +0200 Subject: [PATCH] CRM-CRM-20841 - Dedupe - Show on_hold, is_bulkmail or signature merge conflicts --- CRM/Dedupe/Merger.php | 6 ++++- CRM/Utils/Mail.php | 38 ++++++++++++++++++++++++++++ templates/CRM/Contact/Form/Merge.tpl | 19 +++++++++++--- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index bf95d2e977..cbf83d3602 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -975,7 +975,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m ), 'email' => array( 'label' => 'Email', - 'displayField' => 'email', + 'displayField' => 'display', 'sortString' => 'location_type_id', 'hasLocation' => TRUE, 'hasType' => FALSE, @@ -1172,6 +1172,10 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m CRM_Core_BAO_Address::fixAddress($value); $locations[$moniker][$blockName][$cnt]['display'] = CRM_Utils_Address::format($value); } + // Fix email display + elseif ($blockName == 'email') { + $locations[$moniker][$blockName][$cnt]['display'] = CRM_Utils_Mail::format($value); + } $cnt++; } diff --git a/CRM/Utils/Mail.php b/CRM/Utils/Mail.php index 78dc6676e7..fdb17c9198 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -520,4 +520,42 @@ class CRM_Utils_Mail { ); } + /** + * Format an email string from email fields. + * + * @param array $fields + * The email fields. + * @return string + * The formatted email string. + */ + public static function format($fields) { + $formattedEmail = ''; + if (!empty($fields['email'])) { + $formattedEmail = $fields['email']; + } + + $formattedSuffix = array(); + if (!empty($fields['is_bulkmail'])) { + $formattedSuffix[] = '(' . ts('Bulk') . ')'; + } + if (!empty($fields['on_hold'])) { + if ($fields['on_hold'] == 2) { + $formattedSuffix[] = '(' . ts('On Hold - Opt Out') . ')'; + } + else { + $formattedSuffix[] = '(' . ts('On Hold') . ')'; + } + } + if (!empty($fields['signature_html']) || !empty($fields['signature_text'])) { + $formattedSuffix[] = '(' . ts('Signature') . ')'; + } + + // Add suffixes on a new line, if there is any. + if (!empty($formattedSuffix)) { + $formattedEmail .= "\n" . implode(' ', $formattedSuffix); + } + + return $formattedEmail; + } + } diff --git a/templates/CRM/Contact/Form/Merge.tpl b/templates/CRM/Contact/Form/Merge.tpl index ca2de4c87a..cb76f90941 100644 --- a/templates/CRM/Contact/Form/Merge.tpl +++ b/templates/CRM/Contact/Form/Merge.tpl @@ -114,8 +114,20 @@ {* @TODO check if this is ever an array or a fileName? *} - {* This is on one long line for address formatting *} - {if $row.title|substr:0:7 == "Address"}{else}{/if}{if !is_array($row.other)}{$row.other}{elseif $row.other.fileName}{$row.other.fileName}{else}{', '|implode:$row.other}{/if} + {if $row.title|substr:0:5 == "Email" OR + $row.title|substr:0:7 == "Address"} + + {else} + + {/if} + {if !is_array($row.other)} + {$row.other} + {elseif $row.other.fileName} + {$row.other.fileName} + {else} + {', '|implode:$row.other} + {/if} + @@ -131,7 +143,8 @@ {strip} - {if $row.title|substr:0:7 == "Address"} + {if $row.title|substr:0:5 == "Email" OR + $row.title|substr:0:7 == "Address"} {else} -- 2.25.1