Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | -- CRM-7817 |
2 | {if $addPetitionOptionGroup} | |
3 | ||
10824d34 | 4 | INSERT INTO `civicrm_option_group` |
5 | ( `name`, {localize field='label'}label{/localize}, {localize field='description'}description{/localize}, `is_reserved`, `is_active` ) | |
6 | VALUES | |
6a488035 TO |
7 | ( 'msg_tpl_workflow_petition', {localize}'{ts escape="sql"}Message Template Workflow for Petition{/ts}'{/localize},{localize}'{ts escape="sql"}Message Template Workflow for Petition{/ts}'{/localize}, 0, 1 ); |
8 | ||
9 | SELECT @option_group_id := MAX(id) from civicrm_option_group WHERE name = 'msg_tpl_workflow_petition'; | |
10 | ||
10824d34 | 11 | INSERT INTO `civicrm_option_value` |
12 | ( `option_group_id`, {localize field='label'}label{/localize}, `name`, `value`, `weight`, `is_active` ) | |
6a488035 TO |
13 | VALUES |
14 | ( @option_group_id, {localize}'{ts escape="sql"}Petition - signature added{/ts}'{/localize}, 'petition_sign', 1, 1, 1 ), | |
15 | ( @option_group_id, {localize}'{ts escape="sql"}Petition - need verification{/ts}'{/localize}, 'petition_confirmation_needed', 2, 2, 1 ); | |
16 | ||
17 | SELECT @tpl_ovid_petition_sign := MAX(id) FROM civicrm_option_value WHERE option_group_id = @option_group_id AND name = 'petition_sign'; | |
18 | SELECT @tpl_ovid_petition_confirmation_needed := MAX(id) FROM civicrm_option_value WHERE option_group_id = @option_group_id AND name = 'petition_confirmation_needed'; | |
19 | ||
20 | -- get the petition sign template values. | |
21 | {fetch assign=subject_petition_sign file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/3.4.beta2.msg_template/message_templates/petition_sign_subject.tpl"} | |
22 | {fetch assign=text_petition_sign file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/3.4.beta2.msg_template/message_templates/petition_sign_text.tpl"} | |
23 | {fetch assign=html_petition_sign file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/3.4.beta2.msg_template/message_templates/petition_sign_html.tpl"} | |
24 | ||
25 | -- get the petition confirmation needed template values. | |
26 | {fetch assign=subject_petition_confirmation_needed file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/3.4.beta2.msg_template/message_templates/petition_confirmation_needed_subject.tpl"} | |
27 | {fetch assign=text_petition_confirmation_needed file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/3.4.beta2.msg_template/message_templates/petition_confirmation_needed_text.tpl"} | |
28 | {fetch assign=html_petition_confirmation_needed file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/3.4.beta2.msg_template/message_templates/petition_confirmation_needed_html.tpl"} | |
29 | ||
10824d34 | 30 | INSERT INTO civicrm_msg_template |
31 | (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) | |
6a488035 TO |
32 | VALUES |
33 | ( '{ts escape="sql"}Petition - signature added{/ts}', '{$subject_petition_sign|escape:"quotes"}', '{$text_petition_sign|escape:"quotes"}', '{$html_petition_sign|escape:"quotes"}', @tpl_ovid_petition_sign, 1, 0), | |
34 | ||
35 | ('{ts escape="sql"}Petition - signature added{/ts}', '{$subject_petition_sign|escape:"quotes"}', '{$text_petition_sign|escape:"quotes"}', '{$html_petition_sign|escape:"quotes"}', @tpl_ovid_petition_sign, 0, 1), | |
36 | ||
37 | ('{ts escape="sql"}Petition - need verification{/ts}', '{$subject_petition_confirmation_needed|escape:"quotes"}', '{$text_petition_confirmation_needed|escape:"quotes"}', '{$html_petition_confirmation_needed|escape:"quotes"}', @tpl_ovid_petition_confirmation_needed, 1, 0), | |
38 | ||
39 | ('{ts escape="sql"}Petition - need verification{/ts}', '{$subject_petition_confirmation_needed|escape:"quotes"}', '{$text_petition_confirmation_needed|escape:"quotes"}', '{$html_petition_confirmation_needed|escape:"quotes"}', @tpl_ovid_petition_confirmation_needed, 0, 1); | |
40 | ||
41 | {/if} | |
42 | ||
43 | -- CRM-7834 | |
44 | {php} | |
45 | $dir = SMARTY_DIR . '/../../CRM/Upgrade/3.4.beta2.msg_template/message_templates'; | |
46 | $templates = array(); | |
47 | foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) { | |
48 | $parts = explode('_', basename($filename, '.tpl')); | |
49 | $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename"); | |
50 | } | |
51 | $this->assign('templates', $templates); | |
52 | {/php} | |
53 | ||
54 | {foreach from=$templates item=tpl} | |
55 | {fetch assign=content file=$tpl.filename} | |
56 | SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}'; | |
57 | SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1; | |
58 | 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)); | |
59 | {/foreach} |