Bugfixing domain deletion with update_domains php style ( This might be a ugly hack but who cares about technical debt right ^^ )

This commit is contained in:
Squidly 2014-07-04 13:46:32 +02:00
parent fa31340baa
commit 2f0a68c280
2 changed files with 23 additions and 2 deletions

View File

@ -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
*/

View File

@ -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;