X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FMail.php;h=1328521d738119ff92f49898ef3f4764e12501bf;hb=1c5bc02c1bbfc3cbbee279e61b488787a4c41daf;hp=8929f2052ee3246dd53353dd92f08bf9e8fa9d50;hpb=c6ca33613ef7a5d1114b61480e3eb530f37a74f2;p=civicrm-core.git diff --git a/CRM/Utils/Mail.php b/CRM/Utils/Mail.php index 8929f2052e..1328521d73 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -539,4 +539,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; + } + }