From f8a24d1685cb435d9432f71621a5504d5c1b1b2b Mon Sep 17 00:00:00 2001 From: colemanw Date: Mon, 24 Jul 2023 11:22:06 -0400 Subject: [PATCH] ScheduleReminders - Update metadata for 'recipient_listing' --- CRM/Core/BAO/ActionSchedule.php | 24 +++++++++++++++--------- CRM/Core/DAO/ActionSchedule.php | 11 ++++++++++- Civi/ActionSchedule/MappingInterface.php | 15 +++++---------- xml/schema/Core/ActionSchedule.xml | 10 ++++++++++ 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 64bcf8c1cc..b8b0658ba8 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -99,6 +99,18 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule implements return self::getMapping($values['mapping_id'])::getRecipientTypes(); } + /** + * Provides pseudoconstant list for `recipient_listing` field. + * @return array|null + */ + public static function getRecipientListingOptions(string $fieldName, array $params): ?array { + $values = self::fillValues($params['values'], ['mapping_id', 'recipient']); + if (!$values['mapping_id']) { + return []; + } + return self::getMapping($values['mapping_id'])->getRecipientListing($values['recipient']); + } + /** * Provides pseudoconstant list for `entity_status` field. * @return array @@ -457,17 +469,11 @@ FROM civicrm_action_schedule cas } /** - * @param int $mappingID - * @param $recipientType - * - * @return array + * @deprecated */ public static function getRecipientListing($mappingID, $recipientType) { - $mapping = CRM_Core_BAO_ActionSchedule::getMapping($mappingID); - if (!$mapping) { - return []; - } - return $mapping->getRecipientListing($recipientType); + CRM_Core_Error::deprecatedFunctionWarning('getRecipientListingOptions'); + return self::getRecipientListingOptions('recipient_listing', ['values' => ['mapping_id' => $mappingID, 'recipient' => $recipientType]]); } /** diff --git a/CRM/Core/DAO/ActionSchedule.php b/CRM/Core/DAO/ActionSchedule.php index fe54694bfd..ef5d8d6f6d 100644 --- a/CRM/Core/DAO/ActionSchedule.php +++ b/CRM/Core/DAO/ActionSchedule.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/ActionSchedule.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:08e73c2f0aa86b5eab3e67f2a707b2bf) + * (GenCodeChecksum:271b3b1e64984e8a221b98351ae68300) */ /** @@ -976,6 +976,15 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO { 'entity' => 'ActionSchedule', 'bao' => 'CRM_Core_BAO_ActionSchedule', 'localizable' => 0, + 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED, + 'html' => [ + 'type' => 'Select', + 'label' => ts("Recipient Roles"), + 'controlField' => 'recipient', + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getRecipientListingOptions', + ], 'add' => '4.1', ], 'body_text' => [ diff --git a/Civi/ActionSchedule/MappingInterface.php b/Civi/ActionSchedule/MappingInterface.php index c75c972a2e..c6973aafd6 100644 --- a/Civi/ActionSchedule/MappingInterface.php +++ b/Civi/ActionSchedule/MappingInterface.php @@ -93,28 +93,23 @@ interface MappingInterface { public static function getLimitToOptions(): array; /** - * Get a list of recipient types. + * Get option list for `recipient` field. * * Note: A single schedule may filter on *zero* or *one* recipient types. * When an admin chooses a value, it's stored in $schedule->recipient. * * @return array - * array(string $value => string $label). - * Ex: array('assignee' => 'Activity Assignee'). + * Ex: ['assignee' => 'Activity Assignee', ...]. */ public static function getRecipientTypes(): array; /** - * Get a list of recipients which match the given type. - * - * Note: A single schedule may filter on *multiple* recipients. - * When an admin chooses value(s), it's stored in $schedule->recipient_listing. + * Get option list for `recipient_listing` field. * * @param string $recipientType - * Ex: 'participant_role'. + * Value of `recipient` field * @return array - * Array(mixed $name => string $label). - * Ex: array(1 => 'Attendee', 2 => 'Volunteer'). + * Ex: [1 => 'Attendee', 2 => 'Volunteer', ...]. * @see getRecipientTypes */ public function getRecipientListing($recipientType): array; diff --git a/xml/schema/Core/ActionSchedule.xml b/xml/schema/Core/ActionSchedule.xml index fa9ae0be23..1483a627f5 100644 --- a/xml/schema/Core/ActionSchedule.xml +++ b/xml/schema/Core/ActionSchedule.xml @@ -269,6 +269,16 @@ Recipient Listing varchar 128 + SEPARATOR_TRIMMED + + + Select + 1 + recipient + + + CRM_Core_BAO_ActionSchedule::getRecipientListingOptions + listing based on recipient field. 4.1 -- 2.25.1