Skip to content

Commit

Permalink
Dev: FailedEmail fix wrong variable applied for id searched with admi…
Browse files Browse the repository at this point in the history
…n_responses(detailed email notifications)

Dev: adjusted Text intention when checking whether to delete emails after a successfully sending them
  • Loading branch information
ptelu committed Aug 30, 2022
1 parent 204ca68 commit ed273e9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions application/controllers/FailedEmailController.php
Expand Up @@ -78,8 +78,8 @@ public function actionResend()
App()->user->setFlash('error', gT("You do not have permission to access this page."));
$this->redirect(['failedEmail/index/', 'surveyid' => $surveyId]);
}
$preserveResend = App()->request->getParam('preserveResend');
$preserveResend = !is_null($preserveResend);
$deleteAfterResend = App()->request->getParam('deleteAfterResend');
$preserveResend = is_null($deleteAfterResend);
$item = [App()->request->getParam('item')];
$items = json_decode(App()->request->getParam('sItems'));
$selectedItems = $items ?? $item;
Expand Down
18 changes: 9 additions & 9 deletions application/helpers/frontend_helper.php
Expand Up @@ -518,11 +518,11 @@ function sendSubmitNotifications($surveyid, array $emails = [], bool $preserveRe
$mailer = \LimeMailer::getInstance();
$mailer->setTypeWithRaw('admin_notification', $emailLanguage);
foreach ($aEmailNotificationTo as $sRecipient) {
$notificationId = null;
$failedNotificationId = null;
$notificationRecipient = $sRecipient;
/** set mailer params for @see FailedEmailController::actionResend() */
if (!empty($emails)) {
$notificationId = $sRecipient['id'];
$failedNotificationId = $sRecipient['id'];
$responseId = $sRecipient['responseId'];
$notificationRecipient = $sRecipient['recipient'];
$emailLanguage = $sRecipient['language'];
Expand All @@ -531,7 +531,7 @@ function sendSubmitNotifications($surveyid, array $emails = [], bool $preserveRe
$mailer->setTo($notificationRecipient);
if (!$mailer->SendMessage()) {
$failedEmailCount++;
saveFailedEmail($notificationId, $notificationRecipient, $surveyid, $responseId, 'admin_notification', $emailLanguage, $mailer->getError());
saveFailedEmail($failedNotificationId, $notificationRecipient, $surveyid, $responseId, 'admin_notification', $emailLanguage, $mailer->getError());
if (empty($emails) && $debug > 0 && Permission::model()->hasSurveyPermission($surveyid, 'surveysettings', 'update')) {
/* Find a better way to show email error … */
echo CHtml::tag("div",
Expand All @@ -541,7 +541,7 @@ function sendSubmitNotifications($surveyid, array $emails = [], bool $preserveRe
} elseif ($preserveResend) {
$successfullEmailCount++;
//preserve failedEmail if it exists
preserveSuccessFailedEmail($notificationId);
preserveSuccessFailedEmail($failedNotificationId);
} else {
$successfullEmailCount++;
}
Expand All @@ -550,19 +550,19 @@ function sendSubmitNotifications($surveyid, array $emails = [], bool $preserveRe

if (count($aEmailResponseTo) > 0) {
// there was no token used so lets remove the token field from insertarray
if (isset($_SESSION['survey_' . $surveyid])) {
if (isset($_SESSION['survey_' . $surveyid]['insertarray'][0])) {
if (!isset($_SESSION['survey_' . $surveyid]['token']) && $_SESSION['survey_' . $surveyid]['insertarray'][0] === 'token') {
unset($_SESSION['survey_' . $surveyid]['insertarray'][0]);
}
}
$mailer = \LimeMailer::getInstance();
$mailer->setTypeWithRaw('admin_responses', $emailLanguage);
foreach ($aEmailResponseTo as $sRecipient) {
$notificationId = null;
$failedNotificationId = null;
$responseRecipient = $sRecipient;
/** set mailer params for @see FailedEmailController::actionResend() */
if (!empty($emails)) {
$notificationId = $sRecipient['id'];
$failedNotificationId = $sRecipient['id'];
$responseId = $sRecipient['responseId'];
$responseRecipient = $sRecipient['recipient'];
$emailLanguage = $sRecipient['language'];
Expand Down Expand Up @@ -595,7 +595,7 @@ function sendSubmitNotifications($surveyid, array $emails = [], bool $preserveRe
$mailer->setTo($responseRecipient);
if (!$mailer->SendMessage()) {
$failedEmailCount++;
saveFailedEmail($notificationId, $responseRecipient, $surveyid, $responseId, 'admin_responses', $emailLanguage, $mailer->getError());
saveFailedEmail($failedNotificationId, $responseRecipient, $surveyid, $responseId, 'admin_responses', $emailLanguage, $mailer->getError());
if (empty($emails) && $debug > 0 && Permission::model()->hasSurveyPermission($surveyid, 'surveysettings', 'update')) {
/* Find a better way to show email error … */
echo CHtml::tag("div",
Expand All @@ -605,7 +605,7 @@ function sendSubmitNotifications($surveyid, array $emails = [], bool $preserveRe
} elseif ($preserveResend) {
$successfullEmailCount++;
//preserve failedEmail if it exists
preserveSuccessFailedEmail($responseId);
preserveSuccessFailedEmail($failedNotificationId);
} else {
$successfullEmailCount++;
}
Expand Down
4 changes: 2 additions & 2 deletions application/views/failedEmail/partials/modal/resend_body.php
@@ -1,6 +1,6 @@
<?php
?>
<label class="control-label" for="preserveResend"><?= gT('Preserve successful emails?') ?></label>
<label class="control-label" for="deleteAfterResend"><?= gT('Delete email(s) from list after sending was successful') ?></label>
<div>
<input class="custom-data" type="checkbox" name="preserveResend" id="preserveResend" checked/>
<input class="custom-data" type="checkbox" name="deleteAfterResend" id="deleteAfterResend" checked/>
</div>

0 comments on commit ed273e9

Please sign in to comment.