Skip to content

Commit

Permalink
Add contact greeting to membership online receipt text message templa…
Browse files Browse the repository at this point in the history
…te, if exists, per civicrm#11674
  • Loading branch information
eileenmcnaughton committed Jun 8, 2018
1 parent 7e0ee04 commit 6718c2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions CRM/Upgrade/Incremental/MessageTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ protected function getTemplateUpdates() {
return [
[
'version' => '5.4.alpha1',
'template' => 'membership_online_receipt',
'upgrade_descriptor' => ts('Use email greeting at top where available'),
'type' => 'text',
'templates' => [
['name' => 'membership_online_receipt', 'type' => 'text'],
['name' => 'membership_online_receipt', 'type' => 'html'],
]
],
];
}
Expand All @@ -86,9 +88,11 @@ protected function getTemplateUpdates() {
public function getTemplatesToUpdate() {
$templates = $this->getTemplateUpdates();
$return = [];
foreach ($templates as $template) {
if ($template['version'] === $this->getUpgradeVersion()) {
$return[$template['template'] . '_' . $template['type']] = $template;
foreach ($templates as $templateArray) {
if ($templateArray['version'] === $this->getUpgradeVersion()) {
foreach ($templateArray['templates'] as $template) {
$return[$template['name'] . '_' . $template['type']] = $template;
}
}
}
return $return;
Expand All @@ -113,9 +117,9 @@ public function updateTemplates() {
$templates = $this->getTemplatesToUpdate();
foreach ($templates as $template) {
$workFlowID = CRM_Core_DAO::singleValueQuery("SELECT MAX(id) as id FROM civicrm_option_value WHERE name = %1", [
1 => [$template['template'], 'String'],
1 => [$template['name'], 'String'],
]);
$content = file_get_contents(\Civi::paths()->getPath('[civicrm.root]/xml/templates/message_templates/' . $template['template'] . '_' . $template['type'] . '.tpl'));
$content = file_get_contents(\Civi::paths()->getPath('[civicrm.root]/xml/templates/message_templates/' . $template['name'] . '_' . $template['type'] . '.tpl'));
$templatesToUpdate = [];
$templatesToUpdate[] = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_msg_template WHERE workflow_id = $workFlowID AND is_reserved = 1");
$defaultTemplateID = CRM_Core_DAO::singleValueQuery("
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{if $contact.email_greeting}{$contact.email_greeting},{/if}
{if $receipt_text}
{$receipt_text}
{/if}
Expand Down

0 comments on commit 6718c2c

Please sign in to comment.