Skip to content

Commit

Permalink
Merge pull request #19543 from eileenmcnaughton/msg_tpl
Browse files Browse the repository at this point in the history
replaceOrgTokens: Remove broken code
  • Loading branch information
eileenmcnaughton authored Apr 8, 2021
2 parents 73cf379 + fc0ac49 commit 9b7fe90
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions CRM/Utils/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,20 @@ public static function getDomainTokenReplacement($token, $domain, $html = FALSE,
/**
* Replace all the org-level tokens in $str
*
* @fixme: This function appears to be broken, as it depends on
* @fixme: This function appears to be broken, as it depended on
* nonexistant method: CRM_Core_BAO_CustomValue::getContactValues()
* Marking as deprecated until this is fixed
* Marking as deprecated until this is clarified.
*
* @deprecated
* - the above hard-breakage was there from 2015 to 2021 and
* no error was ever reported on it -does that mean
* 1) the code is never hit because the only function that
* calls this function is never called or
* 2) it was called but never required to resolve any tokens
* or more specifically custom field tokens
*
* The handling for custom fields with the removed token has
* now been removed.
*
* @param string $str
* The string with tokens to be replaced.
Expand All @@ -330,17 +340,16 @@ public static function getDomainTokenReplacement($token, $domain, $html = FALSE,
* @return string
* The processed string
*/
public static function &replaceOrgTokens($str, &$org, $html = FALSE, $escapeSmarty = FALSE) {
public static function replaceOrgTokens($str, &$org, $html = FALSE, $escapeSmarty = FALSE) {
self::$_tokens['org']
= array_merge(
array_keys(CRM_Contact_BAO_Contact::importableFields('Organization')),
['address', 'display_name', 'checksum', 'contact_id']
);

$cv = NULL;
foreach (self::$_tokens['org'] as $token) {
// print "Getting token value for $token<br/><br/>";
if ($token == '') {
if ($token === '') {
continue;
}

Expand All @@ -354,23 +363,11 @@ public static function &replaceOrgTokens($str, &$org, $html = FALSE, $escapeSmar

$value = NULL;

if ($cfID = CRM_Core_BAO_CustomField::getKeyID($token)) {
// only generate cv if we need it
if ($cv === NULL) {
$cv = CRM_Core_BAO_CustomValue::getContactValues($org['contact_id']);
}
foreach ($cv as $cvFieldID => $value) {
if ($cvFieldID == $cfID) {
$value = CRM_Core_BAO_CustomField::displayValue($value, $cfID);
break;
}
}
}
elseif ($token == 'checksum') {
if ($token === 'checksum') {
$cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($org['contact_id']);
$value = "cs={$cs}";
}
elseif ($token == 'address') {
elseif ($token === 'address') {
// Build the location values array

$loc = [];
Expand Down

0 comments on commit 9b7fe90

Please sign in to comment.