Skip to content

Commit

Permalink
Merge branch 'hotfix-emails'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvanbreda committed May 21, 2024
2 parents e0fbbc5 + 295d082 commit 0e781f6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 52 deletions.
15 changes: 1 addition & 14 deletions ElasticsearchProxyHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,24 +640,11 @@ private static function proxyRedetAll($nid) {
* Proxy method to send an email querying a record.
*/
private static function proxyVerificationQueryEmail() {
$lang = [
'verificationQuery' => lang::get('Verification query'),
];
$emailBody = $_POST['body'];
// Format correct HTML.
$emailBody = str_replace("\n", '<br/>', $emailBody);
$emailBodyHtml = <<<HTML
<html>
<head>
<title>$lang[verificationQuery]</title>
</head>
<body>
$emailBody
</body>
</html>
HTML;
// Send email. Depends upon settings in php.ini being correct.
$success = hostsite_send_email($_POST['to'], $_POST['subject'], wordwrap($emailBodyHtml, 70));
$success = hostsite_send_email($_POST['to'], $_POST['subject'], $emailBody);

return [
'status' => $success ? 'OK' : 'Fail',
Expand Down
4 changes: 2 additions & 2 deletions ElasticsearchReportHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1843,13 +1843,13 @@ public static function verificationButtons(array $options) {
'commentReplyInstruct' => 'Click here to add a publicly visible comment to the record on iRecord.',
'csvDisallowedMessage' => 'Uploading verification decisions is only allowed when there is a filter that defines the scope of the records you can verify.',
'duplicateTemplateMsg' => 'A template with that name already exists. Please specify a unique name for your template then save it again, or click Overwrite to update the existing template details.',
'emailExpertBodyHeader' => 'The following record requires your assistance. Please could you reply to this email ' .
'emailExpertBodyHeader' => "Verification query\n\nThe following record requires your assistance. Please could you reply to this email " .
'with your opininion on whether the record is correct or not. You can reply to this message and it will be ' .
'forwarded direct to the verifier.',
'emailExpertInstruct' => 'Enter the email of an expert to request their assistance with this record.',
'emailExpertLoggedAsComment' => 'This record was emailed to an expert for checking.',
'emailExpertSubject' => 'Record of {{ taxon.taxon_name }} requires your assistance (ID:{{ id }})',
'emailQueryBodyHeader' => 'The following record requires confirmation. Please could you reply to this email ' .
'emailQueryBodyHeader' => "Verification query\n\nThe following record requires confirmation. Please could you reply to this email " .
'stating how confident you are that the record is correct and any other information you have which may help ' .
'to confirm this. You can reply to this message and it will be forwarded direct to the verifier.',
'emailQueryLoggedAsComment' => 'This record was emailed to the recorder for checking.',
Expand Down
19 changes: 6 additions & 13 deletions prebuilt_forms/group_send_invites.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,14 @@ private static function sendInvites(array $args, array $auth) {
$clean = strpos($rootFolder, '?') === FALSE;
$acceptUrl = $protocol . $_SERVER['HTTP_HOST'] . $rootFolder . $args['accept_invite_path'] . ($clean ? '?' : '&') . 'token=' . $base . $idx;
$messageHtml = str_replace("\n", '<br/>', $_POST['invite_message']);
$emailBodyHtml = <<<HTML
<html>
<head>
<title>$lang[invitationToJoinRecordingGroup]</title>
</head>
<body>
$messageHtml
<br/>
<br/>
<a href="$acceptUrl">$lang[acceptInvitiation]</a>
</body>
</html>
$emailHtml = <<<HTML
$messageHtml
<br/>
<br/>
<a href="$acceptUrl">$lang[acceptInvitiation]</a>
HTML;
// Send email. Depends upon settings in php.ini being correct.
$thismailsuccess = hostsite_send_email($trimmedEmail, $lang['invitationToJoinRecordingGroup'], $emailBodyHtml);
$thismailsuccess = hostsite_send_email($trimmedEmail, $lang['invitationToJoinRecordingGroup'], $emailHtml);
if (!$thismailsuccess) {
$failedRecipients[$trimmedEmail] = $acceptUrl;
}
Expand Down
2 changes: 1 addition & 1 deletion prebuilt_forms/js/verification_5.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ indiciaData.rowIdToReselect = false;
'{1}',
email.subtype === 'R' ? indiciaData.commentTranslations.recorder : indiciaData.commentTranslations.expert
);
email.body = email.body.replace(/\[Photos]/g, response.media);
email.body = email.body.replace(/\[Photos]/g, response.media.replace(/data-media-info=\"(.*?)\"/g, ''));
email.body = email.body.replace(/\[Comments]/g, response.comments);
// save a comment to indicate that the mail was sent
indiciaFns.saveComment(
Expand Down
12 changes: 1 addition & 11 deletions prebuilt_forms/verification_5.php
Original file line number Diff line number Diff line change
Expand Up @@ -1317,18 +1317,8 @@ public static function ajax_email($website_id, $password, $nid) {
$fromName = $fromEmail;
}
$emailBody = str_replace("\n", "<br/>", $_POST['body']);
$emailBodyHtml = <<<HTML
<html>
<head>
<title>$lang[verification]</title>
</head>
<body>
$emailBody
</body>
</html>
HTML;
// Send email. Depends upon settings in php.ini being correct.
$success = hostsite_send_email($_POST['to'], $_POST['subject'], $emailBodyHtml, [
$success = hostsite_send_email($_POST['to'], $_POST['subject'], $emailBody, [
'from' => $fromEmail,
'fromName' => $fromName,
]);
Expand Down
12 changes: 1 addition & 11 deletions prebuilt_forms/verification_samples.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,18 +816,8 @@ public static function ajax_email() {
'verification' => lang::get('Verification'),
];
$emailBody = str_replace("\n", "<br/>", $_POST['body']);
$emailBodyHtml = <<<HTML
<html>
<head>
<title>$lang[verification]</title>
</head>
<body>
$emailBody
</body>
</html>
HTML;
// Send email. Depends upon settings in php.ini being correct
$success = hostsite_send_email($_POST['to'], $_POST['subject'], $emailBodyHtml);
$success = hostsite_send_email($_POST['to'], $_POST['subject'], $emailBody);
return $success ? 'OK' : 'Fail';
}

Expand Down

0 comments on commit 0e781f6

Please sign in to comment.