From 4c49535eb0e71d0c098b2f2bbcad596f0e00303d Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Wed, 13 Dec 2017 14:19:19 +0000 Subject: [PATCH] CRM-21548 Remove unused variable and param from CRM_Utils_Address::format --- CRM/Contact/BAO/Individual.php | 4 ++-- CRM/Contact/Form/Task/Label.php | 2 +- CRM/Core/BAO/Address.php | 2 +- CRM/Member/Form/Task/Label.php | 2 +- CRM/Utils/Address.php | 21 +++------------------ tools/bin/scripts/updateNameCache.php | 4 ++-- 6 files changed, 10 insertions(+), 25 deletions(-) diff --git a/CRM/Contact/BAO/Individual.php b/CRM/Contact/BAO/Individual.php index 013e576e53..bce8ff5e92 100644 --- a/CRM/Contact/BAO/Individual.php +++ b/CRM/Contact/BAO/Individual.php @@ -216,14 +216,14 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_Contact { //build the sort name. $format = Civi::settings()->get('sort_name_format'); $sortName = CRM_Utils_Address::format($formatted, $format, - FALSE, FALSE, TRUE, $tokenFields + FALSE, FALSE, $tokenFields ); $sortName = trim($sortName); //build the display name. $format = Civi::settings()->get('display_name_format'); $displayName = CRM_Utils_Address::format($formatted, $format, - FALSE, FALSE, TRUE, $tokenFields + FALSE, FALSE, $tokenFields ); $displayName = trim($displayName); } diff --git a/CRM/Contact/Form/Task/Label.php b/CRM/Contact/Form/Task/Label.php index 24e1dce7fe..6f12a62ea8 100644 --- a/CRM/Contact/Form/Task/Label.php +++ b/CRM/Contact/Form/Task/Label.php @@ -333,7 +333,7 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { $row['preferred_communication_method'] = implode(', ', $temp); } $row['id'] = $id; - $formatted = CRM_Utils_Address::format($row, 'mailing_format', FALSE, TRUE, $individualFormat, $tokenFields); + $formatted = CRM_Utils_Address::format($row, 'mailing_format', FALSE, TRUE, $tokenFields); // CRM-2211: UFPDF doesn't have bidi support; use the PECL fribidi package to fix it. // On Ubuntu (possibly Debian?) be aware of http://pecl.php.net/bugs/bug.php?id=12366 diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 7d7e2caf4e..edf8d6d695 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -1083,7 +1083,7 @@ SELECT is_primary, 'individual_prefix' => $rows[$rowID]['individual_prefix'], ); $format = Civi::settings()->get('display_name_format'); - $firstNameWithPrefix = CRM_Utils_Address::format($formatted, $format, FALSE, FALSE, TRUE); + $firstNameWithPrefix = CRM_Utils_Address::format($formatted, $format, FALSE, FALSE); $firstNameWithPrefix = trim($firstNameWithPrefix); // fill uniqueAddress array with last/first name tree diff --git a/CRM/Member/Form/Task/Label.php b/CRM/Member/Form/Task/Label.php index 0eae095fdb..0bb7f0129c 100644 --- a/CRM/Member/Form/Task/Label.php +++ b/CRM/Member/Form/Task/Label.php @@ -122,7 +122,7 @@ class CRM_Member_Form_Task_Label extends CRM_Member_Form_Task { $row['preferred_communication_method'] = implode(', ', $temp); } $row['id'] = $id; - $formatted = CRM_Utils_Address::format($row, 'mailing_format', FALSE, TRUE, $individualFormat, $tokenFields); + $formatted = CRM_Utils_Address::format($row, 'mailing_format', FALSE, TRUE, $tokenFields); $rows[$id] = array($formatted); } if ($isPerMembership) { diff --git a/CRM/Utils/Address.php b/CRM/Utils/Address.php index 551c48bfaa..3168164aa0 100644 --- a/CRM/Utils/Address.php +++ b/CRM/Utils/Address.php @@ -39,6 +39,9 @@ class CRM_Utils_Address { * Format an address basing on the address fields provided. * Use Setting's address_format if there's no format specified. * + * This function is also used to generate a contact's display_name and + * sort_name. + * * @param array $fields * The address fields. * @param string $format @@ -47,9 +50,6 @@ class CRM_Utils_Address { * If true indicates, the address to be built in hcard-microformat standard. * @param bool $mailing * If true indicates, the call has been made from mailing label. - * @param bool $individualFormat - * If true indicates, the call has been made for the contact of type 'individual'. - * * @param null $tokenFields * * @return string @@ -61,7 +61,6 @@ class CRM_Utils_Address { $format = NULL, $microformat = FALSE, $mailing = FALSE, - $individualFormat = FALSE, $tokenFields = NULL ) { static $config = NULL; @@ -115,20 +114,6 @@ class CRM_Utils_Address { } } - $contactName = CRM_Utils_Array::value('display_name', $fields); - if (!$individualFormat) { - if (isset($fields['id'])) { - $type = CRM_Contact_BAO_Contact::getContactType($fields['id']); - } - else { - $type = 'Individual'; - } - - if ($type == 'Individual') { - $contactName = CRM_Utils_Array::value('addressee_display', $fields); - } - } - if (!$microformat) { // replacements in case of Individual Name Format $replacements = array( diff --git a/tools/bin/scripts/updateNameCache.php b/tools/bin/scripts/updateNameCache.php index 01ea57b4ba..18d490aa26 100644 --- a/tools/bin/scripts/updateNameCache.php +++ b/tools/bin/scripts/updateNameCache.php @@ -109,10 +109,10 @@ class CRM_UpdateNameCache { $params['individual_prefix'] = $prefixes[$dao->prefix_id]; $params['individual_suffix'] = $suffixes[$dao->suffix_id]; - $sortName = CRM_Utils_Address::format($params, $sortFormat, FALSE, FALSE, TRUE, $tokenFields); + $sortName = CRM_Utils_Address::format($params, $sortFormat, FALSE, FALSE, $tokenFields); $sortName = trim(CRM_Core_DAO::escapeString($sortName)); - $displayName = CRM_Utils_Address::format($params, $displayFormat, FALSE, FALSE, TRUE, $tokenFields); + $displayName = CRM_Utils_Address::format($params, $displayFormat, FALSE, FALSE, $tokenFields); $displayName = trim(CRM_Core_DAO::escapeString($displayName)); //check for email -- 2.25.1