Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions CRM/SMS/Form/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,14 @@ public static function formRule($params, $files, $self) {
$str = CRM_Core_TokenSmarty::render(['text' => $str], [
'smarty' => FALSE,
'contactId' => CRM_Core_Session::getLoggedInContactID(),
'mailingId' => $mailing->id,
])['text'];
$tokens = $dummy_mail->getTokens();

$str = self::replaceSubscribeInviteTokens($str);
$str = CRM_Utils_Token::replaceMailingTokens($str, $mailing, NULL, $tokens['text']);
$str = CRM_Utils_Token::replaceActionTokens($str, $verp, $urls, NULL, $tokens['text']);

$unmatched = CRM_Utils_Token::unmatchedTokens($str);
$unmatched = self::unmatchedTokens($str);
$contentCheck = CRM_Utils_String::htmlToText($str);

if (!empty($unmatched) && 0) {
Expand Down Expand Up @@ -437,4 +437,19 @@ public function listTokens() {
return $tokens;
}

/**
* Find unprocessed tokens (call this last)
*
* @param string $str
* The string to search.
*
* @return array
* Array of tokens that weren't replaced
*/
private static function unmatchedTokens($str) {
//preg_match_all('/[^\{\\\\]\{(\w+\.\w+)\}[^\}]/', $str, $match);
preg_match_all('/\{(\w+\.\w+)\}/', $str, $match);
return $match[1];
}

}
6 changes: 5 additions & 1 deletion CRM/Utils/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static function tokenEscapeSmarty($string) {
* @return string
* The processed string
*
* @deprecated
* @deprecated will be removed around 6.30
*/
public static function &replaceMailingTokens(
$str,
Expand All @@ -172,6 +172,7 @@ public static function &replaceMailingTokens(
$knownTokens = NULL,
$escapeSmarty = FALSE
) {
CRM_Core_Error::deprecatedFunctionWarning('token processor');
$mailingContext = $mailing->id ? ['mailingId' => (int) $mailing->id] : [];
$tokenProcessor = new TokenProcessor(\Civi::dispatcher(), $mailingContext + [
'controller' => __CLASS__,
Expand Down Expand Up @@ -742,8 +743,11 @@ public static function replaceSubscribeInviteTokens($str) {
*
* @return array
* Array of tokens that weren't replaced
*
* @deprecated since 6.18 will be removed around 6.30
*/
public static function &unmatchedTokens(&$str) {
CRM_Core_Error::deprecatedFunctionWarning('no alternative');
//preg_match_all('/[^\{\\\\]\{(\w+\.\w+)\}[^\}]/', $str, $match);
preg_match_all('/\{(\w+\.\w+)\}/', $str, $match);
return $match[1];
Expand Down