Add cancel_reason field
[civicrm-core.git] / CRM / Upgrade / 4.5.alpha1.msg_template / civicrm_msg_template.tpl
CommitLineData
1421174e 1{php}
2 $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates';
3 $templates = array();
4 foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
5 $parts = explode('_', basename($filename, '.tpl'));
6 $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename");
7 }
8 $this->assign('templates', $templates);
9{/php}
10
11{foreach from=$templates item=tpl}
12 {fetch assign=content file=$tpl.filename}
13 SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
14 SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
15 UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
c20a2a07 16{/foreach}
7cdb890a 17
81f3d017 18{php}
7cdb890a
PJ
19 $ovNames = array(
20 'contribution' => array(
21 'payment_or_refund_notification' => ts('Additional Payment Receipt or Refund Notification', array('escape' => 'sql')),
22 ),
23 );
24
25 $this->assign('ovNames', $ovNames);
26 $this->assign('dir', $dir);
27{/php}
28
29{foreach from=$ovNames key=name item=ignore}
30 SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}';
31{/foreach}
32
33INSERT INTO civicrm_option_value
34 (option_group_id, name, {localize field='label'}label{/localize}, value, weight) VALUES
35{foreach from=$ovNames key=gName item=ovs name=for_groups}
36{foreach from=$ovs key=vName item=label name=for_values}
37 (@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}
38{/foreach}
39{/foreach}
40
41{foreach from=$ovNames key=gName item=ovs}
42{foreach from=$ovs key=vName item=label}
43 SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}';
44{/foreach}
45{/foreach}
46
47INSERT INTO civicrm_msg_template
48 (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES
49{foreach from=$ovNames key=gName item=ovs name=for_groups}
50{foreach from=$ovs key=vName item=title name=for_values}
51 {fetch assign=subject file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates/`$vName`_subject.tpl"}
52 {fetch assign=text file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates/`$vName`_text.tpl"}
53 {fetch assign=html file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates/`$vName`_html.tpl"}
54 ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1, 0),
55 ('{$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}
56{/foreach}
1421174e 57{/foreach}