X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FToken.php;h=dd81e288723afc3513440e0d6b94c18edf0920a2;hb=e0c4f234b9eab061bade28bd91a39f8912f9e2be;hp=605405c5240c15c351dfd81ed0a9fb2308403003;hpb=9c7ec7086d8984dcc3dc11f643bfa0f4b3c6eeda;p=civicrm-core.git diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 605405c524..dd81e28872 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -161,10 +161,12 @@ class CRM_Utils_Token { /** * Wrapper for token replacing * - * @param string $type The token type - * @param string $var The token variable - * @param string $value The value to substitute for the token - * @param string (reference) $str The string to replace in + * @param string $type The token type + * @param string $var The token variable + * @param string $value The value to substitute for the token + * @param string (reference) $str The string to replace in + * + * @param bool $escapeSmarty * * @return string The processed string * @access public @@ -185,7 +187,9 @@ class CRM_Utils_Token { /** * get< the regex for token replacement * - * @param string $key a string indicating the the type of token to be used in the expression + * @param $token_type + * + * @internal param string $key a string indicating the the type of token to be used in the expression * * @return string regular expression sutiable for using in preg_replace * @access private @@ -209,13 +213,15 @@ class CRM_Utils_Token { return preg_replace(array('/{/', '/(? $contactId); + $greetingDetails = self::getTokenDetails($contactParams, + $greetingsReturnProperties, + FALSE, FALSE, NULL, + $greetingTokens, + $className + ); + // Prepare variables for calling replaceHookTokens + $categories = array_keys($greetingTokens); + list($contact) = $greetingDetails; + // Replace tokens defined in Hooks. + $tokenString = CRM_Utils_Token::replaceHookTokens($tokenString, $contact[$contactId], $categories); + } } } + /** + * @param $tokens + * + * @return array + */ static function flattenTokens(&$tokens) { $flattenTokens = array(); @@ -1322,7 +1424,10 @@ class CRM_Utils_Token { /** * Replace all user tokens in $str * - * @param string $str The string with tokens to be replaced + * @param string $str The string with tokens to be replaced + * + * @param null $knownTokens + * @param bool $escapeSmarty * * @return string The processed string * @access public @@ -1346,6 +1451,12 @@ class CRM_Utils_Token { return $str; } + /** + * @param $token + * @param bool $escapeSmarty + * + * @return string + */ public static function getUserTokenReplacement($token, $escapeSmarty = FALSE) { $value = ''; @@ -1368,7 +1479,9 @@ class CRM_Utils_Token { return $value; } - + /** + * + */ protected static function _buildContributionTokens() { $key = 'contribution'; if (self::$_tokens[$key] == NULL) { @@ -1419,11 +1532,13 @@ class CRM_Utils_Token { /** * Replace Contribution tokens in html - * @param unknown $str - * @param unknown $contribution - * @param string $html + * + * @param string $str + * @param array $contribution + * @param bool|string $html * @param string $knownTokens - * @param string $escapeSmarty + * @param bool|string $escapeSmarty + * * @return unknown|Ambigous |mixed */ public static function replaceContributionTokens($str, &$contribution, $html = FALSE, $knownTokens = NULL, $escapeSmarty = FALSE) { @@ -1463,9 +1578,11 @@ class CRM_Utils_Token { * @param string $separator * @param string $str * @param array $contribution - * @param string $html + * @param bool|string $html * @param string $knownTokens - * @param string $escapeSmarty + * @param bool|string $escapeSmarty + * + * @return \Ambigous|mixed|string|\unknown */ public static function replaceMultipleContributionTokens($separator, $str, &$contribution, $html = FALSE, $knownTokens = NULL, $escapeSmarty = FALSE) { if(empty($knownTokens['contribution'])) { @@ -1530,6 +1647,14 @@ class CRM_Utils_Token { return $value; } + /** + * @param $token + * @param $contribution + * @param bool $html + * @param bool $escapeSmarty + * + * @return mixed|string + */ public static function getContributionTokenReplacement($token, &$contribution, $html = FALSE, $escapeSmarty = FALSE) { self::_buildContributionTokens(); @@ -1563,10 +1688,6 @@ class CRM_Utils_Token { return $value; } - function getPermissionEmails($permissionName) {} - - function getRoleEmails($roleName) {} - /** * @return array: legacy_token => new_token */ @@ -1601,7 +1722,12 @@ class CRM_Utils_Token { // Group by entity else { $split = explode('.', trim($k, '{}')); - $entity = isset($split[1]) ? ucfirst($split[0]) : 'Contact'; + if (isset($split[1])) { + $entity = array_key_exists($split[1], CRM_Core_DAO_Address::export()) ? 'Address' : ucfirst($split[0]); + } + else { + $entity = 'Contact'; + } $sorted[ts($entity)][] = array('id' => $k, 'text' => $v); } } @@ -1613,5 +1739,4 @@ class CRM_Utils_Token { return $output; } - }