Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#48 Fix PDF Letter only generates a single letter when multiple contact IDs are specified #11985

Merged
merged 2 commits into from
Apr 17, 2018

Conversation

monishdeb
Copy link
Member

Overview

Ref https://lab.civicrm.org/dev/core/issues/48
When multiple contact IDs are specified via print/merge task the PDFLetterCommon code overwrites them with a single contact ID of the logged in user. This means that only a single PDF letter is printed/generated.
This PR only uses the logged in contact ID if not contact IDs have been specified.

Before

Only a single PDF letter was being generated by print/merge document.

After

Multiple PDF letters are generated by print/merge document.

Comments

It is possible that this issue was introduced by changes in #11411 which introduced a CRM_Core_Form_Task class but looking at the code and the proposed changes here I'm not sure how Print/Merge ever printed multiple documents as the code I'm changing here hasn't changed for more than 5 years!

@monishdeb
Copy link
Member Author

@mattwire @eileenmcnaughton here's the additional change:

  1. Although this is a hack from old days, but still left a TODO comment to indicate what needs to be done to remove that hack - https://github.com/civicrm/civicrm-core/pull/11985/files#diff-5224650ca4795126c06ff6c16ad0b7afR75

  2. Lets maintain the same order like in other 6 tasks i.e.

public function preProcess() {
+    CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
     $this->skipOnHold = $this->skipDeceased = FALSE;
     parent::preProcess();
     $this->setContactIDs();
-    CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
   }

@eileenmcnaughton
Copy link
Contributor

@monishdeb on checking there is quite a bit of order-variance on the other classes - this seems like the one you are emulating

  /**
   * Build all the data structures needed to build the form.
   */
  public function preProcess() {
    CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
    parent::preProcess();

    // we have all the participant ids, so now we get the contact ids
    parent::setContactIDs();

    $this->assign('single', $this->_single);
  }

I can't see anything in the parent::preProcess that will be hurt by moving it right up there before it.

Merging

@monishdeb
Copy link
Member Author

Yes checked these classes and they obey that pattern except the Case

CRM/Activity/Form/Task/Email.php:60:    CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
CRM/Contact/Form/Task/Email.php:129:    CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
CRM/Contact/Form/Task/PDFLetterCommon.php:61:    CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($form);
CRM/Contribute/Form/Task/Email.php:60:    CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
CRM/Contribute/Form/Task/Invoice.php:132:    CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
CRM/Event/Form/Task/Email.php:68:    CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
CRM/Member/Form/Task/Email.php:71:    CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);

@eileenmcnaughton
Copy link
Contributor

unrelated fail

@eileenmcnaughton eileenmcnaughton merged commit f34fb1a into civicrm:master Apr 17, 2018
// @TODO remove these line and to it somewhere more appropriate. Currently some classes (e.g Case
// are having to re-write contactIds afterwards due to this inappropriate variable setting
// If we don't have any contact IDs, use the logged in contact ID
$form->_contactIds = $form->_contactIds ?: [CRM_Core_Session::getLoggedInContactID()];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice Elvis
image

@monishdeb monishdeb deleted the devcore48 branch April 18, 2018 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants