CRM-21255 - PDFLetterCommon - Detect buttons in new popup style
authorTim Otten <totten@civicrm.org>
Tue, 24 Oct 2017 01:11:36 +0000 (18:11 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 24 Oct 2017 01:37:24 +0000 (18:37 -0700)
commit592172f75f1a69b4c8bf50fede9d3f7137072ae7
treeafb4c80f5356d1e9ac45d6e35344eddafb73ab34
parent4359e03cb7fb3f6e21a34944b95a8c7698afb5ba
CRM-21255 - PDFLetterCommon - Detect buttons in new popup style

Overview
--------------

Suppose you enable the extension `org.civicrm.civicase`, set the option
`recordGeneratedLetters=combined-attached`, and create a PDF based on the
instructions in [CRM-21255](https://issues.civicrm.org/jira/browse/CRM-21255).

The PDF generator tries to determine whether the clicked the button labeled
"Preview" or "Download Document". This works correctly with the CiviCase 4 popup
mechanism, but in the CiviCase 5 popup mechanism it doesn't work.

Before
--------------

When you click the "Download Document" button, the operates in a
quasi-preview mode and fails to create any activities. This eventually
leads to a crash because the expected activities are missing.

After
--------------

The controller uses a more accurate check which correctly differentiates
"Preview" and "Download Document" on both CiviCase 4+5.

Comments
--------------

I'm not a huge fan of this patch, but it helps demonstrate the
problem+solution.  @colemanw, perhaps there's a better way to make
the buttons function consistently in CiviCase 4+5?
CRM/Contact/Form/Task/PDFLetterCommon.php