Merge pull request #17257 from colemanw/tagParam
[civicrm-core.git] / xml / templates / civicrm_msg_template.tpl
1 -- +--------------------------------------------------------------------+
2 -- | Copyright CiviCRM LLC. All rights reserved. |
3 -- | |
4 -- | This work is published under the GNU AGPLv3 license with some |
5 -- | permitted exceptions and without any warranty. For full license |
6 -- | and copyright information, see https://civicrm.org/licensing |
7 -- +--------------------------------------------------------------------+
8 --
9 -- Generated from {$smarty.template}
10 -- {$generated}
11 --
12 {* not sure how to define the below in Smarty, so doing it in PHP instead *}
13 {php}
14 $ogNames = array(
15 'case' => ts('Message Template Workflow for Cases', array('escape' => 'sql')),
16 'contribution' => ts('Message Template Workflow for Contributions', array('escape' => 'sql')),
17 'event' => ts('Message Template Workflow for Events', array('escape' => 'sql')),
18 'friend' => ts('Message Template Workflow for Tell-a-Friend', array('escape' => 'sql')),
19 'membership' => ts('Message Template Workflow for Memberships', array('escape' => 'sql')),
20 'meta' => ts('Message Template Workflow for Meta Templates', array('escape' => 'sql')),
21 'pledge' => ts('Message Template Workflow for Pledges', array('escape' => 'sql')),
22 'uf' => ts('Message Template Workflow for Profiles', array('escape' => 'sql')),
23 'petition' => ts('Message Template Workflow for Petition', array('escape' => 'sql')),
24 );
25 $ovNames = array(
26 'case' => array(
27 'case_activity' => ts('Cases - Send Copy of an Activity', array('escape' => 'sql')),
28 ),
29 'contribution' => array(
30 'contribution_dupalert' => ts('Contributions - Duplicate Organization Alert', array('escape' => 'sql')),
31 'contribution_offline_receipt' => ts('Contributions - Receipt (off-line)', array('escape' => 'sql')),
32 'contribution_online_receipt' => ts('Contributions - Receipt (on-line)', array('escape' => 'sql')),
33 'contribution_invoice_receipt' => ts('Contributions - Invoice', array('escape' => 'sql')),
34 'contribution_recurring_notify' => ts('Contributions - Recurring Start and End Notification', array('escape' => 'sql')),
35 'contribution_recurring_cancelled' => ts('Contributions - Recurring Cancellation Notification', array('escape' => 'sql')),
36 'contribution_recurring_billing' => ts('Contributions - Recurring Billing Updates', array('escape' => 'sql')),
37 'contribution_recurring_edit' => ts('Contributions - Recurring Updates', array('escape' => 'sql')),
38 'pcp_notify' => ts('Personal Campaign Pages - Admin Notification', array('escape' => 'sql')),
39 'pcp_status_change' => ts('Personal Campaign Pages - Supporter Status Change Notification', array('escape' => 'sql')),
40 'pcp_supporter_notify' => ts('Personal Campaign Pages - Supporter Welcome', array('escape' => 'sql')),
41 'pcp_owner_notify' => ts('Personal Campaign Pages - Owner Notification', array('escape' => 'sql')),
42 'payment_or_refund_notification' => ts('Additional Payment Receipt or Refund Notification', array('escape' => 'sql')),
43 ),
44 'event' => array(
45 'event_offline_receipt' => ts('Events - Registration Confirmation and Receipt (off-line)', array('escape' => 'sql')),
46 'event_online_receipt' => ts('Events - Registration Confirmation and Receipt (on-line)', array('escape' => 'sql')),
47 'event_registration_receipt' => ts('Events - Receipt only', array('escape' => 'sql')),
48 'participant_cancelled' => ts('Events - Registration Cancellation Notice', array('escape' => 'sql')),
49 'participant_confirm' => ts('Events - Registration Confirmation Invite', array('escape' => 'sql')),
50 'participant_expired' => ts('Events - Pending Registration Expiration Notice', array('escape' => 'sql')),
51 'participant_transferred' => ts('Events - Registration Transferred Notice', array('escape' => 'sql')),
52 ),
53 'friend' => array(
54 'friend' => ts('Tell-a-Friend Email', array('escape' => 'sql')),
55 ),
56 'membership' => array(
57 'membership_offline_receipt' => ts('Memberships - Signup and Renewal Receipts (off-line)', array('escape' => 'sql')),
58 'membership_online_receipt' => ts('Memberships - Receipt (on-line)', array('escape' => 'sql')),
59 'membership_autorenew_cancelled' => ts('Memberships - Auto-renew Cancellation Notification', array('escape' => 'sql')),
60 'membership_autorenew_billing' => ts('Memberships - Auto-renew Billing Updates', array('escape' => 'sql')),
61 ),
62 'meta' => array(
63 'test_preview' => ts('Test-drive - Receipt Header', array('escape' => 'sql')),
64 ),
65 'pledge' => array(
66 'pledge_acknowledge' => ts('Pledges - Acknowledgement', array('escape' => 'sql')),
67 'pledge_reminder' => ts('Pledges - Payment Reminder', array('escape' => 'sql')),
68 ),
69 'uf' => array(
70 'uf_notify' => ts('Profiles - Admin Notification', array('escape' => 'sql')),
71 ),
72 'petition' => array(
73 'petition_sign' => ts('Petition - signature added', array('escape' => 'sql')),
74 'petition_confirmation_needed' => ts('Petition - need verification', array('escape' => 'sql')),
75 ),
76 );
77 $this->assign('ogNames', $ogNames);
78 $this->assign('ovNames', $ovNames);
79 {/php}
80
81 INSERT INTO civicrm_option_group
82 (name, {localize field='title'}title{/localize}, {localize field='description'}description{/localize}, is_reserved, is_active) VALUES
83 {foreach from=$ogNames key=name item=description name=for_groups}
84 ('msg_tpl_workflow_{$name}', {localize}'{$description}'{/localize}, {localize}'{$description}'{/localize}, 1, 1) {if $smarty.foreach.for_groups.last};{else},{/if}
85 {/foreach}
86
87 {foreach from=$ogNames key=name item=description}
88 SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}';
89 {/foreach}
90
91 INSERT INTO civicrm_option_value
92 (option_group_id, name, {localize field='label'}label{/localize}, value, weight) VALUES
93 {foreach from=$ovNames key=gName item=ovs name=for_groups}
94 {foreach from=$ovs key=vName item=label name=for_values}
95 (@tpl_ogid_{$gName}, '{$vName}', {localize}'{$label}'{/localize}, {$smarty.foreach.for_values.iteration}, {$smarty.foreach.for_values.iteration}) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
96 {/foreach}
97 {/foreach}
98
99 {foreach from=$ovNames key=gName item=ovs}
100 {foreach from=$ovs key=vName item=label}
101 SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}';
102 {/foreach}
103 {/foreach}
104
105 INSERT INTO civicrm_msg_template
106 (msg_title, msg_subject, msg_text, msg_html, workflow_name, workflow_id, is_default, is_reserved) VALUES
107 {foreach from=$ovNames key=gName item=ovs name=for_groups}
108 {foreach from=$ovs key=vName item=title name=for_values}
109 {fetch assign=subject file="`$gencodeXmlDir`/templates/message_templates/`$vName`_subject.tpl"}
110 {fetch assign=text file="`$gencodeXmlDir`/templates/message_templates/`$vName`_text.tpl"}
111 {fetch assign=html file="`$gencodeXmlDir`/templates/message_templates/`$vName`_html.tpl"}
112 ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', '{$vName}', @tpl_ovid_{$vName}, 1, 0),
113 ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', '{$vName}', @tpl_ovid_{$vName}, 0, 1) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
114 {/foreach}
115 {/foreach}
116
117 {php}
118 $dir = $this->_tpl_vars['gencodeXmlDir'] . '/templates/message_templates/sample';
119 $templates = array();
120 foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
121 $templates[] = array('name' => basename($filename, '.tpl'), 'filename' => "$dir/$filename");
122 }
123 $this->assign('templates', $templates);
124 {/php}
125
126 {foreach from=$templates item=tpl}
127 {fetch assign=content file=$tpl.filename}
128 INSERT INTO civicrm_msg_template
129 (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES
130 ('{$tpl.name} Template', '{$tpl.name}', '', '{$content|escape:"quotes"}' ,NULL, 1, 0);
131 {/foreach}