X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FToken.php;h=4f8729229981ef6167c752bb15e413032e96c3f6;hb=3cfdbf479f28dde3f72458e345b6c003a9db01e2;hp=89d67e0c5b9a4108f7553037e4f8c3b80a015552;hpb=3b1e452b9449056fef9e225e7b6988322bc1229f;p=civicrm-core.git diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 89d67e0c5b..4f87292299 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -1,43 +1,27 @@ [ 'forward', 'optOut', @@ -88,7 +72,6 @@ class CRM_Utils_Token { 'welcome' => ['group'], ]; - /** * @deprecated * This is used by CiviMail but will be made redundant by FlexMailer. @@ -116,7 +99,7 @@ class CRM_Utils_Token { * The message. * * @return bool|array - * true if all required tokens are found, + * true if all required tokens are found, * else an array of the missing tokens */ public static function requiredTokens(&$str) { @@ -178,7 +161,7 @@ class CRM_Utils_Token { * The token variable. * @param string $value * The value to substitute for the token. - * @param string (reference) $str The string to replace in + * @param string $str (reference) The string to replace in * * @param bool $escapeSmarty * @@ -1260,10 +1243,10 @@ class CRM_Utils_Token { // special case for greeting replacement foreach ([ - 'email_greeting', - 'postal_greeting', - 'addressee', - ] as $val) { + 'email_greeting', + 'postal_greeting', + 'addressee', + ] as $val) { if (!empty($contactDetails[$contactID][$val])) { $contactDetails[$contactID][$val] = $contactDetails[$contactID]["{$val}_display"]; } @@ -1300,8 +1283,8 @@ class CRM_Utils_Token { * contactDetails with hooks swapped out */ public static function getAnonymousTokenDetails($contactIDs = [ - 0, - ], + 0, + ], $returnProperties = NULL, $skipOnHold = TRUE, $skipDeceased = TRUE, @@ -1432,8 +1415,15 @@ class CRM_Utils_Token { * * @param string $tokenString * @param array $contactDetails + * @param array $greetingTokens */ private static function removeNullContactTokens(&$tokenString, $contactDetails, &$greetingTokens) { + + // Only applies to contact tokens + if (!array_key_exists('contact', $greetingTokens)) { + return; + } + $greetingTokensOriginal = $greetingTokens; $contactFieldList = CRM_Contact_DAO_Contact::fields(); // Sometimes contactDetails are in a multidemensional array, sometimes a @@ -1477,10 +1467,10 @@ class CRM_Utils_Token { $flattenTokens = []; foreach ([ - 'html', - 'text', - 'subject', - ] as $prop) { + 'html', + 'text', + 'subject', + ] as $prop) { if (!isset($tokens[$prop])) { continue; } @@ -1676,7 +1666,8 @@ class CRM_Utils_Token { public static function replaceContributionTokens($str, &$contribution, $html = FALSE, $knownTokens = NULL, $escapeSmarty = FALSE) { $key = 'contribution'; if (!$knownTokens || !CRM_Utils_Array::value($key, $knownTokens)) { - return $str; //early return + //early return + return $str; } self::_buildContributionTokens(); @@ -1759,9 +1750,9 @@ class CRM_Utils_Token { case 'fee': try { $value = civicrm_api3('membership_type', 'getvalue', [ - 'id' => $membership['membership_type_id'], - 'return' => 'minimum_fee', - ]); + 'id' => $membership['membership_type_id'], + 'return' => 'minimum_fee', + ]); $value = CRM_Utils_Money::format($value, NULL, NULL, TRUE); } catch (CiviCRM_API3_Exception $e) { @@ -1847,7 +1838,7 @@ class CRM_Utils_Token { * @param string $entity * @param bool $usedForTokenWidget * - * @return array $customTokens + * @return array * return custom field tokens in array('custom_N' => 'label') format */ public static function getCustomFieldTokens($entity, $usedForTokenWidget = FALSE) {