From f93ca6db532c1ca50177cbb225d6b3c5ae407006 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 3 Dec 2022 14:56:31 +1300 Subject: [PATCH] Remove noisly deprecated function PDFLetterCommon::postProcess --- CRM/Contact/Form/Task/PDFLetterCommon.php | 89 ----------------------- 1 file changed, 89 deletions(-) diff --git a/CRM/Contact/Form/Task/PDFLetterCommon.php b/CRM/Contact/Form/Task/PDFLetterCommon.php index 6c18f1dc90..405fd7dd0f 100644 --- a/CRM/Contact/Form/Task/PDFLetterCommon.php +++ b/CRM/Contact/Form/Task/PDFLetterCommon.php @@ -109,95 +109,6 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter return [$formValues, $categories, $html_message, $messageToken, $returnProperties]; } - /** - * Process the form after the input has been submitted and validated. - * - * @param CRM_Core_Form $form - * - * @throws \CRM_Core_Exception - * - * @deprecated - */ - public static function postProcess(&$form): void { - CRM_Core_Error::deprecatedFunctionWarning('no alternative'); - $formValues = $form->controller->exportValues($form->getName()); - [$formValues, $categories, $html_message, $messageToken, $returnProperties] = self::processMessageTemplate($formValues); - $html = $activityIds = []; - - // CRM-16725 Skip creation of activities if user is previewing their PDF letter(s) - if (self::isLiveMode($form)) { - $activityIds = self::createActivities($form, $html_message, $form->_contactIds, $formValues['subject'], CRM_Utils_Array::value('campaign_id', $formValues)); - } - - if (!empty($formValues['document_file_path'])) { - [$html_message, $zip] = CRM_Utils_PDF_Document::unzipDoc($formValues['document_file_path'], $formValues['document_type']); - } - - foreach ($form->_contactIds as $item => $contactId) { - $caseId = $form->getVar('_caseId'); - if (empty($caseId) && !empty($form->_caseIds[$item])) { - $caseId = $form->_caseIds[$item]; - } - - $tokenHtml = CRM_Core_BAO_MessageTemplate::renderTemplate([ - 'contactId' => $contactId, - 'messageTemplate' => ['msg_html' => $html_message], - 'tokenContext' => $caseId ? ['caseId' => $caseId] : [], - 'disableSmarty' => (!defined('CIVICRM_MAIL_SMARTY') || !CIVICRM_MAIL_SMARTY), - ])['html']; - - $html[] = $tokenHtml; - } - - $tee = NULL; - if (self::isLiveMode($form) && Civi::settings()->get('recordGeneratedLetters') === 'combined-attached') { - if (count($activityIds) !== 1) { - throw new CRM_Core_Exception("When recordGeneratedLetters=combined-attached, there should only be one activity."); - } - $tee = CRM_Utils_ConsoleTee::create()->start(); - } - - $type = $formValues['document_type']; - $mimeType = self::getMimeType($type); - // ^^ Useful side-effect: consistently throws error for unrecognized types. - - $fileName = method_exists($form, 'getFileName') ? ($form->getFileName() . '.' . $type) : 'CiviLetter.' . $type; - - if ($type === 'pdf') { - CRM_Utils_PDF_Utils::html2pdf($html, $fileName, FALSE, $formValues); - } - elseif (!empty($formValues['document_file_path'])) { - $fileName = pathinfo($formValues['document_file_path'], PATHINFO_FILENAME) . '.' . $type; - CRM_Utils_PDF_Document::printDocuments($html, $fileName, $type, $zip); - } - else { - CRM_Utils_PDF_Document::html2doc($html, $fileName, $formValues); - } - - if ($tee) { - $tee->stop(); - $content = file_get_contents($tee->getFileName(), NULL, NULL, NULL, 5); - if (empty($content)) { - throw new \CRM_Core_Exception("Failed to capture document content (type=$type)!"); - } - foreach ($activityIds as $activityId) { - civicrm_api3('Attachment', 'create', [ - 'entity_table' => 'civicrm_activity', - 'entity_id' => $activityId, - 'name' => $fileName, - 'mime_type' => $mimeType, - 'options' => [ - 'move-file' => $tee->getFileName(), - ], - ]); - } - } - - $form->postProcessHook(); - - CRM_Utils_System::civiExit(); - } - /** * @param CRM_Core_Form $form * @param string $html_message -- 2.25.1