From: kurund Date: Tue, 28 Jan 2014 04:11:12 +0000 (-0500) Subject: Merge branch 'CRM-13965' of git://github.com/pratik-joshi/civicrm-core into CRM-13965 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c20a2a076238cc98b963d877e8ec5adc6f0d0fe6;p=civicrm-core.git Merge branch 'CRM-13965' of git://github.com/pratik-joshi/civicrm-core into CRM-13965 Conflicts: CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl ---------------------------------------- * CRM-13965: Record additional payments or refunds for pending-pay later OR partially paid event registrations http://issues.civicrm.org/jira/browse/CRM-13965 --- c20a2a076238cc98b963d877e8ec5adc6f0d0fe6 diff --cc CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl index df84772493,6003bf8290..d46a279aa4 --- a/CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl +++ b/CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl @@@ -1,16 -1,42 +1,56 @@@ {php} $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates'; + $templates = array(); + foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) { + $parts = explode('_', basename($filename, '.tpl')); + $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename"); + } + $this->assign('templates', $templates); +{/php} + +{foreach from=$templates item=tpl} + {fetch assign=content file=$tpl.filename} + SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}'; + SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1; + 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)); ++{/foreach} + + $ovNames = array( + 'contribution' => array( + 'payment_or_refund_notification' => ts('Additional Payment Receipt or Refund Notification', array('escape' => 'sql')), + ), + ); + + $this->assign('ovNames', $ovNames); + $this->assign('dir', $dir); + {/php} + + {foreach from=$ovNames key=name item=ignore} + SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}'; + {/foreach} + + INSERT INTO civicrm_option_value + (option_group_id, name, {localize field='label'}label{/localize}, value, weight) VALUES + {foreach from=$ovNames key=gName item=ovs name=for_groups} + {foreach from=$ovs key=vName item=label name=for_values} + (@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} + {/foreach} + {/foreach} + + {foreach from=$ovNames key=gName item=ovs} + {foreach from=$ovs key=vName item=label} + SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}'; + {/foreach} + {/foreach} + + INSERT INTO civicrm_msg_template + (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES + {foreach from=$ovNames key=gName item=ovs name=for_groups} + {foreach from=$ovs key=vName item=title name=for_values} + {fetch assign=subject file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates/`$vName`_subject.tpl"} + {fetch assign=text file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates/`$vName`_text.tpl"} + {fetch assign=html file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates/`$vName`_html.tpl"} + ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1, 0), + ('{$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} + {/foreach} {/foreach} diff --cc CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl index 34d81d23bc,324852a647..1a89f39ea6 --- a/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl @@@ -1,7 -1,6 +1,8 @@@ {* file to handle db changes in 4.5.alpha1 during upgrade *} + {include file='../CRM/Upgrade/4.4.alpha1.msg_template/civicrm_msg_template.tpl'} +{include file='../CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl'} + ALTER TABLE `civicrm_contact` ADD COLUMN `formal_title` varchar(64) COMMENT 'Formal (academic or similar) title in front of name. (Prof., Dr. etc.)' AFTER `suffix_id`;