From 2f0a68c28087251f02030c1907522aeb5402ff9f Mon Sep 17 00:00:00 2001 From: Squidly Date: Fri, 4 Jul 2014 13:46:32 +0200 Subject: [PATCH] Bugfixing domain deletion with update_domains php style ( This might be a ugly hack but who cares about technical debt right ^^ ) --- bureau/class/m_dom.php | 19 +++++++++++++++++-- src/generate_apache_conf.php | 6 ++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php index ac52a9a0..1c2e533d 100644 --- a/bureau/class/m_dom.php +++ b/bureau/class/m_dom.php @@ -1999,7 +1999,7 @@ order by $r = array(); while ($db->next_record()) { $r[$db->Record['sub_id']] = $db->Record; - } + } return $r; } @@ -2065,7 +2065,7 @@ order by // Initialize duplicate check $check_dup = array(); - $ret = ''; + $ret = "## AlternC Generated conf\n"; foreach ($lst as $p) { // Check if duplicate if (in_array($p['fqdn'], $check_dup)) { @@ -2129,6 +2129,21 @@ order by return true; } + /** + * @param string $domain_id: domain id to delete from database + * called from generate_apacheconf.php after a domain deletion + **/ + function domain_delete() { + global $db,$err; + $err->log("dom", "domain_delete"); + $sql = "delete from domaines where dns_action = 'delete' and domaine not in (select domaine from sub_domaines);"; + if(!$db->query($sql)){ + $err->raise("dom", "Error deleting domain from database"); + return false; + } + return true; + } + /** * @param string $dns_action */ diff --git a/src/generate_apache_conf.php b/src/generate_apache_conf.php index 961c5220..45eabd60 100755 --- a/src/generate_apache_conf.php +++ b/src/generate_apache_conf.php @@ -76,6 +76,12 @@ foreach ( $todo as $taction=>$tlist){ } } +/** +* This function is used to delete a domain from the database +* after all it's sub domains were deleted. +**/ +$dom->domain_delete(); + // Hooks ! foreach (array('DELETE', 'CREATE', 'UPDATE', 'ENABLE', 'DISABLE') as $y) { if (!isset($todo[$y]) || empty($todo[$y])) continue;