From 0e74a808d9005459dbb223888760f2f871a60e63 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Mon, 2 Dec 2019 20:33:38 -0500 Subject: [PATCH] remove unused function --- CRM/Case/BAO/Case.php | 87 ------------------------------------------- 1 file changed, 87 deletions(-) diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 00dbc265ed..76f74d496d 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1382,93 +1382,6 @@ HERESQL; return FALSE; } - /** - * Create an activity for a case via email. - * - * @param int $file - * Email sent. - * - * @return array|void - * $activity object of newly creted activity via email - */ - public static function recordActivityViaEmail($file) { - if (!file_exists($file) || - !is_readable($file) - ) { - return CRM_Core_Error::fatal(ts('File %1 does not exist or is not readable', - [1 => $file] - )); - } - - $result = CRM_Utils_Mail_Incoming::parse($file); - if ($result['is_error']) { - return $result; - } - - foreach ($result['to'] as $to) { - $caseId = NULL; - - $emailPattern = '/^([A-Z0-9._%+-]+)\+([\d]+)@[A-Z0-9.-]+\.[A-Z]{2,4}$/i'; - $replacement = preg_replace($emailPattern, '$2', $to['email']); - - if ($replacement !== $to['email']) { - $caseId = $replacement; - //if caseId is invalid, return as error file - if (!CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseId, 'id')) { - return CRM_Core_Error::createAPIError(ts('Invalid case ID ( %1 ) in TO: field.', - [1 => $caseId] - )); - } - } - else { - continue; - } - - // TODO: May want to replace this with a call to getRelatedAndGlobalContacts() when this feature is revisited. - // (Or for efficiency call the global one outside the loop and then union with this each time.) - $contactDetails = self::getRelatedContacts($caseId, FALSE); - - if (!empty($contactDetails[$result['from']['id']])) { - $params = []; - $params['subject'] = $result['subject']; - $params['activity_date_time'] = $result['date']; - $params['details'] = $result['body']; - $params['source_contact_id'] = $result['from']['id']; - $params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'); - - $details = CRM_Case_PseudoConstant::caseActivityType(); - $matches = []; - preg_match('/^\W+([a-zA-Z0-9_ ]+)(\W+)?\n/i', - $result['body'], $matches - ); - - if (!empty($matches) && isset($matches[1])) { - $activityType = trim($matches[1]); - if (isset($details[$activityType])) { - $params['activity_type_id'] = $details[$activityType]['id']; - } - } - if (!isset($params['activity_type_id'])) { - $params['activity_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Inbound Email'); - } - - // create activity - $activity = CRM_Activity_BAO_Activity::create($params); - - $caseParams = [ - 'activity_id' => $activity->id, - 'case_id' => $caseId, - ]; - self::processCaseActivity($caseParams); - } - else { - return CRM_Core_Error::createAPIError(ts('FROM email contact %1 doesn\'t have a relationship to the referenced case.', - [1 => $result['from']['email']] - )); - } - } - } - /** * Retrieve the scheduled activity type and date. * -- 2.25.1