From: hickert Date: Tue, 7 Feb 2006 09:42:38 +0000 (+0000) Subject: REmove : Added check for zones X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=07e70fbbe12ad14a67ffc9af8bbabed70753157e;p=gosa.git REmove : Added check for zones git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2633 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_servDNS.inc b/plugins/admin/systems/class_servDNS.inc index 121b4318a..6039a29bb 100644 --- a/plugins/admin/systems/class_servDNS.inc +++ b/plugins/admin/systems/class_servDNS.inc @@ -134,6 +134,12 @@ class servdns extends plugin $this->DNSinitially_was_account = $this->is_account; } + + /* this is used to flip the ip address for example + 12.3.45 -> 54.3.12 + Because some entries (like zones) are store like that 54.3.12.in-addr.arpa + but we want to display 12.3.45. + */ function FlipIp($ip) { $tmp = array_reverse(split("\.",$ip)); @@ -211,10 +217,30 @@ class servdns extends plugin /* check posts for delete zone */ if(preg_match("/^delZone_/",$name)&&!$once){ + + $once =true; $tmp = preg_replace("/^delZone_/","",$name); $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); - unset($this->Zones[$tmp]); + + $zones = $this->getUsedZoneNames(); + $rev = $this->Zones[$tmp]['ReverseZone']; + $res = array_merge(($zones[$tmp]),($zones[$rev.".in-addr.arpa"])); + + if(count($res)){ + $i = 2; + $str =""; + foreach($res as $dn){ + if($i > 0 ){ + $i --; + $str.=$dn." "; + } + } + if(count($res)> 2) $str .=" ... "; + print_red(sprintf(_("Can't delete the selected zone, because it is still in use by these entry/entries '%s'"),trim($str))); + }else{ + unset($this->Zones[$tmp]); + } } } @@ -248,6 +274,25 @@ class servdns extends plugin return($display); } + + /* This funtion returns all used Zonenames */ + function getUsedZoneNames() + { + $ret = array(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=dNSZone)(!(relativeDomainName=@))(zoneName=*))",array("zoneName","relativeDomainName","tXTRecord")); + while($attr = $ldap->fetch()){ + if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){ + $ret[$attr['zoneName'][0]][] = $attr['dn']; + }else{ + $ret[$attr['zoneName'][0]][] = $attr['dn']; + } + } + return($ret); + } + + /* Remove dns service */ function remove_from_parent() { diff --git a/plugins/admin/systems/class_servDNSeditZone.inc b/plugins/admin/systems/class_servDNSeditZone.inc index 49e904d71..eda11ea19 100644 --- a/plugins/admin/systems/class_servDNSeditZone.inc +++ b/plugins/admin/systems/class_servDNSeditZone.inc @@ -155,6 +155,7 @@ class servdnseditZone extends plugin return ($message); } + /* This funtion returns all used Zonenames */ function getUsedZoneNames() { $ret = array(); @@ -172,7 +173,11 @@ class servdnseditZone extends plugin return($ret); } - + /* this is used to flip the ip address for example + 12.3.45 -> 54.3.12 + Because some entries (like zones) are store like that 54.3.12.in-addr.arpa + but we want to display 12.3.45. + */ function FlipIp($ip) { $tmp = array_reverse(split("\.",$ip)); @@ -195,6 +200,12 @@ class servdnseditZone extends plugin return($ret); } + + /* This function generate a table row for each used record. + This table row displays the recordtype in a select box + and the specified value for the record, and a remove button. + The last element of the table also got an 'add' button. + */ function generateRecordsList($changeStateForRecords="") { $changeStateForRecords = ""; @@ -223,6 +234,10 @@ class servdnseditZone extends plugin return($str); } + /* This function generates a select box out of $this->RecordTypes options. + The Parameter $selected is used to predefine an attribute. + $name is used to specify a post name + */ function generateRecordListBox($selected,$name) { $str = "