From 2c97ee4d38014d3749597eb4671577b591f267ef Mon Sep 17 00:00:00 2001 From: Herb v/d Dool Date: Wed, 15 Feb 2023 12:46:41 -0500 Subject: [PATCH] dev/core#4127 move mailing workflow check to userSystem --- CRM/Mailing/Info.php | 16 +--------------- CRM/Utils/System/Base.php | 9 +++++++++ CRM/Utils/System/Drupal8.php | 13 +++++++++++++ CRM/Utils/System/DrupalBase.php | 13 +++++++++++++ 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/CRM/Mailing/Info.php b/CRM/Mailing/Info.php index e30a0dee84..bffbd7ca79 100644 --- a/CRM/Mailing/Info.php +++ b/CRM/Mailing/Info.php @@ -159,21 +159,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { */ public static function workflowEnabled() { $config = CRM_Core_Config::singleton(); - - // early exit, since not true for most - if (!$config->userSystem->is_drupal || - !function_exists('module_exists') - ) { - return FALSE; - } - - if (!module_exists('rules')) { - return FALSE; - } - - $enableWorkflow = Civi::settings()->get('civimail_workflow'); - - return $enableWorkflow && $config->userSystem->is_drupal; + return $config->userSystem->mailingWorkflowIsEnabled(); } /** diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 3a69bc69e6..8ca38079aa 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -1152,4 +1152,13 @@ abstract class CRM_Utils_System_Base { return $_SERVER['REMOTE_ADDR'] ?? NULL; } + /** + * Check if mailing workflow is enabled + * + * @return bool + */ + public function mailingWorkflowIsEnabled():bool { + return FALSE; + } + } diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index c4d06a5a2c..5d26a2533c 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -932,4 +932,17 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { return class_exists('Drupal') ? \Drupal::request()->getClientIp() : ($_SERVER['REMOTE_ADDR'] ?? NULL); } + /** + * @inheritdoc + */ + public function mailingWorkflowIsEnabled():bool { + if (!\Drupal::moduleHandler()->moduleExists('rules')) { + return FALSE; + } + + $enableWorkflow = Civi::settings()->get('civimail_workflow'); + + return (bool) $enableWorkflow; + } + } diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index e65c03d200..6b1b466478 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -763,4 +763,17 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { return $emailName; } + /** + * @inheritdoc + */ + public function mailingWorkflowIsEnabled():bool { + if (!module_exists('rules')) { + return FALSE; + } + + $enableWorkflow = Civi::settings()->get('civimail_workflow'); + + return (bool) $enableWorkflow; + } + } -- 2.25.1