[REF] dev/core#2790 move preProcess static to the trait
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 31 Aug 2021 19:14:46 +0000 (07:14 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 31 Aug 2021 22:05:59 +0000 (10:05 +1200)
CRM/Case/Form/Task/PDF.php
CRM/Contact/Form/Task/PDF.php
CRM/Contact/Form/Task/PDFLetterCommon.php
CRM/Contact/Form/Task/PDFTrait.php
CRM/Contribute/Form/Task/PDFLetter.php
CRM/Event/Form/Task/PDF.php
CRM/Member/Form/Task/PDFLetter.php

index e0f43f2b913a9b5864e0fd6a5809a50565a14cfc..65954ea27294883634a9f7e584f0ebfa79ea212c 100644 (file)
@@ -37,7 +37,7 @@ class CRM_Case_Form_Task_PDF extends CRM_Case_Form_Task {
    * Build all the data structures needed to build the form.
    */
   public function preProcess() {
-    CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
+    $this->preProcessPDF();
     $this->skipOnHold = $this->skipDeceased = FALSE;
     parent::preProcess();
     $this->setContactIDs();
index 757ac4833f2b34ad10dca973f53f67acf79576ed..884819bdb4f6c811b8aba0521f3f286244f7afc1 100644 (file)
@@ -41,7 +41,7 @@ class CRM_Contact_Form_Task_PDF extends CRM_Contact_Form_Task {
   public function preProcess() {
 
     $this->skipOnHold = $this->skipDeceased = FALSE;
-    CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
+    $this->preProcessPDF();
 
     // store case id if present
     $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'CommaSeparatedIntegers', $this, FALSE);
index 44716b10478ecbbbcde65b3b47663c85847cd4f1..bb0c2dcef54cc6b5c9116a1769f1e5ac9473034e 100644 (file)
@@ -39,9 +39,12 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter
   /**
    * Build all the data structures needed to build the form.
    *
+   * @deprecated
+   *
    * @param CRM_Core_Form $form
    */
   public static function preProcess(&$form) {
+    CRM_Core_Error::deprecatedFunctionWarning('no alternative');
     $defaults = [];
     $form->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     if (is_numeric(key($form->_fromEmails))) {
index 27b7a84fec13e0d468adc11c37e8e7adacc23209..9ac741c0a1b6000975117f75d5e589c22d0cbc38 100644 (file)
@@ -183,4 +183,22 @@ trait CRM_Contact_Form_Task_PDFTrait {
     $form->addFormRule(['CRM_Core_Form_Task_PDFLetterCommon', 'formRule'], $form);
   }
 
+  /**
+   * Prepare form.
+   */
+  public function preProcessPDF(): void {
+    $form = $this;
+    $defaults = [];
+    $form->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
+    if (is_numeric(key($form->_fromEmails))) {
+      $emailID = (int) key($form->_fromEmails);
+      $defaults = CRM_Core_BAO_Email::getEmailSignatureDefaults($emailID);
+    }
+    if (!Civi::settings()->get('allow_mail_from_logged_in_contact')) {
+      $defaults['from_email_address'] = current(CRM_Core_BAO_Domain::getNameAndEmail(FALSE, TRUE));
+    }
+    $form->setDefaults($defaults);
+    $form->setTitle('Print/Merge Document');
+  }
+
 }
index 9941415900e1de62330e9f52cb7fad2ebfa0d9c9..330e1e2d59ea533faceea9804c423d47419bd8f7 100644 (file)
@@ -38,7 +38,7 @@ class CRM_Contribute_Form_Task_PDFLetter extends CRM_Contribute_Form_Task {
    */
   public function preProcess() {
     $this->skipOnHold = $this->skipDeceased = FALSE;
-    CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
+    $this->preProcessPDF();
     parent::preProcess();
     $this->assign('single', $this->isSingle());
   }
index 43341aaf12f89d6439360185ed33ff42a3f32597..9ce1baed9c71cdfb82a34ebc1a8eaa1b1231c12c 100644 (file)
@@ -46,7 +46,7 @@ class CRM_Event_Form_Task_PDF extends CRM_Event_Form_Task {
    * Build all the data structures needed to build the form.
    */
   public function preProcess() {
-    CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
+    $this->preProcessPDF();
     parent::preProcess();
 
     // we have all the participant ids, so now we get the contact ids
index fd73a19dc3c1113f55a747d03c3488daf03dbb29..92e84714730d26e3e1dba7b000d5b1a2f8b4b281 100644 (file)
@@ -43,7 +43,7 @@ class CRM_Member_Form_Task_PDFLetter extends CRM_Member_Form_Task {
     $this->skipOnHold = $this->skipDeceased = FALSE;
     parent::preProcess();
     $this->setContactIDs();
-    CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
+    $this->preProcessPDF();
   }
 
   /**