Skip to content
Snippets Groups Projects
Commit a996475e authored by totten's avatar totten
Browse files

FiveSeventyNine - Show notification about changes to `{afform.*}` email tokens

parent dc9ba36a
Branches
Tags
No related merge requests found
......@@ -21,6 +21,36 @@
*/
class CRM_Upgrade_Incremental_php_FiveSeventyNine extends CRM_Upgrade_Incremental_Base {
public function setPreUpgradeMessage(&$message, $rev, $current = NULL) {
if ($rev == '5.79.alpha1') {
$tokenForms = static::findAfformsWithMsgToken();
if (!empty($tokenForms)) {
$formList = implode(', ', array_map(fn($name) => '<em>"' . htmlentities($name) . '"</em>', $tokenForms));
$message .= '<p>' . ts('Some custom forms (%1) support authenticated email links. Links will still be generated in 5.79+, but they only confer access to one page at a time. If you need a link to provide a full login-session, please install extension <a %2>%3</a>.', [
1 => $formList,
2 => 'href="https://lab.civicrm.org/extensions/afform-login-token" target="_blank"',
3 => 'Afform Login Token',
]) . '</p>';
}
}
}
public static function findAfformsWithMsgToken(): array {
if (!class_exists('CRM_Afform_AfformScanner')) {
return [];
}
$scanner = new CRM_Afform_AfformScanner(
new CRM_Utils_Cache_ArrayCache([])
);
$matches = [];
foreach ($scanner->getMetas() as $name => $meta) {
if (in_array('msg_token', $meta['placement'] ?? [])) {
$matches[] = $name;
}
}
return $matches;
}
/**
* Upgrade step; adds tasks including 'runSql'.
*
......
......@@ -29,9 +29,11 @@ class CRM_Afform_AfformScanner extends \Civi\Core\Service\AutoService {
/**
* CRM_Afform_AfformScanner constructor.
*
* @param \CRM_Utils_Cache_Interface $cache
*/
public function __construct() {
$this->cache = Civi::cache('long');
public function __construct($cache = NULL) {
$this->cache = $cache ?: Civi::cache('long');
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment