Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle both Activity Email and CiviMail-style token arrays #9

Merged
merged 2 commits into from Jun 26, 2019

Conversation

MegaphoneJon
Copy link
Contributor

@MegaphoneJon MegaphoneJon commented Jun 25, 2019

At first I thought this was a bug in your extension - but it's really a bug in core. Given how long the bug has been in core (2016) I think it makes sense to account for it in the extension - especially since this fix won't need changing if the bug ever IS fixed.

Chris Burgess outlines the issue perfectly in CRM-19758 - essentially, the array passed to this hook as $tokens isn't always in the same format. As a result, the tokens this extension generates fail on CiviMail (but not quick email, scheduled reminders, etc.)

This adds a helper function (stolen from Chris Burgess) to account for both array formats.

To test:
Create a template with this text:

Hi {contact.display_name},

Your employee's name is {related.display_name___reltype_b_Employee_of_Employer_of}
  • Send an email to any organization contact that has an employee via quick mail. This should render both tokens correctly.
  • Send the same email to the same contact via CiviMail. Without this patch, the internal token will render correctly but the reltoken will not.

@twomice twomice merged commit 5a4ebbc into twomice:master Jun 26, 2019
@twomice
Copy link
Owner

twomice commented Jun 26, 2019

Merged, thanks @MegaphoneJon . I've actually hit that bug before in other contexts; should have thought about it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants