From 0fe4153d86bf74a313bf912157c8ab9746a08d83 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 25 Nov 2015 18:52:03 -0500 Subject: [PATCH] CRM-17606 - Limit case token list to only relevant custom fields --- CRM/Contact/Form/Task/PDF.php | 3 ++- CRM/Core/SelectValues.php | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/Form/Task/PDF.php b/CRM/Contact/Form/Task/PDF.php index 0b9eb91afa..67a7476086 100644 --- a/CRM/Contact/Form/Task/PDF.php +++ b/CRM/Contact/Form/Task/PDF.php @@ -119,7 +119,8 @@ class CRM_Contact_Form_Task_PDF extends CRM_Contact_Form_Task { public function listTokens() { $tokens = CRM_Core_SelectValues::contactTokens(); if (isset($this->_caseId)) { - $tokens += CRM_Core_SelectValues::caseTokens(); + $caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $this->_caseId, 'case_type_id'); + $tokens += CRM_Core_SelectValues::caseTokens($caseTypeId); } return $tokens; } diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index b494d563f7..0b07c65bc1 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -693,16 +693,17 @@ class CRM_Core_SelectValues { } /** + * @param int $caseTypeId * @return array */ - public static function caseTokens() { + public static function caseTokens($caseTypeId = NULL) { static $tokens = NULL; if (!$tokens) { foreach (CRM_Case_BAO_Case::fields() as $field) { $tokens["{case.{$field['name']}}"] = $field['title']; } - $customFields = CRM_Core_BAO_CustomField::getFields('Case'); + $customFields = CRM_Core_BAO_CustomField::getFields('Case', FALSE, FALSE, $caseTypeId); foreach ($customFields as $id => $field) { $tokens["{case.custom_$id}"] = "{$field['label']} :: {$field['groupTitle']}"; } -- 2.25.1