From 9babb59899650008492ee18b1e6b8f5d232d2e6a Mon Sep 17 00:00:00 2001 From: Olaf Buddenhagen Date: Sat, 24 Aug 2013 05:38:27 +0200 Subject: [PATCH] Add config setting to disable mandatory tokens check in mailings As per a previous discussion (with Lobo IIRC), add a configuration setting to disable the check for presence of mandatory tokens when sending mailings. This setting is implemented as a negative option, i.e. ticking the option disables the check. We could also reverse the logic, so that ticking the option enables the check instead; and set it to on by default... Not sure which is preferable -- I guess that's mostly a matter of taste. --- CRM/Admin/Form/Preferences/Mailing.php | 7 +++++++ CRM/Mailing/Form/Upload.php | 14 ++++++++------ settings/Mailing.setting.php | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Mailing.php b/CRM/Admin/Form/Preferences/Mailing.php index 484f955e05..16ca93f8e2 100644 --- a/CRM/Admin/Form/Preferences/Mailing.php +++ b/CRM/Admin/Form/Preferences/Mailing.php @@ -99,6 +99,13 @@ class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences { 'weight' => 8, 'description' => NULL, ), + 'disable_mandatory_tokens_check' => + array( + 'html_type' => 'checkbox', + 'title' => ts('Disable check for mandatory tokens'), + 'weight' => 9, + 'description' => ts('Don\'t check for presence of mandatory tokens (domain address; unsubscribe/opt-out) before sending mailings. WARNING: Mandatory tokens are a safe-guard which facilitate compliance with the US CAN-SPAM Act. They should only be disabled if your organization adopts other mechanisms for compliance or if your organization is not subject to CAN-SPAM.'), + ), ), ); diff --git a/CRM/Mailing/Form/Upload.php b/CRM/Mailing/Form/Upload.php index af4b39a4db..dd1bafe9d0 100644 --- a/CRM/Mailing/Form/Upload.php +++ b/CRM/Mailing/Form/Upload.php @@ -613,12 +613,14 @@ class CRM_Mailing_Form_Upload extends CRM_Core_Form { /* First look for missing tokens */ - $err = CRM_Utils_Token::requiredTokens($str); - if ($err !== TRUE) { - foreach ($err as $token => $desc) { - $dataErrors[] = '
  • ' . ts('This message is missing a required token - {%1}: %2', - array(1 => $token, 2 => $desc) - ) . '
  • '; + if (!CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'disable_mandatory_tokens_check')) { + $err = CRM_Utils_Token::requiredTokens($str); + if ($err !== TRUE) { + foreach ($err as $token => $desc) { + $dataErrors[] = '
  • ' . ts('This message is missing a required token - {%1}: %2', + array(1 => $token, 2 => $desc) + ) . '
  • '; + } } } diff --git a/settings/Mailing.setting.php b/settings/Mailing.setting.php index b2e112ed95..31b6c02d60 100644 --- a/settings/Mailing.setting.php +++ b/settings/Mailing.setting.php @@ -136,4 +136,18 @@ return array( 'description' => 'When CiviMail is enabled, users who "subscribe" to a group from a profile Group(s) checkbox will receive a confirmation email. They must respond (opt-in) before they are added to the group.', 'help_text' => null, ), + 'disable_mandatory_tokens_check' => array( + 'group_name' => 'Mailing Preferences', + 'group' => 'mailing', + 'name' => 'disable_mandatory_tokens_check', + 'type' => 'Integer', + 'html_type' => 'checkbox', + 'default' => 0, + 'add' => '4.4', + 'title' => 'Disable check for mandatory tokens', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => 'Don\'t check for presence of mandatory tokens (domain address; unsubscribe/opt-out) before sending mailings. WARNING: Mandatory tokens are a safe-guard which facilitate compliance with the US CAN-SPAM Act. They should only be disabled if your organization adopts other mechanisms for compliance or if your organization is not subject to CAN-SPAM.', + 'help_text' => null, + ), ); -- 2.25.1