Remove now unneeded form requirements
This commit is contained in:
parent
d3a9bc8ca8
commit
48899f307c
@ -7,11 +7,7 @@
|
||||
$data = json_decode($postData, true);
|
||||
|
||||
if (
|
||||
!isset($data["days"]) || $data['days'] == "" ||
|
||||
!isset($data["smtpaddress"]) || $data["smtpaddress"] == "" ||
|
||||
!isset($data["smtpport"]) || $data["smtpport"] == "" ||
|
||||
!isset($data["smtpusername"]) || $data["smtpusername"] == "" ||
|
||||
!isset($data["smtppassword"]) || $data["smtppassword"] == ""
|
||||
!isset($data["days"]) || $data['days'] == ""
|
||||
) {
|
||||
$response = [
|
||||
"success" => false,
|
||||
@ -21,19 +17,10 @@
|
||||
} else {
|
||||
$enabled = $data["enabled"];
|
||||
$days = $data["days"];
|
||||
$smtpAddress = $data["smtpaddress"];
|
||||
$smtpPort = $data["smtpport"];
|
||||
$encryption = "tls";
|
||||
if (isset($data["encryption"])) {
|
||||
$encryption = $data["encryption"];
|
||||
}
|
||||
$smtpUsername = $data["smtpusername"];
|
||||
$smtpPassword = $data["smtppassword"];
|
||||
$fromEmail = $data["fromemail"];
|
||||
|
||||
$query = "SELECT COUNT(*) FROM notifications";
|
||||
$result = $db->querySingle($query);
|
||||
|
||||
|
||||
if ($result === false) {
|
||||
$response = [
|
||||
"success" => false,
|
||||
@ -49,17 +36,17 @@
|
||||
SET enabled = :enabled, days = :days, smtp_address = :smtpAddress, smtp_port = :smtpPort,
|
||||
smtp_username = :smtpUsername, smtp_password = :smtpPassword, from_email = :fromEmail, encryption = :encryption";
|
||||
}
|
||||
|
||||
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindValue(':enabled', $enabled, SQLITE3_INTEGER);
|
||||
$stmt->bindValue(':days', $days, SQLITE3_INTEGER);
|
||||
$stmt->bindValue(':smtpAddress', $smtpAddress, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':smtpPort', $smtpPort, SQLITE3_INTEGER);
|
||||
$stmt->bindValue(':smtpUsername', $smtpUsername, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':smtpPassword', $smtpPassword, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':fromEmail', $fromEmail, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':encryption', $encryption, SQLITE3_TEXT);
|
||||
|
||||
$stmt->bindValue(':smtpAddress', "", SQLITE3_TEXT);
|
||||
$stmt->bindValue(':smtpPort', 1, SQLITE3_INTEGER);
|
||||
$stmt->bindValue(':smtpUsername', "", SQLITE3_TEXT);
|
||||
$stmt->bindValue(':smtpPassword', "", SQLITE3_TEXT);
|
||||
$stmt->bindValue(':fromEmail', "", SQLITE3_TEXT);
|
||||
$stmt->bindValue(':encryption', "", SQLITE3_TEXT);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$response = [
|
||||
"success" => true,
|
||||
|
||||
@ -848,22 +848,10 @@ function saveNotificationsButton() {
|
||||
|
||||
const enabled = document.getElementById("notifications").checked ? 1 : 0;
|
||||
const days = document.getElementById("days").value;
|
||||
const smtpAddress = document.getElementById("smtpaddress").value;
|
||||
const smtpPort = document.getElementById("smtpport").value;
|
||||
const encryption = document.querySelector('input[name="encryption"]:checked').value;
|
||||
const smtpUsername = document.getElementById("smtpusername").value;
|
||||
const smtpPassword = document.getElementById("smtppassword").value;
|
||||
const fromEmail = document.getElementById("fromemail").value;
|
||||
|
||||
const data = {
|
||||
enabled: enabled,
|
||||
days: days,
|
||||
smtpaddress: smtpAddress,
|
||||
smtpport: smtpPort,
|
||||
encryption: encryption,
|
||||
smtpusername: smtpUsername,
|
||||
smtppassword: smtpPassword,
|
||||
fromemail: fromEmail
|
||||
};
|
||||
|
||||
fetch('endpoints/notifications/save.php', {
|
||||
|
||||
26
settings.php
26
settings.php
@ -223,32 +223,8 @@
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group-inline">
|
||||
<input type="text" name="smtpaddress" id="smtpaddress" placeholder="<?= translate('smtp_address', $i18n) ?>" value="<?= $notifications['smtp_address'] ?>" />
|
||||
<input type="text" name="smtpport" id="smtpport" placeholder="<?= translate('port', $i18n) ?>" class="one-third" value="<?= $notifications['smtp_port'] ?>" />
|
||||
</div>
|
||||
<div class="form-group-inline">
|
||||
<input type="radio" name="encryption" id="encryptiontls" value="tls" <?= $notifications['encryption'] == "tls" ? "checked" : "" ?> />
|
||||
<label for="encryptiontls"><?= translate('tls', $i18n) ?></label>
|
||||
<input type="radio" name="encryption" id="encryptionssl" value="ssl" <?= $notifications['encryption'] == "ssl" ? "checked" : "" ?> />
|
||||
<label for="encryptionssl"><?= translate('ssl', $i18n) ?></label>
|
||||
</div>
|
||||
<div class="form-group-inline">
|
||||
<input type="text" name="smtpusername" id="smtpusername" placeholder="<?= translate('smtp_username', $i18n) ?>" value="<?= $notifications['smtp_username'] ?>" />
|
||||
</div>
|
||||
<div class="form-group-inline">
|
||||
<input type="password" name="smtppassword" id="smtppassword" placeholder="<?= translate('smtp_password', $i18n) ?>" value="<?= $notifications['smtp_password'] ?>" />
|
||||
</div>
|
||||
<div class="form-group-inline">
|
||||
<input type="text" name="fromemail" id="fromemail" placeholder="<?= translate('from_email', $i18n) ?>" value="<?= $notifications['from_email'] ?>" />
|
||||
</div>
|
||||
<div class="settings-notes">
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-info"></i> <?= translate('smtp_info', $i18n) ?></p>
|
||||
<p>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<input type="button" class="secondary-button thin" value="<?= translate('test', $i18n) ?>" id="testNotifications" onClick="testNotificationButton()"/>
|
||||
<!-- <input type="button" class="secondary-button thin" value="--><?php //= translate('test', $i18n) ?><!--" id="testNotifications" onClick="testNotificationButton()"/>-->
|
||||
<input type="submit" value="<?= translate('save', $i18n) ?>" id="saveNotifications" onClick="saveNotificationsButton()" class="thin"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user