From b366f0474343fc373673a7c2bc73740ea491a44d Mon Sep 17 00:00:00 2001 From: Daniel Reichelt Date: Sat, 17 Sep 2016 08:13:10 +0200 Subject: [PATCH] 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);