Commit db085098 authored by jaapjansma's avatar jaapjansma
Browse files

Made case token output compatible with send email from case and export document from case

parent b9df5df3
......@@ -11,9 +11,9 @@ use CRM_DataprocessorTokenOutput_ExtensionUtil as E;
class CaseToken extends AbstractToken {
/**
* Array containing all the related participant ids
* Array containing all the related case ids
*
* This property is set when executed from an participant search action.
* This property is set when executed from a case action.
*
* @var array
*/
......@@ -36,6 +36,10 @@ class CaseToken extends AbstractToken {
} elseif (isset($values['extra_data']['case']['id'])) {
// Coming from CiviRules
return $values['extra_data']['case']['id'];
} elseif (is_array(self::$_caseIds) && count(self::$_caseIds)) {
return array_shift(self::$_caseIds);
} elseif (self::$_caseIds) {
return self::$_caseIds;
}
return false;
}
......@@ -56,5 +60,22 @@ class CaseToken extends AbstractToken {
return 'case_id_field';
}
/**
* Extract the event ids from the event task forms.
* We need this as soon as the task is a send letter or send e-mail from the action
* after a search for participants.
*
* We can then use those event ids during the processing of the tokens.
*
* @param $form
*/
public static function extractCaseIdsFromManageCaseForms(\CRM_Core_Form $form) {
if ($form instanceof \CRM_Contact_Form_Task_Email) {
self::$_caseIds = $form->getVar('_caseId');
} elseif ($form instanceof \CRM_Contact_Form_Task_PDF) {
self::$_caseIds = $form->getVar('_caseId');
}
}
}
......@@ -118,6 +118,7 @@ function dataprocessor_token_output_get_token_factory() {
function dataprocessor_token_output_civicrm_buildForm($formName, &$form) {
\Civi\DataProcessorTokenOutput\Output\EventToken::extractParticipantIdsFromEventFormTasks($form);
\Civi\DataProcessorTokenOutput\Output\ParticipantToken::extractParticipantIdsFromEventFormTasks($form);
\Civi\DataProcessorTokenOutput\Output\CaseToken::extractCaseIdsFromManageCaseForms($form);
}
......
......@@ -13,8 +13,8 @@
<url desc="Documentation">https://lab.civicrm.org/extensions/dataprocessor-token-output/blob/master/README.md</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-10-08</releaseDate>
<version>1.8</version>
<releaseDate>2021-11-24</releaseDate>
<version>1.9</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.13</ver>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment