-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept Mosaico-style unsubscribe URLs (veda-consulting-company#143)
Before ------ As observed in veda-consulting-company#143, the default `versafix-1` templates use tokens like `[unsubscribe_link]` which do not match `{action.unsubscribeUrl}`. Thus, when you try to submit the mailing, it fails because the token is missing. After ----- The `[unsubscribe_link]` is treated as an alias for `{action.unsubscribeUrl}`. Thus, when you try to submit the mailing, it accepts that token. Comment ------- There's another required token, `{domain.address}`. For the moment, the patch waives that requirement because Mosaico UX handles that differently. See comments inlined.
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
use Civi\FlexMailer\Listener\RequiredTokens; | ||
|
||
use CRM_Mosaico_ExtensionUtil as E; | ||
|
||
/** | ||
* Class CRM_Mosaico_MosaicoRequiredTokens | ||
* | ||
* The token format for Mosaico extends the traditional format -- all | ||
* traditional tokens (eg "{action.unsubscribeUrl}") are supported, and | ||
* a few additional aliases (eg "[unsubscribe_link]") are also | ||
* supported. | ||
* | ||
* When validating required tokens, we should accept the aliases. | ||
*/ | ||
class CRM_Mosaico_MosaicoRequiredTokens extends RequiredTokens { | ||
|
||
public function __construct() { | ||
parent::__construct(array('mosaico'), array()); | ||
} | ||
|
||
public function getRequiredTokens() { | ||
return Civi::service('civi_flexmailer_required_tokens') | ||
->getRequiredTokens(); | ||
} | ||
|
||
public function findMissingTokens($str) { | ||
$content = array('body_unspecified' => $str); | ||
_mosaico_civicrm_alterMailContent($content); | ||
return parent::findMissingTokens($content['body_unspecified']); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters