[REF] Move another deprecated function back to the only class that calls it
authoreileen <emcnaughton@wikimedia.org>
Thu, 31 Dec 2020 20:53:39 +0000 (09:53 +1300)
committereileen <emcnaughton@wikimedia.org>
Sun, 3 Jan 2021 00:25:11 +0000 (13:25 +1300)
CRM/Utils/DeprecatedUtils.php
CRM/Utils/Mail/EmailProcessor.php

index d0a4e1512b8e769b2a7d4da5d8cb5386d9b13790..d0103127adb467f99e8cf3fde70037e3a10031af 100644 (file)
@@ -468,49 +468,3 @@ function _civicrm_api3_deprecated_participant_check_params($params, $checkDuplic
   }
   return TRUE;
 }
-
-/**
- * @param $result
- * @param int $activityTypeID
- *
- * @return array
- *   <type> $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;
-}
index fe24b02e02721bb1989e7b1f907d46794bc0a177..43fc9145c3519e97bf7a2b79b8ba8e29b9ae8d12 100644 (file)
@@ -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
+   *   <type> $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;
+  }
+
 }