fix bug where list source was not updated on change

This commit is contained in:
hmrhkr committed 2021-11-10 15:13:53 +01:00
1 parent a04893aed9
commit 649990eeef
3 files changed
+27 -21

No files matched your search

+21 -7
View File
@@ -50,13 +50,27 @@ if ($_SESSION['log'] == 1) {
$sth = $dbh->prepare($eintrag);
$sth->execute(array(':aliasid' => $_POST['editlistid'], ':owner_username' => $maillistownerex[0], ':owner_domain' => $maillistownerex[1]));
}
$abfrage = "SELECT `source` FROM `alias_details` WHERE `id` LIKE :alias_id";
$result = $dbh->prepare($abfrage);
$result->execute(array(':alias_id' => $_POST['editlistid']));
$oldlistsource = $result->fetch()['source']; //bei fetch() werden im Array ['spaltenname'] und [#Nummer der Spalte] angelegt also ['source_username'] und [0] praktische Sache
if ($_SESSION['admin']) {
$newlistsource = explode('@', $_POST['newlistsource']);
} else {
$abfrage = "SELECT `source_username`, `source_domain` FROM `aliases` WHERE `alias_id` LIKE :alias_id";
$result = $dbh->prepare($abfrage);
$result->execute(array(':alias_id' => $_POST['editlistid']));
$newlistsource = $result->fetch(); //bei fetch() werden im Array ['spaltenname'] und [#Nummer der Spalte] angelegt also ['source_username'] und [0] praktische Sache
$newlistsource = $_POST['newlistsource'];
$newlistsourceexp = explode('@', $newlistsource);
if ($newlistsource != $oldlistsource) {
$abfrage = "UPDATE `alias_details` SET `source` = :source WHERE `id` LIKE :alias_id";
$result = $dbh->prepare($abfrage);
$result->execute(array(':source' => $newlistsource, ':alias_id' => $_POST['editlistid']));
$abfrage = "UPDATE `aliases` SET `source_username` = :source_username, `source_domain` = :source_domain WHERE `alias_id` LIKE :alias_id";
$result = $dbh->prepare($abfrage);
$result->execute(array(':source_username' => $newlistsourceexp[0], ':source_domain' => $newlistsourceexp[1], ':alias_id' => $_POST['editlistid']));
}
}
else {
$newlistsource = $oldlistsource;
$newlistsourceexp = explode('@', $newlistsource);
}
$abfrage = "SELECT `id`, `destination_username`, `destination_domain` FROM `aliases` WHERE `alias_id` LIKE :alias_id";
@@ -98,7 +112,7 @@ if ($_SESSION['log'] == 1) {
foreach ($addlistdestinations as $addlistdestination) {
$eintrag = "INSERT INTO `aliases` (`alias_id`, `source_username`, `source_domain`, `destination_username`, `destination_domain`) VALUES (:aliasid, :source_username, :source_domain, :destination_username, :destination_domain)"; // Aliasdaten in MailServer DB eintragen
$sth = $dbh->prepare($eintrag);
$sth->execute(array(':aliasid' => $_POST['editlistid'], ':source_username' => $newlistsource[0], ':source_domain' => $newlistsource[1], ':destination_username' => $addlistdestination[0], ':destination_domain' => $addlistdestination[1]));
$sth->execute(array(':aliasid' => $_POST['editlistid'], ':source_username' => $newlistsourceexp[0], ':source_domain' => $newlistsourceexp[1], ':destination_username' => $addlistdestination[0], ':destination_domain' => $addlistdestination[1]));
}
header("Location: maillistsettings.php");
exit;