Merge pull request #13182 from civicrm/5.8
[civicrm-core.git] / CRM / Upgrade / 4.6.alpha4.msg_template / civicrm_msg_template.tpl
CommitLineData
f5f9426f 1{php}
8bbae400 2 $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.6.alpha4.msg_template/message_templates';
f5f9426f
N
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{php}
12 $ovNames = array(
13 'contribution' => array(
14 'pcp_owner_notify' => ts('Personal Campaign Pages - Owner Notification', array('escape' => 'sql')),
15 ),
16 );
17
18 $this->assign('ovNames', $ovNames);
19 $this->assign('dir', $dir);
20{/php}
21
22{foreach from=$ovNames key=name item=ignore}
23 SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}';
24{/foreach}
25
26INSERT INTO civicrm_option_value
27 (option_group_id, name, {localize field='label'}label{/localize}, value, weight) VALUES
28{foreach from=$ovNames key=gName item=ovs name=for_groups}
29{foreach from=$ovs key=vName item=label name=for_values}
30 (@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}
31{/foreach}
32{/foreach}
33
34{foreach from=$ovNames key=gName item=ovs}
35{foreach from=$ovs key=vName item=label}
36 SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}';
37{/foreach}
38{/foreach}
39
40INSERT INTO civicrm_msg_template
41 (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES
42{foreach from=$ovNames key=gName item=ovs name=for_groups}
43{foreach from=$ovs key=vName item=title name=for_values}
c1f0eff9
N
44 {fetch assign=subject file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.6.alpha4.msg_template/message_templates/`$vName`_subject.tpl"}
45 {fetch assign=text file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.6.alpha4.msg_template/message_templates/`$vName`_text.tpl"}
46 {fetch assign=html file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.6.alpha4.msg_template/message_templates/`$vName`_html.tpl"}
f5f9426f
N
47 ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1, 0),
48 ('{$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}
49{/foreach}
50{/foreach}