From: eileen Date: Wed, 22 Nov 2017 21:42:05 +0000 (+1300) Subject: CRM-21471 remove unused core function CRM_Core_Pseudoconstant::greetingDefaults X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5f35a2d9549c56a0cb181316309b3596a906c9f2;p=civicrm-core.git CRM-21471 remove unused core function CRM_Core_Pseudoconstant::greetingDefaults --- diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 56599265fd..5f1abdadc7 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -2640,15 +2640,8 @@ AND civicrm_openid.is_primary = 1"; * * @param object $contact * Contact object after save. - * @param bool $useDefaults - * Use default greeting values. */ - public static function processGreetings(&$contact, $useDefaults = FALSE) { - if ($useDefaults) { - //retrieve default greetings - $defaultGreetings = CRM_Core_PseudoConstant::greetingDefaults(); - $contactDefaults = $defaultGreetings[$contact->contact_type]; - } + public static function processGreetings(&$contact) { // The contact object has not always required the // fields that are required to calculate greetings @@ -2681,14 +2674,7 @@ AND civicrm_openid.is_primary = 1"; $updateQueryString[] = " email_greeting_custom = NULL "; } else { - if ($useDefaults) { - reset($contactDefaults['email_greeting']); - $emailGreetingID = key($contactDefaults['email_greeting']); - $emailGreetingString = $contactDefaults['email_greeting'][$emailGreetingID]; - $updateQueryString[] = " email_greeting_id = $emailGreetingID "; - $updateQueryString[] = " email_greeting_custom = NULL "; - } - elseif ($contact->email_greeting_custom) { + if ($contact->email_greeting_custom) { $updateQueryString[] = " email_greeting_display = NULL "; } } @@ -2717,14 +2703,7 @@ AND civicrm_openid.is_primary = 1"; $updateQueryString[] = " postal_greeting_custom = NULL "; } else { - if ($useDefaults) { - reset($contactDefaults['postal_greeting']); - $postalGreetingID = key($contactDefaults['postal_greeting']); - $postalGreetingString = $contactDefaults['postal_greeting'][$postalGreetingID]; - $updateQueryString[] = " postal_greeting_id = $postalGreetingID "; - $updateQueryString[] = " postal_greeting_custom = NULL "; - } - elseif ($contact->postal_greeting_custom) { + if ($contact->postal_greeting_custom) { $updateQueryString[] = " postal_greeting_display = NULL "; } } @@ -2754,14 +2733,7 @@ AND civicrm_openid.is_primary = 1"; $updateQueryString[] = " addressee_custom = NULL "; } else { - if ($useDefaults) { - reset($contactDefaults['addressee']); - $addresseeID = key($contactDefaults['addressee']); - $addresseeString = $contactDefaults['addressee'][$addresseeID]; - $updateQueryString[] = " addressee_id = $addresseeID "; - $updateQueryString[] = " addressee_custom = NULL "; - } - elseif ($contact->addressee_custom) { + if ($contact->addressee_custom) { $updateQueryString[] = " addressee_display = NULL "; } } diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 4196644418..dd13698211 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -155,12 +155,6 @@ class CRM_Core_PseudoConstant { */ private static $greeting; - /** - * Default Greetings - * @var array - */ - private static $greetingDefaults; - /** * Extensions of type module * @var array @@ -1650,6 +1644,10 @@ WHERE id = %1 * array reference of all greetings. */ public static function greeting($filter, $columnName = 'label') { + if (!isset(Civi::$statics[__CLASS__]['greeting'])) { + Civi::$statics[__CLASS__]['greeting'] = array(); + } + $index = $filter['greeting_type'] . '_' . $columnName; // also add contactType to the array @@ -1658,11 +1656,7 @@ WHERE id = %1 $index .= '_' . $contactType; } - if (NULL === self::$greeting) { - self::$greeting = array(); - } - - if (!CRM_Utils_Array::value($index, self::$greeting)) { + if (!CRM_Utils_Array::value($index, Civi::$statics[__CLASS__]['greeting'])) { $filterCondition = NULL; if ($contactType) { $filterVal = 'v.filter ='; @@ -1682,40 +1676,10 @@ WHERE id = %1 $filterCondition .= "AND (v.filter = 0 OR {$filterVal}) "; } - self::$greeting[$index] = CRM_Core_OptionGroup::values($filter['greeting_type'], NULL, NULL, NULL, $filterCondition, $columnName); - } - - return self::$greeting[$index]; - } - - /** - * Construct array of default greeting values for contact type. - * - * - * @return array - * array reference of default greetings. - */ - public static function &greetingDefaults() { - if (!self::$greetingDefaults) { - $defaultGreetings = array(); - $contactTypes = self::get('CRM_Contact_DAO_Contact', 'contact_type', array( - 'keyColumn' => 'id', - 'labelColumn' => 'name', - )); - - foreach ($contactTypes as $filter => $contactType) { - $filterCondition = " AND (v.filter = 0 OR v.filter = $filter) AND v.is_default = 1 "; - - foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) { - $tokenVal = CRM_Core_OptionGroup::values($greeting, NULL, NULL, NULL, $filterCondition, 'label'); - $defaultGreetings[$contactType][$greeting] = $tokenVal; - } - } - - self::$greetingDefaults = $defaultGreetings; + Civi::$statics[__CLASS__]['greeting'][$index] = CRM_Core_OptionGroup::values($filter['greeting_type'], NULL, NULL, NULL, $filterCondition, $columnName); } - return self::$greetingDefaults; + return Civi::$statics[__CLASS__]['greeting'][$index]; } /**