From 8e1a1043a5bd9934c8dcb99ac88db0c6c81432fe Mon Sep 17 00:00:00 2001 From: Daniel Reichelt Date: Sat, 17 Sep 2016 07:33:48 +0200 Subject: [PATCH 1/3] don't limit this query to emaildomains ...to catch possibly existing orphaned entries in the mail-user/mail- forwarding tables --- admin_domains.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin_domains.php b/admin_domains.php index c840b277..ded6616e 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -166,7 +166,7 @@ if ($page == 'domains' || $page == 'overview') { $subresult_stmt = Database::prepare(" SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` - WHERE (`id` = :id OR `parentdomainid` = :id " . $rsd_sql . ") AND `isemaildomain` = '1'"); + WHERE (`id` = :id OR `parentdomainid` = :id " . $rsd_sql . ")"); Database::pexecute($subresult_stmt, array( 'id' => $id )); From f3c74bd718be3957b0f362a5a7cd45e6bbc035e2 Mon Sep 17 00:00:00 2001 From: Daniel Reichelt Date: Sat, 17 Sep 2016 07:34:56 +0200 Subject: [PATCH 2/3] remove unused code --- admin_domains.php | 1 - 1 file changed, 1 deletion(-) diff --git a/admin_domains.php b/admin_domains.php index ded6616e..7523e8b7 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -195,7 +195,6 @@ if ($page == 'domains' || $page == 'overview') { Database::pexecute($del_stmt, array( 'id' => $id )); - $deleted_domains = $del_stmt->rowCount(); $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET From b366f0474343fc373673a7c2bc73740ea491a44d Mon Sep 17 00:00:00 2001 From: Daniel Reichelt Date: Sat, 17 Sep 2016 08:13:10 +0200 Subject: [PATCH 3/3] re-assign new main domain to remaining mainbutsubto-domains --- admin_domains.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/admin_domains.php b/admin_domains.php index 7523e8b7..0e7d4fbd 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -189,6 +189,20 @@ if ($page == 'domains' || $page == 'overview') { $log->logAction(ADM_ACTION, LOG_NOTICE, "deleted domain/s from mail-tables"); } + // if mainbutsubto-domains are not to be deleted, re-assign the (ismainbutsubto value of the main + // domain which is being deleted) as their new ismainbutsubto value + if ($remove_subbutmain_domains !== 1) { + $upd_stmt = Database::prepare(" + UPDATE `" . TABLE_PANEL_DOMAINS . "` SET + `ismainbutsubto` = :newIsMainButSubtoValue + WHERE `ismainbutsubto` = :deletedMainDomainId + "); + Database::pexecute($upd_stmt, array( + 'newIsMainButSubtoValue' => $result['ismainbutsubto'], + 'deletedMainDomainId' => $id, + )); + } + $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `id` = :id OR `parentdomainid` = :id " . $rsd_sql);