Commit | Line | Data |
---|---|---|
7c3d751c | 1 | {php} |
e4784b29 | 2 | $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.5.beta2.msg_template/message_templates/sample'; |
7c3d751c DG |
3 | $templates = array(); |
4 | foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) { | |
5 | $templates[] = array('name' => basename($filename, '.tpl'), 'filename' => "$dir/$filename"); | |
6 | } | |
7 | $this->assign('templates', $templates); | |
8 | {/php} | |
9 | ||
10 | {foreach from=$templates item=tpl} | |
11 | {fetch assign=content file=$tpl.filename} | |
12 | INSERT INTO civicrm_msg_template | |
13 | (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES | |
14 | ('{$tpl.name} Template', '{$tpl.name}', '', '{$content|escape:"quotes"}' ,NULL, 1, 0); | |
15 | {/foreach} | |
e4784b29 DG |
16 | |
17 | {php} | |
18 | $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.5.beta2.msg_template/message_templates'; | |
19 | $templates = array(); | |
20 | foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) { | |
21 | $parts = explode('_', basename($filename, '.tpl')); | |
22 | $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename"); | |
23 | } | |
24 | $this->assign('templates', $templates); | |
25 | {/php} | |
26 | ||
27 | {foreach from=$templates item=tpl} | |
28 | {fetch assign=content file=$tpl.filename} | |
29 | SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}'; | |
30 | SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1; | |
31 | 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)); | |
32 | {/foreach} |