X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=CRM%2FMember%2FTokens.php;h=35ba54a3557d5fa6db017dbe8a8bfa5923c70cad;hb=cf9fd82e3c538b0c4d798326bee8a0a1a3d010a1;hp=07aa7ef65af8042b8876feba782290440b918f78;hpb=044c0ad17bd0e434de0bb388f2629d2f37b8764e;p=civicrm-core.git diff --git a/CRM/Member/Tokens.php b/CRM/Member/Tokens.php index 07aa7ef65a..35ba54a355 100644 --- a/CRM/Member/Tokens.php +++ b/CRM/Member/Tokens.php @@ -34,23 +34,25 @@ class CRM_Member_Tokens extends CRM_Core_EntityTokens { } /** - * Get all tokens. + * List out the fields that are exposed. * - * This function will be removed once the parent class can determine it. + * For historical reasons these are the only exposed fields. + * + * It is also possible to list 'skippedFields' + * + * @return string[] */ - public function getAllTokens(): array { - return array_merge( - [ - 'fee' => ts('Membership Fee'), - 'id' => ts('Membership ID'), - 'join_date' => ts('Member Since'), - 'start_date' => ts('Membership Start Date'), - 'end_date' => ts('Membership Expiration Date'), - 'status_id:label' => ts('Status'), - 'membership_type_id:label' => ts('Membership Type'), - ], - CRM_Utils_Token::getCustomFieldTokens('Membership') - ); + protected function getExposedFields(): array { + return [ + 'id', + 'join_date', + 'start_date', + 'end_date', + 'status_id', + 'membership_type_id', + 'source', + 'status_override_end_date', + ]; } /** @@ -67,6 +69,30 @@ class CRM_Member_Tokens extends CRM_Core_EntityTokens { } } + /** + * Get any overrides for token metadata. + * + * This is most obviously used for setting the audience, which + * will affect widget-presence. + * + * Changing the audience is done in order to simplify the + * UI for more general users. + * + * @return \string[][] + */ + protected function getTokenMetadataOverrides(): array { + return [ + 'owner_membership_id' => ['audience' => 'sysadmin'], + 'max_related' => ['audience' => 'sysadmin'], + 'contribution_recur_id' => ['audience' => 'sysadmin'], + 'is_override' => ['audience' => 'sysadmin'], + 'is_test' => ['audience' => 'sysadmin'], + // Pay later is considered to be unreliable in the schema + // and will eventually be removed. + 'is_pay_later' => ['audience' => 'deprecated'], + ]; + } + /** * Get fields which need to be returned to render another token. * @@ -76,4 +102,24 @@ class CRM_Member_Tokens extends CRM_Core_EntityTokens { return ['fee' => 'membership_type_id']; } + /** + * Get any tokens with custom calculation. + * + * In this case 'fee' should be converted to{membership.membership_type_id.fee} + * but we don't have the formatting support to do that with no + * custom intervention yet. + */ + protected function getBespokeTokens(): array { + return [ + 'fee' => [ + 'title' => ts('Membership Fee'), + 'name' => 'fee', + 'type' => 'calculated', + 'options' => NULL, + 'data_type' => 'integer', + 'audience' => 'user', + ], + ]; + } + }