Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* not sure how to define the below in Smarty, so doing it in PHP instead *} |
2 | {php} | |
3 | $ogNames = array( | |
4 | 'case' => ts('Message Template Workflow for Cases', array('escape' => 'sql')), | |
5 | 'contribution' => ts('Message Template Workflow for Contributions', array('escape' => 'sql')), | |
6 | 'event' => ts('Message Template Workflow for Events', array('escape' => 'sql')), | |
7 | 'friend' => ts('Message Template Workflow for Tell-a-Friend', array('escape' => 'sql')), | |
8 | 'membership' => ts('Message Template Workflow for Memberships', array('escape' => 'sql')), | |
9 | 'meta' => ts('Message Template Workflow for Meta Templates', array('escape' => 'sql')), | |
10 | 'pledge' => ts('Message Template Workflow for Pledges', array('escape' => 'sql')), | |
11 | 'uf' => ts('Message Template Workflow for Profiles', array('escape' => 'sql')), | |
12 | ); | |
13 | $ovNames = array( | |
14 | 'case' => array( | |
15 | 'case_activity' => ts('Cases - Send Copy of an Activity', array('escape' => 'sql')), | |
16 | ), | |
17 | 'contribution' => array( | |
18 | 'contribution_dupalert' => ts('Contributions - Duplicate Organization Alert', array('escape' => 'sql')), | |
19 | 'contribution_offline_receipt' => ts('Contributions - Receipt (off-line)', array('escape' => 'sql')), | |
20 | 'contribution_online_receipt' => ts('Contributions - Receipt (on-line)', array('escape' => 'sql')), | |
21 | 'contribution_recurring_notify' => ts('Contributions - Recurring Start and End Notification', array('escape' => 'sql')), | |
22 | 'pcp_notify' => ts('Personal Campaign Pages - Admin Notification', array('escape' => 'sql')), | |
23 | 'pcp_status_change' => ts('Personal Campaign Pages - Supporter Status Change Notification', array('escape' => 'sql')), | |
24 | 'pcp_supporter_notify' => ts('Personal Campaign Pages - Supporter Welcome', array('escape' => 'sql')), | |
25 | ), | |
26 | 'event' => array( | |
27 | 'event_offline_receipt' => ts('Events - Registration Confirmation and Receipt (off-line)', array('escape' => 'sql')), | |
28 | 'event_online_receipt' => ts('Events - Registration Confirmation and Receipt (on-line)', array('escape' => 'sql')), | |
29 | 'participant_cancelled' => ts('Events - Registration Cancellation Notice', array('escape' => 'sql')), | |
30 | 'participant_confirm' => ts('Events - Registration Confirmation Invite', array('escape' => 'sql')), | |
31 | 'participant_expired' => ts('Events - Pending Registration Expiration Notice', array('escape' => 'sql')), | |
32 | ), | |
33 | 'friend' => array( | |
34 | 'friend' => ts('Tell-a-Friend Email', array('escape' => 'sql')), | |
35 | ), | |
36 | 'membership' => array( | |
37 | 'membership_offline_receipt' => ts('Memberships - Signup and Renewal Receipts (off-line)', array('escape' => 'sql')), | |
38 | 'membership_online_receipt' => ts('Memberships - Receipt (on-line)', array('escape' => 'sql')), | |
39 | ), | |
40 | 'meta' => array( | |
41 | 'test_preview' => ts('Test-drive - Receipt Header', array('escape' => 'sql')), | |
42 | ), | |
43 | 'pledge' => array( | |
44 | 'pledge_acknowledge' => ts('Pledges - Acknowledgement', array('escape' => 'sql')), | |
45 | 'pledge_reminder' => ts('Pledges - Payment Reminder', array('escape' => 'sql')), | |
46 | ), | |
47 | 'uf' => array( | |
48 | 'uf_notify' => ts('Profiles - Admin Notification', array('escape' => 'sql')), | |
49 | ), | |
50 | ); | |
51 | $this->assign('ogNames', $ogNames); | |
52 | $this->assign('ovNames', $ovNames); | |
53 | {/php} | |
54 | ||
55 | INSERT INTO civicrm_option_group | |
56 | (name, {localize field='label'}label{/localize}, {localize field='description'}description{/localize}, is_reserved, is_active) VALUES | |
57 | {foreach from=$ogNames key=name item=description name=for_groups} | |
58 | ('msg_tpl_workflow_{$name}', {localize}'{$description}'{/localize}, {localize}'{$description}'{/localize}, 0, 1) {if $smarty.foreach.for_groups.last};{else},{/if} | |
59 | {/foreach} | |
60 | ||
61 | {foreach from=$ogNames key=name item=description} | |
62 | SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}'; | |
63 | {/foreach} | |
64 | ||
65 | INSERT INTO civicrm_option_value | |
66 | (option_group_id, name, {localize field='label'}label{/localize}, value, weight) VALUES | |
67 | {foreach from=$ovNames key=gName item=ovs name=for_groups} | |
68 | {foreach from=$ovs key=vName item=label name=for_values} | |
69 | (@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} | |
70 | {/foreach} | |
71 | {/foreach} | |
72 | ||
73 | {foreach from=$ovNames key=gName item=ovs} | |
74 | {foreach from=$ovs key=vName item=label} | |
75 | SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}'; | |
76 | {/foreach} | |
77 | {/foreach} | |
78 | ||
79 | INSERT INTO civicrm_msg_template | |
80 | (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES | |
81 | {foreach from=$ovNames key=gName item=ovs name=for_groups} | |
82 | {foreach from=$ovs key=vName item=title name=for_values} | |
83 | {fetch assign=subject file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/3.1.alpha1.msg_template/message_templates/`$vName`_subject.tpl"} | |
84 | {fetch assign=text file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/3.1.alpha1.msg_template/message_templates/`$vName`_text.tpl"} | |
85 | {fetch assign=html file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/3.1.alpha1.msg_template/message_templates/`$vName`_html.tpl"} | |
86 | ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1, 0), | |
87 | ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 0, 1) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if} | |
88 | {/foreach} | |
89 | {/foreach} |