From: Eileen McNaughton Date: Tue, 14 Sep 2021 21:00:00 +0000 (+1200) Subject: dev/core#2650 upgrade membership tokens to the new format X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=eac0a5bff7de78411da8df37e6fae405732543bf;p=civicrm-core.git dev/core#2650 upgrade membership tokens to the new format --- diff --git a/CRM/Core/Form/Task/PDFLetterCommon.php b/CRM/Core/Form/Task/PDFLetterCommon.php index b7762ccdc0..1f6845ac28 100644 --- a/CRM/Core/Form/Task/PDFLetterCommon.php +++ b/CRM/Core/Form/Task/PDFLetterCommon.php @@ -201,6 +201,8 @@ class CRM_Core_Form_Task_PDFLetterCommon { $deprecatedTokens = [ '{case.status_id}' => '{case.status_id:label}', '{case.case_type_id}' => '{case.case_type_id:label}', + '{membership.status}' => '{membership.status_id:label}', + '{membership.type}' => '{membership.membership_type_id:label}', ]; $tokenErrors = []; foreach ($deprecatedTokens as $token => $replacement) { diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 65509d23ea..1d091c4e50 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -523,11 +523,11 @@ class CRM_Core_SelectValues { * * @return array */ - public static function membershipTokens() { + public static function membershipTokens(): array { return [ '{membership.id}' => ts('Membership ID'), - '{membership.status}' => ts('Membership Status'), - '{membership.type}' => ts('Membership Type'), + '{membership.status_id:label}' => ts('Membership Status'), + '{membership.membership_type_id:label}' => ts('Membership Type'), '{membership.start_date}' => ts('Membership Start Date'), '{membership.join_date}' => ts('Membership Join Date'), '{membership.end_date}' => ts('Membership End Date'), diff --git a/CRM/Member/Tokens.php b/CRM/Member/Tokens.php index 8aff36f7ae..cf883bfeca 100644 --- a/CRM/Member/Tokens.php +++ b/CRM/Member/Tokens.php @@ -46,8 +46,6 @@ class CRM_Member_Tokens extends CRM_Core_EntityTokens { 'join_date' => ts('Membership Join Date'), 'start_date' => ts('Membership Start Date'), 'end_date' => ts('Membership End Date'), - 'status' => ts('Membership Status'), - 'type' => ts('Membership Type'), 'status_id:label' => ts('Membership Status'), 'membership_type_id:label' => ts('Membership Type'), ], @@ -77,9 +75,8 @@ class CRM_Member_Tokens extends CRM_Core_EntityTokens { // FIXME: `select('e.*')` seems too broad. $e->query ->select('e.*') - ->select('mt.minimum_fee as fee, e.id as id , e.join_date, e.start_date, e.end_date, membership_type_id as Membership__membership_type_id, status_id as Membership__status_id, ms.name as status, mt.name as type') - ->join('mt', '!casMailingJoinType civicrm_membership_type mt ON e.membership_type_id = mt.id') - ->join('ms', '!casMailingJoinType civicrm_membership_status ms ON e.status_id = ms.id'); + ->select('mt.minimum_fee as fee, e.id as id , e.join_date, e.start_date, e.end_date, membership_type_id as Membership__membership_type_id, status_id as Membership__status_id') + ->join('mt', '!casMailingJoinType civicrm_membership_type mt ON e.membership_type_id = mt.id'); } /** diff --git a/CRM/Upgrade/Incremental/php/FiveFortyThree.php b/CRM/Upgrade/Incremental/php/FiveFortyThree.php index d37671092b..2dfd87c610 100644 --- a/CRM/Upgrade/Incremental/php/FiveFortyThree.php +++ b/CRM/Upgrade/Incremental/php/FiveFortyThree.php @@ -68,6 +68,12 @@ class CRM_Upgrade_Incremental_php_FiveFortyThree extends CRM_Upgrade_Incremental $this->addTask('Replace legacy last_name smarty token in Online contribution workflow template', 'updateMessageToken', 'contribution_online_receipt', '$last_name', 'contact.last_name', $rev ); + $this->addTask('Replace membership status token in action schedule', + 'updateActionScheduleToken', 'membership.status', 'membership.status_id:label', $rev + ); + $this->addTask('Replace membership type token in action schedule', + 'updateActionScheduleToken', 'membership.type', 'membership.membership_type_id:label', $rev + ); } /** diff --git a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php index b3a08b2873..142a35e493 100644 --- a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php +++ b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php @@ -401,8 +401,8 @@ Check'; public function getMembershipTokens(): array { return [ '{membership.id}' => 'Membership ID', - '{membership.status}' => 'Membership Status', - '{membership.type}' => 'Membership Type', + '{membership.status_id:label}' => 'Membership Status', + '{membership.membership_type_id:label}' => 'Membership Type', '{membership.start_date}' => 'Membership Start Date', '{membership.join_date}' => 'Membership Join Date', '{membership.end_date}' => 'Membership End Date',