Skip to content
Permalink
Browse files

Fixed issue #13372: behavior of reset in mail templates

Dev: also fixed a wrong behaviour regarding general email template settings
  • Loading branch information...
lacrioque committed Mar 15, 2018
1 parent b2b02b9 commit 4837faae7170c0ee0f31e5b99a0658d65768494b
@@ -156,6 +156,121 @@ function update($iSurveyId)
self::index($iSurveyId);
}
public static function getTemplateTypes(){
return [
'invitation',
'reminder',
'confirmation',
'registration',
'admin_notification',
'admin_detailed_notification'
];
}
public static function getTabTypeArray($language=null){
if($language==null) { $language = App()->getLanguage(); }
$aDefaultTexts = LsDefaultDataSets::getTemplateDefaultTexts('html', $language);
return array(
'invitation' => array(
'title' => gT("Invitation"),
'subject' => gT("Invitation email subject:"),
'body' => gT("Invitation email body:"),
'attachments' => gT("Invitation attachments:"),
'field' => array(
'subject' => 'surveyls_email_invite_subj',
'body' => 'surveyls_email_invite'
),
'default' => array(
'subject' => $aDefaultTexts['invitation_subject'],
'body' => $aDefaultTexts['invitation']
)
),
'reminder' => array(
'title' => gT("Reminder"),
'subject' => gT("Reminder email subject:"),
'body' => gT("Reminder email body:"),
'attachments' => gT("Reminder attachments:"),
'field' => array(
'subject' => 'surveyls_email_remind_subj',
'body' => 'surveyls_email_remind'
),
'default' => array(
'subject' => $aDefaultTexts['reminder_subject'],
'body' => $aDefaultTexts['reminder']
)
),
'confirmation' => array(
'title' => gT("Confirmation"),
'subject' => gT("Confirmation email subject:"),
'body' => gT("Confirmation email body:"),
'attachments' => gT("Confirmation attachments:"),
'field' => array(
'subject' => 'surveyls_email_confirm_subj',
'body' => 'surveyls_email_confirm'
),
'default' => array(
'subject' => $aDefaultTexts['confirmation_subject'],
'body' => $aDefaultTexts['confirmation']
)
),
'registration' => array(
'title' => gT("Registration"),
'subject' => gT("Registration email subject:"),
'body' => gT("Registration email body:"),
'attachments' => gT("Registration attachments:"),
'field' => array(
'subject' => 'surveyls_email_register_subj',
'body' => 'surveyls_email_register'
),
'default' => array(
'subject' => $aDefaultTexts['registration_subject'],
'body' => $aDefaultTexts['registration']
)
),
'admin_notification' => array(
'title' => gT("Basic admin notification"),
'subject' => gT("Basic admin notification subject:"),
'body' => gT("Basic admin notification email body:"),
'attachments' => gT("Basic notification attachments:"),
'field' => array(
'subject' => 'email_admin_notification_subj',
'body' => 'email_admin_notification'
),
'default' => array(
'subject' => $aDefaultTexts['admin_notification_subject'],
'body' => $aDefaultTexts['admin_notification']
)
),
'admin_detailed_notification' => array(
'title' => gT("Detailed admin notification"),
'subject' => gT("Detailed admin notification subject:"),
'body' => gT("Detailed admin notification email body:"),
'attachments' => gT("Detailed notification attachments:"),
'field' => array(
'subject' => 'email_admin_responses_subj',
'body' => 'email_admin_responses'
),
'default' => array(
'subject' => $aDefaultTexts['admin_detailed_notification_subject'],
'body' => $aDefaultTexts['admin_detailed_notification']
)
)
);
}
public function getTemplateOfType($type, $language=null, $survey=0){
$language = $language===null ? App()->getLanguage() : $language;
$oSurvey = Survey::model()->findByPk($survey);
$aDefaultTexts = LsDefaultDataSets::getTemplateDefaultTexts('unescaped', $language);
$out = $aDefaultTexts[$type];
if($oSurvey->htmlemail=='Y') {
$out = nl2br($out);
}
echo $out;
App()->end();
}
/**
* Renders template(s) wrapped in header and footer
@@ -53,11 +53,11 @@ public static function getSurveyMenuEntryData()
return $returnArray;
}
public static function getTemplateDefaultTexts($mode)
public static function getTemplateDefaultTexts($mode, $language='en')
{
$sOldLanguage = App()->language;
App()->setLanguage('en');
App()->setLanguage($language);
$returnArray = array(
'admin_detailed_notification_subject'=>gT("Response submission for survey {SURVEYNAME} with results", $mode),
'admin_detailed_notification'=>gT("Hello,\n\nA new response was submitted for your survey '{SURVEYNAME}'.\n\nClick the following link to see the individual response:\n{VIEWRESPONSEURL}\n\nClick the following link to edit the individual response:\n{EDITRESPONSEURL}\n\nView statistics by clicking here:\n{STATISTICSURL}\n\n\nThe following answers were given by the participant:\n{ANSWERTABLE}", $mode),
@@ -912,8 +912,8 @@ function getSurveyInfo($surveyid, $languagecode = '')
*/
function templateDefaultTexts($sLanguage, $mode = 'html', $sNewlines = 'text')
{
$aDefaultTexts = LsDefaultDataSets::getTemplateDefaultTexts($mode);
$aDefaultTexts = LsDefaultDataSets::getTemplateDefaultTexts($mode, $sLanguage);
if ($sNewlines == 'html') {
$aDefaultTexts = array_map('nl2br', $aDefaultTexts);
@@ -1,91 +1,5 @@
<?php
$tabs = array(
'invitation' => array(
'title' => gT("Invitation"),
'subject' => gT("Invitation email subject:"),
'body' => gT("Invitation email body:"),
'attachments' => gT("Invitation attachments:"),
'field' => array(
'subject' => 'surveyls_email_invite_subj',
'body' => 'surveyls_email_invite'
),
'default' => array(
'subject' => $aDefaultTexts['invitation_subject'],
'body' => $aDefaultTexts['invitation']
)
),
'reminder' => array(
'title' => gT("Reminder"),
'subject' => gT("Reminder email subject:"),
'body' => gT("Reminder email body:"),
'attachments' => gT("Reminder attachments:"),
'field' => array(
'subject' => 'surveyls_email_remind_subj',
'body' => 'surveyls_email_remind'
),
'default' => array(
'subject' => $aDefaultTexts['reminder_subject'],
'body' => $aDefaultTexts['reminder']
)
),
'confirmation' => array(
'title' => gT("Confirmation"),
'subject' => gT("Confirmation email subject:"),
'body' => gT("Confirmation email body:"),
'attachments' => gT("Confirmation attachments:"),
'field' => array(
'subject' => 'surveyls_email_confirm_subj',
'body' => 'surveyls_email_confirm'
),
'default' => array(
'subject' => $aDefaultTexts['confirmation_subject'],
'body' => $aDefaultTexts['confirmation']
)
),
'registration' => array(
'title' => gT("Registration"),
'subject' => gT("Registration email subject:"),
'body' => gT("Registration email body:"),
'attachments' => gT("Registration attachments:"),
'field' => array(
'subject' => 'surveyls_email_register_subj',
'body' => 'surveyls_email_register'
),
'default' => array(
'subject' => $aDefaultTexts['registration_subject'],
'body' => $aDefaultTexts['registration']
)
),
'admin_notification' => array(
'title' => gT("Basic admin notification"),
'subject' => gT("Basic admin notification subject:"),
'body' => gT("Basic admin notification email body:"),
'attachments' => gT("Basic notification attachments:"),
'field' => array(
'subject' => 'email_admin_notification_subj',
'body' => 'email_admin_notification'
),
'default' => array(
'subject' => $aDefaultTexts['admin_notification_subject'],
'body' => $aDefaultTexts['admin_notification']
)
),
'admin_detailed_notification' => array(
'title' => gT("Detailed admin notification"),
'subject' => gT("Detailed admin notification subject:"),
'body' => gT("Detailed admin notification email body:"),
'attachments' => gT("Detailed notification attachments:"),
'field' => array(
'subject' => 'email_admin_responses_subj',
'body' => 'email_admin_responses'
),
'default' => array(
'subject' => $aDefaultTexts['admin_detailed_notification_subject'],
'body' => $aDefaultTexts['admin_detailed_notification']
)
)
);
$tabs = emailtemplates::getTabTypeArray();
echo "<div id='tab-$grouplang' class='tab-pane fade in ".$active."'>";
?>
@@ -116,16 +116,9 @@
<?php
App()->getClientScript()->registerScript("ScriptEmailTemplateLanguageTemplate_<?=$grouplang?>_<?=$tab?>", "
$('#validate_expression_".$grouplang."_".$tab."').remoteModal({}, {
closeIcon : '<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"".gT("Close")."\"><span aria-hidden=\"true\">&times;</span></button>',
closeButton : '<button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">".gT("Close")."</button>',
saveButton : '<button type=\"button\" class=\"btn btn-primary\">".gT('Save changes')."</button>'
});\n\n
$('#reset_template_".$grouplang."_".$tab."').on('click', function(){
$('#'+$(this).data('target')).val($(this).data('value'));
});\n\n
var prepEmailTemplates = PrepEmailTemplates();\n
prepEmailTemplates.init();\n
prepEmailTemplates.bindActions({validate: '#validate_expression_".$grouplang."_".$tab."', reset: '#reset_template_".$grouplang."_".$tab."'},
{close: '".gT('Close')."', save: '".gT('Save')."'}, '".App()->getController()->createUrl('admin/emailtemplates/getTemplateOfType', array('type' => $tab, 'language' => $grouplang, 'survey' => $surveyid ))."');\n
".implode("\n", $script), LSYii_ClientScript::POS_POSTSCRIPT);
?>
@@ -49,9 +49,6 @@
$bplang = $bplangs[$key];
$esrow = $attrib[$key];
$aDefaultTexts = $defaulttexts[$key];
if ($ishtml == true) {
$aDefaultTexts['admin_detailed_notification']=$aDefaultTexts['admin_detailed_notification_css'].conditionalNewlineToBreak($aDefaultTexts['admin_detailed_notification'],$ishtml);
}
$this->renderPartial('/admin/emailtemplates/email_language_tab', compact( 'ishtml', 'surveyid', 'grouplang', 'bplang', 'esrow', 'aDefaultTexts', 'active'));
@@ -153,6 +153,37 @@ var PrepEmailTemplates = function(){


},
bindActions = function(elements, translate, resetUrl){
$(elements.validate).remoteModal({}, {
closeIcon : '<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label="'+translate.close+'"><span aria-hidden=\"true\">&times;</span></button>',
closeButton : '<button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">'+translate.close+'</button>',
saveButton : '<button type=\"button\" class=\"btn btn-primary\">'+translate.save+'</button>'
});
$(elements.reset).on('click', function(){
var $self = $(this);
$.ajax({
url : resetUrl,
dataType: 'html',
success: function(result){
if(CKEDITOR.instances[$self.data('target')]){
CKEDITOR.instances[$self.data('target')].setData(result);
} else {
$('#'+$self.data('target')).val(result);
}

},
error: console.ls.error,
beforeSend: function(){
if(CKEDITOR.instances[$self.data('target')]){
CKEDITOR.instances[$self.data('target')].setData('');
} else {
$('#'+$self.data('target')).val('');
}

}
});
});
},

init = function(modal_id){
// Binds the Default value buttons for each email template subject and body text
@@ -184,6 +215,7 @@ var PrepEmailTemplates = function(){

return {
init: init,
bindActions: bindActions,
currentTarget: currentTarget,
addAttachment: addAttachment
}

0 comments on commit 4837faa

Please sign in to comment.
You can’t perform that action at this time.