replacing the email-templates of a survey?

More
3 months 4 days ago - 3 months 4 days ago #183382 by bewi
I want to replace the emailtemplates of a survey. as only superadmins should be able to change the default texts I wanted to get the texts in the plugin configuration.

later on on every save of the survey it's mail-templates should be replaced.

I got the fields to enter the value in the plugin configuration and it's content is saved in the table lime_plugin_settings.

as the mail templates are stored in lime_surveys_languagesettings I tried to hook into the save event.

$this->subscribe('beforeSave');
$this->subscribe('beforeSurveyLanguagesettingSave');


but those functions got not triggered :(



on the other side I noticed:
every time I save the survey, the mail templates are wrapped in a HTML page:
<html>
<script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script>
<script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script>
:
<script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script>
<script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script>
<head>
	<title></title>
</head>
<body>my template text</body>
</html>

and with each save another line
<script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script>
is inserted. (my text stays in the body-tag).



hooking into beforeSurveySave works without problems, but I can't hook into the other ones to modify the mail templates.
Last edit: 3 months 4 days ago by bewi. Reason: clarification

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
3 months 3 days ago #183421 by bewi
Although it is a weird behaviour to wrap text in a full html structur, the insertion of the Google analytics calls appears only with our 'old' firefox. In our company we have not the newest version, but an version with special extended LTS: 60.6.1esr (64-Bit)
Here I have some Javascript errors, I don't get with newest chrome (73.0.3683.103 (64-Bit))
I don't know wether this is the cause of misbehaviour, in chrome I only get a HTML/BODY-wrap with no GA-javascript. but that also seems strange.

At last I found my error:
the event no longer is named 'beforeSave' but 'beforeModelSave'

Please Log in or Create an account to join the conversation.

More
3 months 3 days ago - 3 months 3 days ago #183439 by DenisChenu
beforeModelSave is for all models : beforeSurveyLanguageSettingSave must work for SurveyLanguageSetting model only.

(see the Capitalize)

else beforeSave is the event LimeSurvey use fro Yii : it never work for LimeSurvey plugin

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .
Last edit: 3 months 3 days ago by DenisChenu.

Please Log in or Create an account to join the conversation.

More
3 months 3 days ago #183440 by DenisChenu
Else about _gaUserPrefs : did you try deactivate all FireFox plugin ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!