Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

email: fix wrong button text if "Store email addresses in file" is enabled #462

Merged
merged 5 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 35 additions & 22 deletions api/sendPic.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
require_once '../lib/db.php';
require_once '../lib/log.php';

if (empty($_POST['sendTo']) || empty($_POST['image']) || !PHPMailer::validateAddress($_POST['sendTo'])) {
if (empty($_POST['sendTo']) || !PHPMailer::validateAddress($_POST['sendTo'])) {
$LogData = [
'success' => false,
'error' => 'E-Mail address invalid',
Expand All @@ -24,6 +24,40 @@
die($LogString);
}

if (isset($_POST['send-link']) && $_POST['send-link'] === 'yes') {
if (!file_exists(MAIL_FILE)) {
$addresses = [];
} else {
$addresses = json_decode(file_get_contents(MAIL_FILE));
}

if (!in_array($_POST['sendTo'], $addresses)) {
$addresses[] = $_POST['sendTo'];
}

file_put_contents(MAIL_FILE, json_encode($addresses));

die(
json_encode([
'success' => true,
'saved' => true,
])
);
}

if (empty($_POST['image'])) {
$LogData = [
'success' => false,
'error' => 'Image not defined',
'php' => basename($_SERVER['PHP_SELF']),
];
$LogString = json_encode($LogData);
if ($config['dev']['enabled']) {
logError($LogData);
}
die($LogString);
}

$postImage = basename($_POST['image']);
if (!isImageInDB($postImage)) {
$LogData = [
Expand Down Expand Up @@ -96,27 +130,6 @@
die($LogString);
}

if (isset($_POST['send-link']) && $_POST['send-link'] === 'yes') {
if (!file_exists(MAIL_FILE)) {
$addresses = [];
} else {
$addresses = json_decode(file_get_contents(MAIL_FILE));
}

if (!in_array($_POST['sendTo'], $addresses)) {
$addresses[] = $_POST['sendTo'];
}

file_put_contents(MAIL_FILE, json_encode($addresses));

die(
json_encode([
'success' => true,
'saved' => true,
])
);
}

if ($mail->send()) {
die(
json_encode([
Expand Down
18 changes: 1 addition & 17 deletions gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,7 @@

<?php include('template/pswp.template.php'); ?>

<div class="send-mail">
<i class="fa fa-times" id="send-mail-close"></i>
<p data-i18n="insertMail"></p>
<form id="send-mail-form" style="margin: 0;">
<input class="mail-form-input" size="35" type="email" name="sendTo">
<input id="mail-form-image" type="hidden" name="image" value="">

<?php if ($config['mail']['send_all_later']): ?>
<input type="checkbox" id="mail-form-send-link" name="send-link" value="yes">
<label data-i18n="sendAllMail" for="mail-form-send-link"></label>
<?php endif; ?>

<button class="mail-form-input btn" name="submit" type="submit" value="Send"><span data-i18n="send"></span></button>
</form>

<div id="mail-form-message" style="max-width: 75%"></div>
</div>
<?php include('template/send-mail.template.php'); ?>

<div class="modal" id="print_mesg">
<div class="modal__body"><span data-i18n="printing"></span></div>
Expand Down
18 changes: 1 addition & 17 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,7 @@

<?php include('template/pswp.template.php'); ?>

<div class="send-mail">
<i class="fa fa-times" id="send-mail-close"></i>
<p data-i18n="insertMail"></p>
<form id="send-mail-form" style="margin: 0;">
<input class="mail-form-input" size="35" type="email" name="sendTo">
<input id="mail-form-image" type="hidden" name="image" value="">

<?php if ($config['mail']['send_all_later']): ?>
<input type="checkbox" id="mail-form-send-link" name="send-link" value="yes">
<label data-i18n="sendAllMail" for="mail-form-send-link"></label>
<?php endif; ?>

<button class="mail-form-input btn rotaryfocus" name="submit" type="submit" value="Send"><span data-i18n="send"></span></button>
</form>

<div id="mail-form-message" style="max-width: 75%"></div>
</div>
<?php include('template/send-mail.template.php'); ?>

<div class="modal" id="print_mesg">
<div class="modal__body"><span data-i18n="printing"></span></div>
Expand Down
18 changes: 1 addition & 17 deletions livechroma.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,7 @@
</div>
<?php include('template/pswp.template.php'); ?>

<div class="send-mail">
<i class="fa fa-times" id="send-mail-close"></i>
<p data-i18n="insertMail"></p>
<form id="send-mail-form" style="margin: 0;">
<input class="mail-form-input" size="35" type="email" name="sendTo">
<input id="mail-form-image" type="hidden" name="image" value="">

<?php if ($config['mail']['send_all_later']): ?>
<input type="checkbox" id="mail-form-send-link" name="send-link" value="yes">
<label data-i18n="sendAllMail" for="mail-form-send-link"></label>
<?php endif; ?>

<button class="mail-form-input btn" name="submit" type="submit" value="Send"><span data-i18n="send"></span></button>
</form>

<div id="mail-form-message" style="max-width: 75%"></div>
</div>
<?php include('template/send-mail.template.php'); ?>

<div class="modal" id="print_mesg">
<div class="modal__body"><span data-i18n="printing"></span></div>
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"abort": "Abort",
"add": "Add",
"admin_panel": "Admin panel",
"adminpanel_back": "Back",
"adminpanel_toggletextOFF": "Off",
Expand Down Expand Up @@ -171,6 +172,7 @@
"githead": "Latest changes",
"home": "Home",
"insertMail": "Enter your e-mail address to receive the photo.",
"insertMailToDB": "Enter your e-mail address to add it into a database. A link to all pictures will be send to you in the next few days.",
"jpeg_quality": "JPEG quality",
"jpeg_quality:jpeg_quality_chroma": "JPEG quality chroma-keying:",
"jpeg_quality:jpeg_quality_image": "JPEG quality images (-1 to disable):",
Expand Down
6 changes: 5 additions & 1 deletion src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,11 @@ const photoBooth = (function () {

setTimeout(function () {
submitButton.show();
submitButton.html('<span>' + photoboothTools.getTranslation('send') + '</span>');
if (config.mail.send_all_later) {
submitButton.html('<span>' + photoboothTools.getTranslation('add') + '</span>');
} else {
submitButton.html('<span>' + photoboothTools.getTranslation('send') + '</span>');
}
}, 5000);
});

Expand Down
23 changes: 23 additions & 0 deletions template/send-mail.template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="send-mail">
<i class="fa fa-times" id="send-mail-close"></i>
<?php if ($config['mail']['send_all_later']): ?>
<p data-i18n="insertMailToDB"></p>
<?php else: ?>
<p data-i18n="insertMail"></p>
<?php endif; ?>
<form id="send-mail-form" style="margin: 0;">
<input class="mail-form-input" size="35" type="email" name="sendTo">
<input id="mail-form-image" type="hidden" name="image" value="">

<?php if ($config['mail']['send_all_later']): ?>
<input type="checkbox" id="mail-form-send-link" name="send-link" checked="checked" value="yes" style="opacity: 0">
<label data-i18n="sendAllMail" for="mail-form-send-link" style="opacity: 0"></label>
<button class="mail-form-input btn rotaryfocus" name="submit" type="submit" value="Send"><span data-i18n="add"></span></button>
<?php else: ?>
<button class="mail-form-input btn rotaryfocus" name="submit" type="submit" value="Send"><span data-i18n="send"></span></button>
<?php endif; ?>

</form>

<div id="mail-form-message" style="max-width: 75%"></div>
</div>