Skip to content

Commit

Permalink
mail: add checkbox to add mail address to db
Browse files Browse the repository at this point in the history
Change-Id: I6c33ae08d7e5d0a9b6177aca43dd5b245573a514
  • Loading branch information
andi34 committed Jan 12, 2025
1 parent 2064612 commit 794d189
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api/sendPic.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@
exit();
}

if ($config['mail']['send_all_later']) {
if ($config['mail']['send_all_later'] || isset($_POST['addToDb'])) {
$mailService = MailService::getInstance();
// Save each recipient to the database
foreach ($recipients as $recipient) {
$mailService->addRecipientToDatabase($recipient);
}
echo json_encode(['success' => true, 'saved' => true]);
exit();
if ($config['mail']['send_all_later']) {
echo json_encode(['success' => true, 'saved' => true]);
exit();
}
}

if (empty($_POST['image'])) {
Expand Down
20 changes: 20 additions & 0 deletions assets/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,26 @@ const photoBooth = (function () {
virtualKeyboard.initialize(config.mail.keyboardLayout, '#send-mail-recipient', '#send-mail-form');
}

// add to database on send
if (!config.mail.send_all_later) {
const dbCheckboxWrapper = document.createElement('div');
dbCheckboxWrapper.classList.add('form-db-checkbox-wrapper');

const dbCheckbox = document.createElement('input');
dbCheckbox.type = 'checkbox';
dbCheckbox.id = 'send-mail-db-checkbox';
dbCheckbox.name = 'addToDb';
dbCheckbox.classList.add('form-db-checkbox');

const dbCheckboxLabel = document.createElement('label');
dbCheckboxLabel.htmlFor = 'send-mail-db-checkbox';
dbCheckboxLabel.textContent = ' ' + photoboothTools.getTranslation('add_to_mail_database');

dbCheckboxWrapper.appendChild(dbCheckbox);
dbCheckboxWrapper.appendChild(dbCheckboxLabel);
form.appendChild(dbCheckboxWrapper);
}

// Submit
const submitLabel = config.mail.send_all_later
? photoboothTools.getTranslation('add')
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"abort": "Abort",
"add": "Add",
"add_image": "Add image",
"add_to_mail_database": "save email address(es)",
"admin_panel": "Admin panel",
"adminpanel_back": "Back",
"adminpanel_toggletextOFF": "Off",
Expand Down

0 comments on commit 794d189

Please sign in to comment.