View Issue Details

IDProjectCategoryView StatusLast Update
12007Feature requests[All Projects] Translationpublic2019-03-28 17:21
Reporterdrogu02Assigned To 
PrioritynoneSeverityfeature 
Status newResolutionopen 
Product Version 
Target Version3.0Fixed in Version 
Summary12007: Override a translation value or modify the Save email sent to user
Description

I can't find a way to do something in Limesurvey and I try to know if it's possible.

The problem is that my client want to change the text and appearance in the email sent to person who save the survey to finish it later.

I want to know 2 things :
Is it possible to override a value of a text in /locale/fr/fr.mo without touching core of limesurvey?
Is it possible to modify the appearance/template of the email sent to user when he save the survey to finish it later? (That should be possible to change it by survey like we can do with invitation email)

TagsNo tags attached.

Relationships

related to 10533 resolvedDenisChenu Global beforeSendEmail event 
related to 09649 new Plugin event : update "default core string" 

Activities

DenisChenu

DenisChenu

2016-12-15 23:58

developer   ~42549

09649: Plugin event : update "default core string" : allow to set anystring/sentence
10533: Global beforeSendEmail event : set 'what' you want

DenisChenu

DenisChenu

2017-01-18 09:23

developer   ~42740

My rejextion is about an event for this specific issue , not the idea. I think a more global system are better :)

miguel2i

miguel2i

2017-04-05 14:40

reporter   ~43383

Hi,

For my use, i have made a patch to add the possibility to modify the template of the email send when saved survey for later.
The database update is missing (i can't find which file to update)
Any Developper can include this patch to LS core.

Related to 10533, 11192, 11848 and other, it's a missing feature.
Users doesn't understand they can modify template of other email but not this.
Like other email templates, it's a good place to customize one survey.

Maybe a more global system can be better, but for now, this patch work.



saved_email_template.patch (13,528 bytes)
diff --git a/application/controllers/admin/ExpressionValidate.php b/application/controllers/admin/ExpressionValidate.php
index 9e16ad8..7bbbe2c 100644
--- a/application/controllers/admin/ExpressionValidate.php
+++ b/application/controllers/admin/ExpressionValidate.php
@@ -144,6 +144,16 @@ class ExpressionValidate extends Survey_Common_Action {
                     'title'=>gT('Registration email body'),
                 ),
             ),
