Skip to content

Commit

Permalink
Merge pull request #10630 from tschuettler/CRM-CRM-20841
Browse files Browse the repository at this point in the history
CRM-20841 - Dedupe - Show on_hold, is_bulkmail or signature merge…
  • Loading branch information
eileenmcnaughton authored Jun 6, 2018
2 parents e09262a + 2a7e1dd commit 1c5bc02
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ public static function getLocationBlockInfo() {
),
'email' => array(
'label' => 'Email',
'displayField' => 'email',
'displayField' => 'display',
'sortString' => 'location_type_id',
'hasLocation' => TRUE,
'hasType' => FALSE,
Expand Down Expand Up @@ -1231,6 +1231,10 @@ public static function getRowsElementsAndInfo($mainId, $otherId, $checkPermissio
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++;
}
Expand Down
38 changes: 38 additions & 0 deletions CRM/Utils/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,4 +539,42 @@ public static function appendPDF($fileName, $html, $format = NULL) {
);
}

/**
* 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;
}

}
19 changes: 16 additions & 3 deletions templates/CRM/Contact/Form/Merge.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,20 @@

<td>
{* @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"}<span style="white-space: pre">{else}<span>{/if}{if !is_array($row.other)}{$row.other}{elseif $row.other.fileName}{$row.other.fileName}{else}{', '|implode:$row.other}{/if}</span>
{if $row.title|substr:0:5 == "Email" OR
$row.title|substr:0:7 == "Address"}
<span style="white-space: pre">
{else}
<span>
{/if}
{if !is_array($row.other)}
{$row.other}
{elseif $row.other.fileName}
{$row.other.fileName}
{else}
{', '|implode:$row.other}
{/if}
</span>
</td>

<td style='white-space: nowrap'>
Expand All @@ -131,7 +143,8 @@

<td>
{strip}
{if $row.title|substr:0:7 == "Address"}
{if $row.title|substr:0:5 == "Email" OR
$row.title|substr:0:7 == "Address"}
<span style="white-space: pre" id="main_{$blockName}_{$blockId}">
{else}
<span id="main_{$blockName}_{$blockId}">
Expand Down

0 comments on commit 1c5bc02

Please sign in to comment.