From 360ebaacd0888969c3fc18ec9510f95f79cb7347 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 1 Jan 2021 09:53:39 +1300 Subject: [PATCH] [REF] Move another deprecated function back to the only class that calls it --- CRM/Utils/DeprecatedUtils.php | 46 ----------------------------- CRM/Utils/Mail/EmailProcessor.php | 49 +++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/CRM/Utils/DeprecatedUtils.php b/CRM/Utils/DeprecatedUtils.php index d0a4e1512b..d0103127ad 100644 --- a/CRM/Utils/DeprecatedUtils.php +++ b/CRM/Utils/DeprecatedUtils.php @@ -468,49 +468,3 @@ function _civicrm_api3_deprecated_participant_check_params($params, $checkDuplic } return TRUE; } - -/** - * @param $result - * @param int $activityTypeID - * - * @return array - * $params - */ -function _civicrm_api3_deprecated_activity_buildmailparams($result, $activityTypeID) { - // get ready for collecting data about activity to be created - $params = []; - - $params['activity_type_id'] = $activityTypeID; - - $params['status_id'] = 'Completed'; - if (!empty($result['from']['id'])) { - $params['source_contact_id'] = $params['assignee_contact_id'] = $result['from']['id']; - } - $params['target_contact_id'] = []; - $keys = ['to', 'cc', 'bcc']; - foreach ($keys as $key) { - if (is_array($result[$key])) { - foreach ($result[$key] as $key => $keyValue) { - if (!empty($keyValue['id'])) { - $params['target_contact_id'][] = $keyValue['id']; - } - } - } - } - $params['subject'] = $result['subject']; - $params['activity_date_time'] = $result['date']; - $params['details'] = $result['body']; - - $numAttachments = Civi::settings()->get('max_attachments_backend') ?? CRM_Core_BAO_File::DEFAULT_MAX_ATTACHMENTS_BACKEND; - for ($i = 1; $i <= $numAttachments; $i++) { - if (isset($result["attachFile_$i"])) { - $params["attachFile_$i"] = $result["attachFile_$i"]; - } - else { - // No point looping 100 times if there's only one attachment - break; - } - } - - return $params; -} diff --git a/CRM/Utils/Mail/EmailProcessor.php b/CRM/Utils/Mail/EmailProcessor.php index fe24b02e02..43fc9145c3 100644 --- a/CRM/Utils/Mail/EmailProcessor.php +++ b/CRM/Utils/Mail/EmailProcessor.php @@ -244,8 +244,7 @@ class CRM_Utils_Mail_EmailProcessor { continue; } - require_once 'CRM/Utils/DeprecatedUtils.php'; - $params = _civicrm_api3_deprecated_activity_buildmailparams($mailParams, $emailActivityTypeId); + $params = self::deprecated_activity_buildmailparams($mailParams, $emailActivityTypeId); $params['version'] = 3; if (!empty($dao->activity_status)) { @@ -535,4 +534,50 @@ class CRM_Utils_Mail_EmailProcessor { return $text; } + /** + * @param array $result + * @param int $activityTypeID + * + * @return array + * $params + */ + protected static function deprecated_activity_buildmailparams($result, $activityTypeID) { + // get ready for collecting data about activity to be created + $params = []; + + $params['activity_type_id'] = $activityTypeID; + + $params['status_id'] = 'Completed'; + if (!empty($result['from']['id'])) { + $params['source_contact_id'] = $params['assignee_contact_id'] = $result['from']['id']; + } + $params['target_contact_id'] = []; + $keys = ['to', 'cc', 'bcc']; + foreach ($keys as $key) { + if (is_array($result[$key])) { + foreach ($result[$key] as $key => $keyValue) { + if (!empty($keyValue['id'])) { + $params['target_contact_id'][] = $keyValue['id']; + } + } + } + } + $params['subject'] = $result['subject']; + $params['activity_date_time'] = $result['date']; + $params['details'] = $result['body']; + + $numAttachments = Civi::settings()->get('max_attachments_backend') ?? CRM_Core_BAO_File::DEFAULT_MAX_ATTACHMENTS_BACKEND; + for ($i = 1; $i <= $numAttachments; $i++) { + if (isset($result["attachFile_$i"])) { + $params["attachFile_$i"] = $result["attachFile_$i"]; + } + else { + // No point looping 100 times if there's only one attachment + break; + } + } + + return $params; + } + } -- 2.25.1