diff --git a/CRM/Mailingtools/Form/Settings.php b/CRM/Mailingtools/Form/Settings.php index 0472d61..5210129 100644 --- a/CRM/Mailingtools/Form/Settings.php +++ b/CRM/Mailingtools/Form/Settings.php @@ -123,6 +123,14 @@ public function buildQuickForm() { FALSE ); + // Token Tools + $this->add( + 'checkbox', + 'fix_hash_token', + E::ts('Fix {contact.hash} Token') + ); + + // load contacts $this->renderContact($current_values, 'link'); @@ -187,6 +195,7 @@ protected function getSettingsInForm() { 'anonymous_link_url', 'anonymous_link_permission', 'anonymous_link_contact_id', + 'fix_hash_token', ); } diff --git a/mailingtools.php b/mailingtools.php index cb9605f..8c43eee 100644 --- a/mailingtools.php +++ b/mailingtools.php @@ -177,14 +177,19 @@ function mailingtools_civicrm_alterAPIPermissions($entity, $action, &$params, &$ * - make sure that hash is there */ function mailingtools_civicrm_tokenValues(&$values, $cids, $job = null, $tokens = array(), $context = null) { - // make sure 'hash' is there: - if (!empty($tokens['contact'])) { - if (in_array('hash', $tokens['contact']) || !empty($tokens['contact']['hash'])) { - // hash token is requested - foreach ($values as $contact_id => &$contact_values) { - if (empty($contact_values['hash'])) { - CRM_Contact_BAO_Contact_Utils::generateChecksum($contact_id); - $contact_values['hash'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contact_id, 'hash'); + $config = CRM_Mailingtools_Config::singleton(); + + $fix_hash_token = $config->getSetting('fix_hash_token'); + if ($fix_hash_token) { + // make sure 'hash' is there: + if (!empty($tokens['contact'])) { + if (in_array('hash', $tokens['contact']) || !empty($tokens['contact']['hash'])) { + // hash token is requested + foreach ($values as $contact_id => &$contact_values) { + if (empty($contact_values['hash'])) { + CRM_Contact_BAO_Contact_Utils::generateChecksum($contact_id); + $contact_values['hash'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contact_id, 'hash'); + } } } } diff --git a/templates/CRM/Mailingtools/Form/Settings.hlp b/templates/CRM/Mailingtools/Form/Settings.hlp index bca8b2c..266fcdf 100644 --- a/templates/CRM/Mailingtools/Form/Settings.hlp +++ b/templates/CRM/Mailingtools/Form/Settings.hlp @@ -66,3 +66,7 @@
{ts domain="de.systopia.mailingtools"}You can define a contact ID to be used as a the anonymous contact.{/ts}
{ts domain="de.systopia.mailingtools"}If you don't do that, the contact with the smallest ID will be used in any tracked click events.{/ts}
{/htxt} + +{htxt id="id-mailtools-fix-hash-token"} +{ts domain="de.systopia.mailingtools"}If you have problems filling the {literal}{contact.hash}{/literal} token with Mosaico/Flexmailer, you may try activating this option.{/ts}
+{/htxt} diff --git a/templates/CRM/Mailingtools/Form/Settings.tpl b/templates/CRM/Mailingtools/Form/Settings.tpl index bb0b584..0bf574b 100644 --- a/templates/CRM/Mailingtools/Form/Settings.tpl +++ b/templates/CRM/Mailingtools/Form/Settings.tpl @@ -12,9 +12,9 @@ | written permission from the original author(s). | +-------------------------------------------------------*} -{ts domain='de.systopia.mailingtools'}Retention Time is interpreted as days. If no value is configured, no mails will be deleted.{/ts}
{ts domain='de.systopia.mailingtools'}Add additional Bounce pattern to the Database. Checks first if pattern is already available. Outputs the number of pattern added/ignored from the specified file.{/ts}