Skip to content

Commit

Permalink
Fixed issue #17648: Email received by participant is empty (#2691)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Nov 21, 2022
1 parent 3465fd5 commit 9526dce
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions application/controllers/admin/Tokens.php
Expand Up @@ -1404,8 +1404,17 @@ public function email(int $iSurveyId)
$mail->emailType = $sSubAction;
$mail->replaceTokenAttributes = true;
foreach ($emresult as $emrow) {
if (empty($emrow['language'])) {
$emrow['language'] = $sBaseLanguage;
$mailLanguage = $emrow['language'];
if (empty($mailLanguage)) {
$mailLanguage = $sBaseLanguage;
}
if (!in_array($mailLanguage, Survey::model()->findByPk($iSurveyId)->getAllLanguages())) {
$mailLanguage = $sBaseLanguage;
$tokenoutput .= CHtml::tag(
"div",
array('class' => 'text-warning'),
sprintf(gT("Invalid language %s for token ID: %s."), $emrow['language'], $emrow['tid'])
);
}
$mail = \LimeMailer::getInstance();
if ($this->tokenIsSetInEmailCache($iSurveyId, $emrow['tid'], $bIsInvitation)) {
Expand All @@ -1419,9 +1428,9 @@ public function email(int $iSurveyId)
continue;
}
$mail->setToken($emrow['token']);
$mail->setFrom(Yii::app()->request->getPost('from_' . $emrow['language']));
$mail->rawSubject = $sSubject[$emrow['language']];
$mail->rawBody = $sMessage[$emrow['language']];
$mail->setFrom(Yii::app()->request->getPost('from_' . $mailLanguage));
$mail->rawSubject = $sSubject[$mailLanguage];
$mail->rawBody = $sMessage[$mailLanguage];

// If "Bypass date control before sending email" is disabled, check the token validity range
if (!Yii::app()->request->getPost('bypassdatecontrol')) {
Expand Down Expand Up @@ -1457,7 +1466,16 @@ public function email(int $iSurveyId)
$oToken->remindercount++;
}
$tokenSaveError = "";
if (!$oToken->encryptSave(true)) {
if (
!$oToken->save( // Save only uncrypted value, no need to crypt/encryt
true, // Validate but only the date part
array(
'sent',
'remindersent',
'remindercount'
)
)
) {
// Add the error when try to save token
$tokenSaveError = CHtml::errorSummary(
$oToken,
Expand Down

0 comments on commit 9526dce

Please sign in to comment.