From 1e96d05345e9bf3ff0fd7fd503b98b7a4ad748fe Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 22 Nov 2017 16:14:56 -0800 Subject: [PATCH 1/6] CRM-21472 - Allow FlexMailer to overload checkSendable() --- api/v3/Mailing.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/v3/Mailing.php b/api/v3/Mailing.php index 6a7e4f3d3b3e..903cd80f7d0c 100644 --- a/api/v3/Mailing.php +++ b/api/v3/Mailing.php @@ -74,7 +74,8 @@ function civicrm_api3_mailing_create($params) { if (!$timestampCheck) { throw new API_Exception("Mailing has not been saved, Content maybe out of date, please refresh the page and try again"); } - $safeParams['_evil_bao_validator_'] = 'CRM_Mailing_BAO_Mailing::checkSendable'; + + $safeParams['_evil_bao_validator_'] = \CRM_Utils_Constant::value('CIVICRM_FLEXMAILER_HACK_SENDABLE', 'CRM_Mailing_BAO_Mailing::checkSendable'); $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $safeParams); return _civicrm_api3_mailing_get_formatResult($result); } From 84b086ad7f2d729a817f9993488805485f870ecf Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 22 Nov 2017 16:15:32 -0800 Subject: [PATCH 2/6] CRM-21472 - Allow FlexMailer to overload getRequiredTokens() --- CRM/Mailing/Info.php | 3 ++- CRM/Utils/Token.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CRM/Mailing/Info.php b/CRM/Mailing/Info.php index 50e3f07bbf5d..c7820ea91cd9 100644 --- a/CRM/Mailing/Info.php +++ b/CRM/Mailing/Info.php @@ -129,6 +129,7 @@ public function getAngularModules() { )); $enabledLanguages = CRM_Core_I18n::languages(TRUE); $isMultiLingual = (count($enabledLanguages) > 1); + $requiredTokens = defined('CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS') ? Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS, array()) : CRM_Utils_Token::getRequiredTokens(); CRM_Core_Resources::singleton() ->addSetting(array( 'crmMailing' => array( @@ -143,7 +144,7 @@ public function getAngularModules() { 'emailAdd' => $emailAdd['values'], 'mailTokens' => $mailTokens['values'], 'contactid' => $contactID, - 'requiredTokens' => CRM_Utils_Token::getRequiredTokens(), + 'requiredTokens' => $requiredTokens, 'enableReplyTo' => (int) Civi::settings()->get('replyTo'), 'disableMandatoryTokensCheck' => (int) Civi::settings()->get('disable_mandatory_tokens_check'), 'fromAddress' => $fromAddress['values'], diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 7bd729b2b0cc..e58c3b6ce74a 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -118,7 +118,7 @@ public static function getRequiredTokens() { * else an array of the missing tokens */ public static function requiredTokens(&$str) { - $requiredTokens = self::getRequiredTokens(); + $requiredTokens = defined('CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS') ? Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS, array()) : CRM_Utils_Token::getRequiredTokens(); $missing = array(); foreach ($requiredTokens as $token => $value) { From 23ddc8fdd979cb02bcf304f504121b654584b2bd Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 24 Nov 2017 17:23:48 -0800 Subject: [PATCH 3/6] CRM-21472 - Allow FlexMailer to overload checkSendable() - Comments --- api/v3/Mailing.php | 1 + 1 file changed, 1 insertion(+) diff --git a/api/v3/Mailing.php b/api/v3/Mailing.php index 903cd80f7d0c..300ac3b07c84 100644 --- a/api/v3/Mailing.php +++ b/api/v3/Mailing.php @@ -75,6 +75,7 @@ function civicrm_api3_mailing_create($params) { throw new API_Exception("Mailing has not been saved, Content maybe out of date, please refresh the page and try again"); } + // FlexMailer is a refactoring of CiviMail which provides new hooks/APIs/docs. If the sysadmin has opted to enable it, then use that instead of CiviMail. $safeParams['_evil_bao_validator_'] = \CRM_Utils_Constant::value('CIVICRM_FLEXMAILER_HACK_SENDABLE', 'CRM_Mailing_BAO_Mailing::checkSendable'); $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $safeParams); return _civicrm_api3_mailing_get_formatResult($result); From 613eb099df45f3104cddd6470ae23d68c34f6f92 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 24 Nov 2017 17:24:05 -0800 Subject: [PATCH 4/6] CRM-21472 - Allow FlexMailer to overload getRequiredTokens() - Comments --- CRM/Mailing/Info.php | 1 + CRM/Utils/Token.php | 1 + 2 files changed, 2 insertions(+) diff --git a/CRM/Mailing/Info.php b/CRM/Mailing/Info.php index c7820ea91cd9..649401093180 100644 --- a/CRM/Mailing/Info.php +++ b/CRM/Mailing/Info.php @@ -129,6 +129,7 @@ public function getAngularModules() { )); $enabledLanguages = CRM_Core_I18n::languages(TRUE); $isMultiLingual = (count($enabledLanguages) > 1); + // FlexMailer is a refactoring of CiviMail which provides new hooks/APIs/docs. If the sysadmin has opted to enable it, then use that instead of CiviMail. $requiredTokens = defined('CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS') ? Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS, array()) : CRM_Utils_Token::getRequiredTokens(); CRM_Core_Resources::singleton() ->addSetting(array( diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index e58c3b6ce74a..5b5b358c4f38 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -118,6 +118,7 @@ public static function getRequiredTokens() { * else an array of the missing tokens */ public static function requiredTokens(&$str) { + // FlexMailer is a refactoring of CiviMail which provides new hooks/APIs/docs. If the sysadmin has opted to enable it, then use that instead of CiviMail. $requiredTokens = defined('CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS') ? Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS, array()) : CRM_Utils_Token::getRequiredTokens(); $missing = array(); From b8ea011f70e5a5853f4f4a553b0b8b9f3b2c909f Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 27 Nov 2017 21:28:19 -0800 Subject: [PATCH 5/6] CRM_Mailing - Flag methods made redundant by FlexMailer --- CRM/Mailing/BAO/Mailing.php | 13 ++++++++++++- CRM/Mailing/BAO/MailingJob.php | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index fb5b8f13e02e..a7665a36a4cf 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -712,10 +712,12 @@ public function &getDataFunc($token) { } /** - * * Prepares the text and html templates * for generating the emails and returns a copy of the * prepared templates + * + * @deprecated + * This is used by CiviMail but will be made redundant by FlexMailer/TokenProcessor. */ private function getPreparedTemplates() { if (!$this->preparedTemplates) { @@ -1166,6 +1168,8 @@ public function getVerpAndUrlsAndHeaders($job_id, $event_queue_id, $hash, $email /** * Compose a message. * + * @deprecated + * This is used by CiviMail but will be made redundant by FlexMailer/TokenProcessor. * @param int $job_id * ID of the Job associated with this message. * @param int $event_queue_id @@ -1434,6 +1438,8 @@ public function compose( * * Get mailing object and replaces subscribeInvite, domain and mailing tokens. * + * @deprecated + * This is used by CiviMail but will be made redundant by FlexMailer/TokenProcessor. * @param CRM_Mailing_BAO_Mailing $mailing */ public static function tokenReplace(&$mailing) { @@ -1457,6 +1463,9 @@ public static function tokenReplace(&$mailing) { /** * Get data to resolve tokens. * + * @deprecated + * This is used by CiviMail but will be made redundant by FlexMailer/TokenProcessor. + * * @param array $token_a * @param bool $html * Whether to encode the token result for use in HTML email @@ -2672,6 +2681,8 @@ public static function delJob($id) { } /** + * @deprecated + * This is used by CiviMail but will be made redundant by FlexMailer/TokenProcessor. * @return array */ public function getReturnProperties() { diff --git a/CRM/Mailing/BAO/MailingJob.php b/CRM/Mailing/BAO/MailingJob.php index 01251872e584..9818bacd2f71 100644 --- a/CRM/Mailing/BAO/MailingJob.php +++ b/CRM/Mailing/BAO/MailingJob.php @@ -498,10 +498,13 @@ public function queue($testParams = NULL) { /** * Send the mailing. * + * @deprecated + * This is used by CiviMail but will be made redundant by FlexMailer. * @param object $mailer * A Mail object to send the messages. * * @param array $testParams + * @return bool */ public function deliver(&$mailer, $testParams = NULL) { if (\Civi::settings()->get('experimentalFlexMailerEngine')) { @@ -583,6 +586,8 @@ public function deliver(&$mailer, $testParams = NULL) { } /** + * @deprecated + * This is used by CiviMail but will be made redundant by FlexMailer. * @param array $fields * List of intended recipients. * Each recipient is an array with keys 'hash', 'contact_id', 'email', etc. From ff36928415d3d8ee2389b53c951e5d4e64fb4e13 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 27 Nov 2017 21:31:19 -0800 Subject: [PATCH 6/6] CRM-21472 - Flag methods made redundant by FlexMailer's validator --- CRM/Mailing/BAO/Mailing.php | 2 ++ CRM/Utils/Token.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index a7665a36a4cf..0bd1fa660e19 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -1817,6 +1817,8 @@ public static function create(&$params, $ids = array()) { } /** + * @deprecated + * This is used by CiviMail but will be made redundant by FlexMailer. * @param CRM_Mailing_DAO_Mailing $mailing * The mailing which may or may not be sendable. * @return array diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 5b5b358c4f38..1e71d311ec39 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -90,6 +90,8 @@ class CRM_Utils_Token { /** + * @deprecated + * This is used by CiviMail but will be made redundant by FlexMailer. * @return array */ public static function getRequiredTokens() {