diff --git a/public/bin/editlist.php b/public/bin/editlist.php index 914dfdf..9268275 100644 --- a/public/bin/editlist.php +++ b/public/bin/editlist.php @@ -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; diff --git a/public/bin/editlistpre.php b/public/bin/editlistpre.php index 68828fb..4a311a6 100644 --- a/public/bin/editlistpre.php +++ b/public/bin/editlistpre.php @@ -38,20 +38,16 @@ if ($_SESSION['log']) {