+            'saved'=>array(
+                'subject'=>array(
+                    'attribute'=>'surveyls_email_saved_subj',
+                    'title'=>gT('Saved email subject'),
+                ),
+                'message'=>array(
+                    'attribute'=>'surveyls_email_saved',
+                    'title'=>gT('Saved email body'),
+                ),
+            ),
             'admin_notification'=>array(
                 'subject'=>array(
                     'attribute'=>'email_admin_notification_subj',
@@ -225,6 +235,12 @@ class ExpressionValidate extends Survey_Common_Action {
                 $aReplacement["ANSWERTABLE"] = gT("Answers from this response");
                 // $moveResult = LimeExpressionManager::NavigateForwards(); // Seems OK without, nut need $LEM::StartSurvey
                 break;
+            case 'saved' :
+                $aReplacement["EMAIL"] = gT("Email from the token");
+                $aReplacement["FIRSTNAME"] = gT("First name from token");
+                $aReplacement["PASSWORD"] = gT("Password from token");
+                $aReplacement["SURVEYURL"] = gT("URL of the survey");
+                break;
             default:
                 throw new CHttpException(400,gT('Invalid type.'));
                 break;
diff --git a/application/controllers/admin/emailtemplates.php b/application/controllers/admin/emailtemplates.php
index 3aa1c37..adf839c 100644
--- a/application/controllers/admin/emailtemplates.php
+++ b/application/controllers/admin/emailtemplates.php
@@ -148,6 +148,8 @@ class emailtemplates extends Survey_Common_Action {
                     'surveyls_email_register' => $_POST['email_registration_'.$langname],
                     'surveyls_email_confirm_subj' => $_POST['email_confirmation_subj_'.$langname],
                     'surveyls_email_confirm' => $_POST['email_confirmation_'.$langname],
+                    'surveyls_email_saved_subj'=> $_POST['email_saved_subj_'. $langname],
+                    'surveyls_email_saved'=> $_POST['email_saved_'. $langname],
                     'email_admin_notification_subj' => $_POST['email_admin_notification_subj_'.$langname],
                     'email_admin_notification' => $_POST['email_admin_notification_'.$langname],
                     'email_admin_responses_subj' => $_POST['email_admin_detailed_notification_subj_'.$langname],
diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php
index c96ef9e..cca1f17 100644
--- a/application/helpers/common_helper.php
+++ b/application/helpers/common_helper.php
@@ -1233,7 +1233,13 @@ function templateDefaultTexts($sLanguage, $mode='html', $sNewlines='text')
     'reminder_subject'=>gT("Reminder to participate in a survey",$mode),
     'reminder'=>gT("Dear {FIRSTNAME},\n\nRecently we invited you to participate in a survey.\n\nWe note that you have not yet completed the survey, and wish to remind you that the survey is still available should you wish to take part.\n\nThe survey is titled:\n\"{SURVEYNAME}\"\n\n\"{SURVEYDESCRIPTION}\"\n\nTo participate, please click on the link below.\n\nSincerely,\n\n{ADMINNAME} ({ADMINEMAIL})\n\n----------------------------------------------\nClick here to do the survey:\n{SURVEYURL}",$mode)."\n\n".gT("If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:\n{OPTOUTURL}",$mode),
     'registration_subject'=>gT("Survey registration confirmation",$mode),
-    'registration'=>gT("Dear {FIRSTNAME},\n\nYou, or someone using your email address, have registered to participate in an online survey titled {SURVEYNAME}.\n\nTo complete this survey, click on the following URL:\n\n{SURVEYURL}\n\nIf you have any questions about this survey, or if you did not register to participate and believe this email is in error, please contact {ADMINNAME} at {ADMINEMAIL}.",$mode)
+    'registration'=>gT("Dear {FIRSTNAME},\n\nYou, or someone using your email address, have registered to participate in an online survey titled {SURVEYNAME}.\n\nTo complete this survey, click on the following URL:\n\n{SURVEYURL}\n\nIf you have any questions about this survey, or if you did not register to participate and believe this email is in error, please contact {ADMINNAME} at {ADMINEMAIL}.",$mode),
+    'saved_subject' => gT("Saved Survey Details", $mode) . " - {SURVEYNAME}",
+    'saved'=> gT("Thank you for saving your survey in progress.  The following details can be used to return to this survey and continue where you left off.  Please keep this e-mail for your reference - we cannot retrieve the password for you.", $mode).
+            "\n\n{SURVEYNAME}\n\n". gT("Name", $mode).": {FIRSTNAME}\n".
+                gT("Password", $mode) .": {PASSWORD}\n\n".
+                gT("Reload your survey by clicking on the following link (or pasting it into your browser):", $mode )."\n{SURVEYURL}"
+
     );
     if ($sNewlines=='html')
     {
diff --git a/application/libraries/Save.php b/application/libraries/Save.php
index 53ba9a6..8666828 100644
--- a/application/libraries/Save.php
+++ b/application/libraries/Save.php
@@ -137,7 +137,6 @@ class Save {
         }
 
         $duplicate = SavedControl::model()->findByAttributes(array('sid' => $surveyid, 'identifier' => $_POST['savename']));
-        $duplicate = SavedControl::model()->findByAttributes(array('sid' => $surveyid, 'identifier' => $_POST['savename']));
         if (strpos($_POST['savename'],'/')!==false || strpos($_POST['savepass'],'/')!==false || strpos($_POST['savename'],'&')!==false || strpos($_POST['savepass'],'&')!==false
             || strpos($_POST['savename'],'\\')!==false || strpos($_POST['savepass'],'\\')!==false)
         {
@@ -208,19 +207,29 @@ class Save {
             //Email if needed
             if (isset($_POST['saveemail']) && validateEmailAddress($_POST['saveemail']))
             {
-                $subject  = gT("Saved Survey Details") . " - " . $thissurvey['name'];
-                $message  = gT("Thank you for saving your survey in progress.  The following details can be used to return to this survey and continue where you left off.  Please keep this e-mail for your reference - we cannot retrieve the password for you.");
-                $message .= "\n\n".$thissurvey['name']."\n\n";
-                $message .= gT("Name").": ".$_POST['savename']."\n";
-                $message .= gT("Password").": ".$_POST['savepass']."\n\n";
-                $message .= gT("Reload your survey by clicking on the following link (or pasting it into your browser):")."\n";
+                $aReplacementVars=array();
+                $aReplacementVars['SURVEYNAME'] = $thissurvey['name'];
+                $aReplacementVars["ADMINNAME"]= $thissurvey['admin'];
+                $aReplacementVars["ADMINEMAIL"]= $thissurvey['adminemail'];
+                $aReplacementVars["FIRSTNAME"]=$_POST['savename'];
+                $aReplacementVars["PASSWORD"]=$_POST['savepass'];
+                $aReplacementVars["EMAIL"]=$_POST['saveemail'];
+                
                 $aParams=array('scid'=>$scid,'lang'=>App()->language,'loadname'=>$_POST['savename'],'loadpass'=>$_POST['savepass']);
                 if (!empty($clienttoken))
                 {
                     $aParams['token'] = $clienttoken;
                 }
-                $message .= Yii::app()->getController()->createAbsoluteUrl("/survey/index/sid/{$surveyid}/loadall/reload",$aParams);
-
+                $aReplacementVars['SURVEYURL'] = Yii::app()->getController()->createAbsoluteUrl("/survey/index/sid/{$surveyid}/loadall/reload",$aParams);
+                $redata = compact('thissurvey');
+                $subject = templatereplace(
+                        $thissurvey['surveyls_email_saved_subj'],
+                        $aReplacementVars,
+                        $redata);
+                $message = templatereplace(
+                        $thissurvey['surveyls_email_saved'],
+                        $aReplacementVars,
+                        $redata);
                 $from="{$thissurvey['adminname']} <{$thissurvey['adminemail']}>";
                 if (SendEmailMessage($message, $subject, $_POST['saveemail'], $from, $sitename, false, getBounceEmail($surveyid)))
                 {
diff --git a/application/models/SurveyLanguageSetting.php b/application/models/SurveyLanguageSetting.php
index 564897b..d659436 100644
--- a/application/models/SurveyLanguageSetting.php
+++ b/application/models/SurveyLanguageSetting.php
@@ -40,6 +40,8 @@
  * @property string $email_admin_notification
  * @property string $email_admin_responses_subj
  * @property string $email_admin_responses
+ * @property string $surveyls_email_saved_subj
+ * @property string $surveyls_email_saved
  *
  * @property integer $surveyls_numberformat
  * @property string $attatchments
@@ -117,6 +119,8 @@ class SurveyLanguageSetting extends LSActiveRecord
             array('email_admin_notification','lsdefault'),
             array('email_admin_responses_subj','lsdefault'),
             array('email_admin_responses','lsdefault'),
+            array('surveyls_email_saved_subj', 'lsdefault'),
+            array('surveyls_email_saved', 'lsdefault'),
 
             array('surveyls_email_invite_subj','LSYii_Validators'),
             array('surveyls_email_invite','LSYii_Validators'),
@@ -130,6 +134,8 @@ class SurveyLanguageSetting extends LSActiveRecord
             array('email_admin_notification','LSYii_Validators'),
             array('email_admin_responses_subj','LSYii_Validators'),
             array('email_admin_responses','LSYii_Validators'),
+            array('surveyls_email_saved_subj', 'LSYii_Validators'),
+            array('surveyls_email_saved', 'LSYii_Validators'),
 
             array('surveyls_title','LSYii_Validators'),
             array('surveyls_description','LSYii_Validators'),
@@ -166,7 +172,10 @@ class SurveyLanguageSetting extends LSActiveRecord
                         'email_admin_notification_subj' => $aDefaultTexts['admin_notification_subject'],
                         'email_admin_notification' => $aDefaultTexts['admin_notification'],
                         'email_admin_responses_subj' => $aDefaultTexts['admin_detailed_notification_subject'],
-                        'email_admin_responses' => $aDefaultTexts['admin_detailed_notification']);
+                        'email_admin_responses' => $aDefaultTexts['admin_detailed_notification'],
+                        'surveyls_email_saved_subj' => $aDefaultTexts['saved_subject'],
+                        'surveyls_email_saved' => $aDefaultTexts['saved'],
+             );
         if ($sEmailFormat == "html")
         {
             $aDefaultTextData['admin_detailed_notification']=$aDefaultTexts['admin_detailed_notification_css'].$aDefaultTexts['admin_detailed_notification'];
diff --git a/application/views/admin/emailtemplates/email_language_tab.php b/application/views/admin/emailtemplates/email_language_tab.php
index cbe50f8..abe9647 100644
--- a/application/views/admin/emailtemplates/email_language_tab.php
+++ b/application/views/admin/emailtemplates/email_language_tab.php
@@ -56,6 +56,20 @@
                 'body' => $aDefaultTexts['registration']
             )
         ),
+        'saved' => array(
+            'title' => gT("Saved Survey"),
+            'subject' => gT("Saved email subject : "),
+            'body' => gT("Saved email body:"),
+            'attachments' => gT("Saved email attachments:"),
+            'field' => array(
+                'subject' => 'surveyls_email_saved_subj',
+                'body' => 'surveyls_email_saved'
+            ),
+            'default' => array(
+                'subject' => $aDefaultTexts['saved_subject'],
+                'body' => $aDefaultTexts['saved']
+            )
+        ),
         'admin_notification' => array(
             'title' => gT("Basic admin notification"),
             'subject' => gT("Basic admin notification subject:"),
diff --git a/application/views/admin/emailtemplates/emailtemplates_view.php b/application/views/admin/emailtemplates/emailtemplates_view.php
index 35600aa..5d2322b 100644
--- a/application/views/admin/emailtemplates/emailtemplates_view.php
+++ b/application/views/admin/emailtemplates/emailtemplates_view.php
@@ -55,12 +55,12 @@
                 {
                     $bplang = $bplangs[$key];
                     $esrow = $attrib[$key];
+                    $esrow->validate();
                     $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('surveyinfo', 'ishtml', 'surveyid', 'grouplang', 'bplang', 'esrow', 'aDefaultTexts', 'active'));
 
                     if($count == 0)
DenisChenu

DenisChenu

2019-03-28 17:21

developer   ~51187

Can be done by plugins in 4.0 : https://github.com/LimeSurvey/LimeSurvey/commit/de63762472630ab797db4ae65899a53c165eef70

Issue History

Date Modified Username Field Change
2016-12-15 18:12 drogu02 New Issue
2016-12-15 18:12 drogu02 Status new => assigned
2016-12-15 18:12 drogu02 Assigned To => c_schmitz
2016-12-15 23:55 DenisChenu Relationship added related to 10533
2016-12-15 23:56 DenisChenu Relationship added related to 09649
2016-12-15 23:58 DenisChenu Note Added: 42549
2016-12-15 23:58 DenisChenu Project Bug reports => Feature requests
2017-01-16 18:08 c_schmitz Assigned To c_schmitz =>
2017-01-16 18:08 c_schmitz Status assigned => new
2017-01-18 09:23 DenisChenu Note Added: 42740
2017-04-05 14:40 miguel2i File Added: saved_email_template.patch
2017-04-05 14:40 miguel2i Note Added: 43383
2017-04-25 13:05 LouisGac Product Version 2.55.x =>
2017-04-25 13:05 LouisGac Target Version => 3.0
2019-03-28 17:21 DenisChenu Note Added: 51187