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:
parent
fa31340baa
commit
2f0a68c280
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue