(dev/core#616) Fix Print/merge document for memberships: Preview creating activities; standardise preview code for contacts, cases, contributions & memberships #13369
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
See https://lab.civicrm.org/dev/core/issues/616. Print/merge document for memberships should not creates activities when the Preview button is clicked. This PR resolves that, making the behaviour for Memberships consistent with that of Contacts.
Before
Activities will be created after clicking Preview:
After
Activities will not be created after clicking Preview.
Technical Details
When CRM-16725 / PR #6888 added the Preview button, it did not implement any code in
CRM_Member_Form_Task_PDFLetterCommon
to make Preview work for Membership search tasks, only Contacts.The few lines of code that this PR adds were taken fromCRM_Contact_Form_Task_PDFLetterCommon::postProcess()
(almost verbatim except for the button name).To help standardise the behaviour, the logic associated with
$isLiveMode
inCRM_Contact_Form_Task_PDFLetterCommon::postProcess()
is moved into a new functionCRM_Contact_Form_Task_PDFLetterCommon::isLiveMode()
. It is called from CRM_Contact_Form_Task_PDFLetterCommon::createActivities()`, which was already common to the PDF letter forms for memberships, contacts, contributions and cases.Comments
There is duplication between the contact and membership PDF letter code but it didn't seem straightforward to remove it due to the code for each being based on contact IDs and membership IDs respectively.
@aydun has done some good work in PR #12012 for PDFs for Activities and improving the code structure. I spent a short time looking at this and suspect that it would be best to do similar for Memberships after #12012 is finalised.