| 1 | -- +--------------------------------------------------------------------+ |
| 2 | -- | CiviCRM version 5 | |
| 3 | -- +--------------------------------------------------------------------+ |
| 4 | -- | Copyright CiviCRM LLC (c) 2004-2019 | |
| 5 | -- +--------------------------------------------------------------------+ |
| 6 | -- | This file is a part of CiviCRM. | |
| 7 | -- | | |
| 8 | -- | CiviCRM is free software; you can copy, modify, and distribute it | |
| 9 | -- | under the terms of the GNU Affero General Public License | |
| 10 | -- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | |
| 11 | -- | | |
| 12 | -- | CiviCRM is distributed in the hope that it will be useful, but | |
| 13 | -- | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | -- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 15 | -- | See the GNU Affero General Public License for more details. | |
| 16 | -- | | |
| 17 | -- | You should have received a copy of the GNU Affero General Public | |
| 18 | -- | License and the CiviCRM Licensing Exception along | |
| 19 | -- | with this program; if not, contact CiviCRM LLC | |
| 20 | -- | at info[AT]civicrm[DOT]org. If you have questions about the | |
| 21 | -- | GNU Affero General Public License or the licensing of CiviCRM, | |
| 22 | -- | see the CiviCRM license FAQ at http://civicrm.org/licensing | |
| 23 | -- +--------------------------------------------------------------------+ |
| 24 | -- |
| 25 | -- Generated from {$smarty.template} |
| 26 | -- {$generated} |
| 27 | -- |
| 28 | {* not sure how to define the below in Smarty, so doing it in PHP instead *} |
| 29 | {php} |
| 30 | $ogNames = array( |
| 31 | 'case' => ts('Message Template Workflow for Cases', array('escape' => 'sql')), |
| 32 | 'contribution' => ts('Message Template Workflow for Contributions', array('escape' => 'sql')), |
| 33 | 'event' => ts('Message Template Workflow for Events', array('escape' => 'sql')), |
| 34 | 'friend' => ts('Message Template Workflow for Tell-a-Friend', array('escape' => 'sql')), |
| 35 | 'membership' => ts('Message Template Workflow for Memberships', array('escape' => 'sql')), |
| 36 | 'meta' => ts('Message Template Workflow for Meta Templates', array('escape' => 'sql')), |
| 37 | 'pledge' => ts('Message Template Workflow for Pledges', array('escape' => 'sql')), |
| 38 | 'uf' => ts('Message Template Workflow for Profiles', array('escape' => 'sql')), |
| 39 | 'petition' => ts('Message Template Workflow for Petition', array('escape' => 'sql')), |
| 40 | ); |
| 41 | $ovNames = array( |
| 42 | 'case' => array( |
| 43 | 'case_activity' => ts('Cases - Send Copy of an Activity', array('escape' => 'sql')), |
| 44 | ), |
| 45 | 'contribution' => array( |
| 46 | 'contribution_dupalert' => ts('Contributions - Duplicate Organization Alert', array('escape' => 'sql')), |
| 47 | 'contribution_offline_receipt' => ts('Contributions - Receipt (off-line)', array('escape' => 'sql')), |
| 48 | 'contribution_online_receipt' => ts('Contributions - Receipt (on-line)', array('escape' => 'sql')), |
| 49 | 'contribution_invoice_receipt' => ts('Contributions - Invoice', array('escape' => 'sql')), |
| 50 | 'contribution_recurring_notify' => ts('Contributions - Recurring Start and End Notification', array('escape' => 'sql')), |
| 51 | 'contribution_recurring_cancelled' => ts('Contributions - Recurring Cancellation Notification', array('escape' => 'sql')), |
| 52 | 'contribution_recurring_billing' => ts('Contributions - Recurring Billing Updates', array('escape' => 'sql')), |
| 53 | 'contribution_recurring_edit' => ts('Contributions - Recurring Updates', array('escape' => 'sql')), |
| 54 | 'pcp_notify' => ts('Personal Campaign Pages - Admin Notification', array('escape' => 'sql')), |
| 55 | 'pcp_status_change' => ts('Personal Campaign Pages - Supporter Status Change Notification', array('escape' => 'sql')), |
| 56 | 'pcp_supporter_notify' => ts('Personal Campaign Pages - Supporter Welcome', array('escape' => 'sql')), |
| 57 | 'pcp_owner_notify' => ts('Personal Campaign Pages - Owner Notification', array('escape' => 'sql')), |
| 58 | 'payment_or_refund_notification' => ts('Additional Payment Receipt or Refund Notification', array('escape' => 'sql')), |
| 59 | ), |
| 60 | 'event' => array( |
| 61 | 'event_offline_receipt' => ts('Events - Registration Confirmation and Receipt (off-line)', array('escape' => 'sql')), |
| 62 | 'event_online_receipt' => ts('Events - Registration Confirmation and Receipt (on-line)', array('escape' => 'sql')), |
| 63 | 'event_registration_receipt' => ts('Events - Receipt only', array('escape' => 'sql')), |
| 64 | 'participant_cancelled' => ts('Events - Registration Cancellation Notice', array('escape' => 'sql')), |
| 65 | 'participant_confirm' => ts('Events - Registration Confirmation Invite', array('escape' => 'sql')), |
| 66 | 'participant_expired' => ts('Events - Pending Registration Expiration Notice', array('escape' => 'sql')), |
| 67 | 'participant_transferred' => ts('Events - Registration Transferred Notice', array('escape' => 'sql')), |
| 68 | ), |
| 69 | 'friend' => array( |
| 70 | 'friend' => ts('Tell-a-Friend Email', array('escape' => 'sql')), |
| 71 | ), |
| 72 | 'membership' => array( |
| 73 | 'membership_offline_receipt' => ts('Memberships - Signup and Renewal Receipts (off-line)', array('escape' => 'sql')), |
| 74 | 'membership_online_receipt' => ts('Memberships - Receipt (on-line)', array('escape' => 'sql')), |
| 75 | 'membership_autorenew_cancelled' => ts('Memberships - Auto-renew Cancellation Notification', array('escape' => 'sql')), |
| 76 | 'membership_autorenew_billing' => ts('Memberships - Auto-renew Billing Updates', array('escape' => 'sql')), |
| 77 | ), |
| 78 | 'meta' => array( |
| 79 | 'test_preview' => ts('Test-drive - Receipt Header', array('escape' => 'sql')), |
| 80 | ), |
| 81 | 'pledge' => array( |
| 82 | 'pledge_acknowledge' => ts('Pledges - Acknowledgement', array('escape' => 'sql')), |
| 83 | 'pledge_reminder' => ts('Pledges - Payment Reminder', array('escape' => 'sql')), |
| 84 | ), |
| 85 | 'uf' => array( |
| 86 | 'uf_notify' => ts('Profiles - Admin Notification', array('escape' => 'sql')), |
| 87 | ), |
| 88 | 'petition' => array( |
| 89 | 'petition_sign' => ts('Petition - signature added', array('escape' => 'sql')), |
| 90 | 'petition_confirmation_needed' => ts('Petition - need verification', array('escape' => 'sql')), |
| 91 | ), |
| 92 | ); |
| 93 | $this->assign('ogNames', $ogNames); |
| 94 | $this->assign('ovNames', $ovNames); |
| 95 | {/php} |
| 96 | |
| 97 | INSERT INTO civicrm_option_group |
| 98 | (name, {localize field='title'}title{/localize}, {localize field='description'}description{/localize}, is_reserved, is_active) VALUES |
| 99 | {foreach from=$ogNames key=name item=description name=for_groups} |
| 100 | ('msg_tpl_workflow_{$name}', {localize}'{$description}'{/localize}, {localize}'{$description}'{/localize}, 1, 1) {if $smarty.foreach.for_groups.last};{else},{/if} |
| 101 | {/foreach} |
| 102 | |
| 103 | {foreach from=$ogNames key=name item=description} |
| 104 | SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}'; |
| 105 | {/foreach} |
| 106 | |
| 107 | INSERT INTO civicrm_option_value |
| 108 | (option_group_id, name, {localize field='label'}label{/localize}, value, weight) VALUES |
| 109 | {foreach from=$ovNames key=gName item=ovs name=for_groups} |
| 110 | {foreach from=$ovs key=vName item=label name=for_values} |
| 111 | (@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} |
| 112 | {/foreach} |
| 113 | {/foreach} |
| 114 | |
| 115 | {foreach from=$ovNames key=gName item=ovs} |
| 116 | {foreach from=$ovs key=vName item=label} |
| 117 | SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}'; |
| 118 | {/foreach} |
| 119 | {/foreach} |
| 120 | |
| 121 | INSERT INTO civicrm_msg_template |
| 122 | (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES |
| 123 | {foreach from=$ovNames key=gName item=ovs name=for_groups} |
| 124 | {foreach from=$ovs key=vName item=title name=for_values} |
| 125 | {fetch assign=subject file="`$smarty.const.SMARTY_DIR`/../../xml/templates/message_templates/`$vName`_subject.tpl"} |
| 126 | {fetch assign=text file="`$smarty.const.SMARTY_DIR`/../../xml/templates/message_templates/`$vName`_text.tpl"} |
| 127 | {fetch assign=html file="`$smarty.const.SMARTY_DIR`/../../xml/templates/message_templates/`$vName`_html.tpl"} |
| 128 | ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1, 0), |
| 129 | ('{$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} |
| 130 | {/foreach} |
| 131 | {/foreach} |
| 132 | |
| 133 | {php} |
| 134 | $dir = SMARTY_DIR . '/../../xml/templates/message_templates/sample'; |
| 135 | $templates = array(); |
| 136 | foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) { |
| 137 | $templates[] = array('name' => basename($filename, '.tpl'), 'filename' => "$dir/$filename"); |
| 138 | } |
| 139 | $this->assign('templates', $templates); |
| 140 | {/php} |
| 141 | |
| 142 | {foreach from=$templates item=tpl} |
| 143 | {fetch assign=content file=$tpl.filename} |
| 144 | INSERT INTO civicrm_msg_template |
| 145 | (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES |
| 146 | ('{$tpl.name} Template', '{$tpl.name}', '', '{$content|escape:"quotes"}' ,NULL, 1, 0); |
| 147 | {/foreach} |