<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
+ | Copyright CiviCRM LLC. All rights reserved. |
| |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
*/
/**
* Class to abstract token replacement.
*/
class CRM_Utils_Token {
- static $_requiredTokens = NULL;
+ public static $_requiredTokens = NULL;
- static $_tokens = [
+ public static $_tokens = [
'action' => [
'forward',
'optOut',
'welcome' => ['group'],
];
-
/**
* @deprecated
* This is used by CiviMail but will be made redundant by FlexMailer.
* 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) {
* 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
*
// 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"];
}
* contactDetails with hooks swapped out
*/
public static function getAnonymousTokenDetails($contactIDs = [
- 0,
- ],
+ 0,
+ ],
$returnProperties = NULL,
$skipOnHold = TRUE,
$skipDeceased = TRUE,
*
* @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
$flattenTokens = [];
foreach ([
- 'html',
- 'text',
- 'subject',
- ] as $prop) {
+ 'html',
+ 'text',
+ 'subject',
+ ] as $prop) {
if (!isset($tokens[$prop])) {
continue;
}
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();
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) {
* @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) {