Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
49bcd488
Unverified
Commit
49bcd488
authored
3 years ago
by
colemanw
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #21039 from eileenmcnaughton/tok_pseudo
Reconcile tokens misnamed or missing on legacy class
parents
60738cf9
4a526c1b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Contribute/Tokens.php
+10
-9
10 additions, 9 deletions
CRM/Contribute/Tokens.php
CRM/Core/EntityTokens.php
+9
-0
9 additions, 0 deletions
CRM/Core/EntityTokens.php
CRM/Core/SelectValues.php
+3
-14
3 additions, 14 deletions
CRM/Core/SelectValues.php
with
22 additions
and
23 deletions
CRM/Contribute/Tokens.php
+
10
−
9
View file @
49bcd488
...
...
@@ -58,10 +58,15 @@ class CRM_Contribute_Tokens extends CRM_Core_EntityTokens {
protected
$fieldMetadata
=
[];
/**
* Get a list of tokens whose name and title match the DB fields.
* Get a list of tokens for the entity for which access is permitted to.
*
* This list is historical and we need to question whether we
* should filter out any fields (other than those fields, like api_key
* on the contact entity) with permissions defined.
*
* @return array
*/
protected
function
get
PassthruToken
s
():
array
{
protected
function
get
ExposedField
s
():
array
{
return
[
'contribution_page_id'
,
'source'
,
...
...
@@ -97,7 +102,7 @@ class CRM_Contribute_Tokens extends CRM_Core_EntityTokens {
*/
public
function
getBasicTokens
():
array
{
$return
=
[];
foreach
(
[
'contribution_status_id'
,
'payment_instrument_id'
,
'financial_type_id'
,
'contribution_page_id'
]
as
$fieldName
)
{
foreach
(
$this
->
getExposedFields
()
as
$fieldName
)
{
$return
[
$fieldName
]
=
$this
->
getFieldMetadata
()[
$fieldName
][
'title'
];
}
return
$return
;
...
...
@@ -107,11 +112,7 @@ class CRM_Contribute_Tokens extends CRM_Core_EntityTokens {
* Class constructor.
*/
public
function
__construct
()
{
$tokens
=
CRM_Utils_Array
::
subset
(
CRM_Utils_Array
::
collect
(
'title'
,
$this
->
getFieldMetadata
()),
$this
->
getPassthruTokens
()
);
$tokens
=
array_merge
(
$tokens
,
$this
->
getPseudoTokens
(),
CRM_Utils_Token
::
getCustomFieldTokens
(
'Contribution'
));
$tokens
=
$this
->
getAllTokens
();
parent
::
__construct
(
'contribution'
,
$tokens
);
}
...
...
@@ -138,7 +139,7 @@ class CRM_Contribute_Tokens extends CRM_Core_EntityTokens {
}
$fields
=
$this
->
getFieldMetadata
();
foreach
(
$this
->
get
P
as
sthru
Tokens
()
as
$token
)
{
foreach
(
array_keys
(
$this
->
get
B
as
ic
Tokens
()
)
as
$token
)
{
$e
->
query
->
select
(
'e.'
.
$fields
[
$token
][
'name'
]
.
' AS '
.
$this
->
getEntityAlias
()
.
$token
);
}
foreach
(
array_keys
(
$this
->
getPseudoTokens
())
as
$token
)
{
...
...
This diff is collapsed.
Click to expand it.
CRM/Core/EntityTokens.php
+
9
−
0
View file @
49bcd488
...
...
@@ -61,6 +61,15 @@ class CRM_Core_EntityTokens extends AbstractTokenSubscriber {
return
CRM_Core_DAO_AllCoreTables
::
getFullName
(
$this
->
getApiEntityName
());
}
/**
* Get all the tokens supported by this processor.
*
* @return array|string[]
*/
public
function
getAllTokens
():
array
{
return
array_merge
(
$this
->
getBasicTokens
(),
$this
->
getPseudoTokens
(),
CRM_Utils_Token
::
getCustomFieldTokens
(
'Contribution'
));
}
/**
* Is the given field a date field.
*
...
...
This diff is collapsed.
Click to expand it.
CRM/Core/SelectValues.php
+
3
−
14
View file @
49bcd488
...
...
@@ -565,27 +565,16 @@ class CRM_Core_SelectValues {
public
static
function
contributionTokens
():
array
{
$tokens
=
[];
$processor
=
new
CRM_Contribute_Tokens
();
foreach
(
array_merge
(
$processor
->
get
PseudoTokens
(),
$processor
->
getBasic
Tokens
()
)
as
$token
=>
$title
)
{
foreach
(
$processor
->
get
All
Tokens
()
as
$token
=>
$title
)
{
$tokens
[
'{contribution.'
.
$token
.
'}'
]
=
$title
;
}
return
array_merge
(
$tokens
,
[
'{contribution.id}'
=>
ts
(
'Contribution ID'
),
'{contribution.total_amount}'
=>
ts
(
'Total Amount'
),
'{contribution.fee_amount}'
=>
ts
(
'Fee Amount'
),
'{contribution.net_amount}'
=>
ts
(
'Net Amount'
),
'{contribution.non_deductible_amount}'
=>
ts
(
'Non-deductible Amount'
),
'{contribution.receive_date}'
=>
ts
(
'Contribution Date Received'
),
'{contribution.trxn_id}'
=>
ts
(
'Transaction ID'
),
'{contribution.invoice_id}'
=>
ts
(
'Invoice ID'
),
'{contribution.currency}'
=>
ts
(
'Currency'
),
'{contribution.cancel_date}'
=>
ts
(
'Contribution Cancel Date'
),
'{contribution.cancel_reason}'
=>
ts
(
'Contribution Cancel Reason'
),
'{contribution.receipt_date}'
=>
ts
(
'Receipt Date'
),
'{contribution.thankyou_date}'
=>
ts
(
'Thank You Date'
),
'{contribution.source}'
=>
ts
(
'Contribution Source'
),
'{contribution.amount_level}'
=>
ts
(
'Amount Level'
),
'{contribution.check_number}'
=>
ts
(
'Check Number'
),
'{contribution.campaign}'
=>
ts
(
'Contribution Campaign'
),
// @todo - we shouldn't need to include custom fields here -
// remove, with test.
],
CRM_Utils_Token
::
getCustomFieldTokens
(
'Contribution'
,
TRUE
));
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment