From 52a7c468ff3574fe15ba4698d9362043352a76b0 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 5 Sep 2007 10:13:45 +0000 Subject: [PATCH] Updated post events git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7228 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/functions_dns.inc | 2 +- plugins/admin/systems/class_servDNS.inc | 25 ++++++++++++++++--- .../admin/systems/class_servDNSeditZone.inc | 5 ++++ .../systems/class_servDNSeditZoneEntries.inc | 9 +++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/include/functions_dns.inc b/include/functions_dns.inc index 9625dab37..4365eb7d4 100644 --- a/include/functions_dns.inc +++ b/include/functions_dns.inc @@ -307,7 +307,7 @@ function getDNSZoneEntriesDiff($config,$newZones,$HostDn) */ foreach($oldZones as $zone) { $oldDn = "zoneName=".$zone['InitialzoneName'].",".$HostDn; - $del[$oldDn] = ""; + $del[$oldDn] = $zone; } /* Check for entries which must be updated diff --git a/plugins/admin/systems/class_servDNS.inc b/plugins/admin/systems/class_servDNS.inc index 93343090c..1fc5d0403 100644 --- a/plugins/admin/systems/class_servDNS.inc +++ b/plugins/admin/systems/class_servDNS.inc @@ -285,6 +285,7 @@ class servdns extends goService { if($this->initially_was_account){ $bool = true; + $this->is_account = FALSE; foreach($this->Zones as $key => $zone){ $bool= $bool & $this->RemoveZone($key); } @@ -330,7 +331,6 @@ class servdns extends goService foreach($tmp['zoneUpdates'] as $dn => $attrs){ $ldap->cd($dn); $ldap->modify($attrs); - $this->handle_post_events("modify",array("dn" => $dn)); new log("modfiy","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); show_ldap_error($ldap->get_error(), sprintf(_("Updating of system server/dns with dn '%s' failed."),$this->dn)); } @@ -339,11 +339,20 @@ class servdns extends goService /* Delete dns */ foreach($tmp['del'] as $dn => $del){ + + $for = getNameFromMix($del['InitialzoneName']); + $rev = FlipIp(getNameFromMix($del['InitialReverseZone'])).".in-addr.arpa"; + $ldap->cd($dn); $ldap->rmdir_recursive($dn); - $this->handle_post_events("remove",array("dn" => $dn)); new log("remove","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/dns with dn '%s' failed."),$this->dn)); + + /* Handle Post events */ + if(preg_match("/^zoneName=/",$dn)){ + $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $for)); + $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $rev)); + } } /* move follwoing entries @@ -360,13 +369,21 @@ class servdns extends goService if($ldap->fetch()){ $ldap->cd($dn); $ldap->modify ($attrs); - $this->handle_post_events("modify",array("dn" => $dn)); show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn)); + + /* Handle Post events */ + if(preg_match("/^zoneName=/",$dn)){ + $this->handle_post_events("modify",array("dn" => $dn,"zoneName" => $attrs['zoneName'])); + } }else{ $ldap->cd($dn); $ldap->add($attrs); - $this->handle_post_events("create",array("dn" => $dn)); show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn)); + + /* Handle Post events */ + if(preg_match("/^zoneName=/",$dn)){ + $this->handle_post_events("add",array("dn" => $dn,"zoneName" => $attrs['zoneName'])); + } } } } diff --git a/plugins/admin/systems/class_servDNSeditZone.inc b/plugins/admin/systems/class_servDNSeditZone.inc index c71fdf67b..1f1ee73a6 100644 --- a/plugins/admin/systems/class_servDNSeditZone.inc +++ b/plugins/admin/systems/class_servDNSeditZone.inc @@ -232,6 +232,11 @@ class servdnseditZone extends plugin } }else{ $this->dialog->save(); + $rev = FlipIp(getNameFromMix($this->InitialReverseZone)).".in-addr.arpa"; + $for = getNameFromMix($this->InitialzoneName); + + $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $rev)); + $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $for)); $this->dialog = false; } } diff --git a/plugins/admin/systems/class_servDNSeditZoneEntries.inc b/plugins/admin/systems/class_servDNSeditZoneEntries.inc index 7eace297a..30e268273 100644 --- a/plugins/admin/systems/class_servDNSeditZoneEntries.inc +++ b/plugins/admin/systems/class_servDNSeditZoneEntries.inc @@ -345,6 +345,9 @@ class servDNSeditZoneEntries extends plugin foreach($tmp['del'] as $dn => $del){ $ldap->cd($dn); $ldap->rmdir_recursive($dn); + if(is_object($this->parent->parent)){ + $this->parent->parent->handle_post_events("remove",array("dn" => $dn)); + } } /* Add || Update new DNS entries @@ -355,9 +358,15 @@ class servDNSeditZoneEntries extends plugin if(count($ldap->fetch())){ $ldap->cd($dn); $ldap->modify ($attrs); + if(is_object($this->parent->parent)){ + $this->parent->parent->handle_post_events("modify",array("dn" => $dn)); + } }else{ $ldap->cd($dn); $ldap->add($attrs); + if(is_object($this->parent->parent)){ + $this->parent->parent->handle_post_events("create",array("dn" => $dn)); + } } } } -- 2.30.2