X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servDNSeditZone.inc;h=4d499e951f9f8b419ba6d0ee28aa1cdb3595eedf;hb=7a6a428eb1c6534e448094d51bc6a542fe832bb9;hp=2ab894396a8d66bfd86ade6d1b46c51cf0f3f481;hpb=1a7070808b558fa25a8fea2043d4142079d5b7db;p=gosa.git diff --git a/plugins/admin/systems/class_servDNSeditZone.inc b/plugins/admin/systems/class_servDNSeditZone.inc index 2ab894396..4d499e951 100644 --- a/plugins/admin/systems/class_servDNSeditZone.inc +++ b/plugins/admin/systems/class_servDNSeditZone.inc @@ -13,13 +13,11 @@ class servdnseditZone extends plugin "sOAprimary","sOAmail","sOAserial","sOArefresh","sOAretry","sOAexpire","sOAttl"); var $objectclasses = array("whatever"); - var $RecordTypes = array(); + var $RecordTypes = array(); var $ReverseZone = ""; - var $ReverseDN = ""; var $zoneName = ""; var $dNSClass = "IN"; - var $status = "new"; var $sOAprimary = ""; var $sOAmail = ""; @@ -32,34 +30,49 @@ class servdnseditZone extends plugin var $Records = array(); var $mXRecords = array(); - var $InitiallyZoneName = ""; - var $InitiallyReverseZone = ""; - var $isNew = true; + var $OldZoneName = ""; // To detect changes made with this edit + var $OldReverseZone = ""; + + var $InitialReverseZone = ""; + var $InitialzoneName = ""; var $dialog = false; - function servdnseditZone ($config, $dn= NULL,$recordtypes,$attrs = array()) + var $isNew = true; + + var $ZoneObject = array(); + + function servdnseditZone ($config, $dn= NULL,$attrs = array()) { plugin::plugin ($config, $dn); /* All types with required attrs */ - $this->RecordTypes = $recordtypes; + $this->RecordTypes = getDnsRecordTypes(true); if(!count($attrs)){ - $this->InitiallyZoneName = ""; - $this->InitiallyReverseZone = ""; - $this->isNew = true; - $this->sOAserial = date("Ymd")."1"; + $this->OldZoneName = ""; + $this->OldReverseZone = ""; + $this->isNew = true; + $this->sOAserial = date("Ymd")."1"; + + $this->InitialzoneName = "";//$attrs['InitialzoneName']; + $this->InitialReverseZone = "";//$attrs['InitialReverseZone']; }else{ - $this->InitiallyZoneName = $attrs['zoneName']; - $this->InitiallyReverseZone = $attrs['ReverseZone']; + $this->ZoneObject = $attrs; + + $this->OldZoneName = $attrs['zoneName']; + $this->OldReverseZone = $attrs['ReverseZone']; + + $this->InitialzoneName = $attrs['InitialzoneName']; + $this->InitialReverseZone = $attrs['InitialReverseZone']; + $this->isNew = false; foreach($this->attributes as $value){ $this->$value = $attrs[$value]; } - if(isset($attrs['Records'])){ - $this->Records = $attrs['Records']; + if(isset($attrs['RECORDS'])){ + $this->Records = $attrs['RECORDS']; $tmp2 = array(); $usedPrio = array(); @@ -165,11 +178,15 @@ class servdnseditZone extends plugin $smarty= get_smarty(); $display= ""; - /* Open Zone Entry Edit Dialog */ - if(isset($_POST['EditZoneEntries'])){ - $this->dialog= new servDNSeditZoneEntries($this->config,$this->dn,$this->InitiallyZoneName,$this->FlipIp($this->InitiallyReverseZone),$this->RecordTypes); + if(!count($this->ZoneObject)){ + $smarty->assign("AllowZoneEdit" , false); + }else{ + $smarty->assign("AllowZoneEdit" , true); + if(isset($_POST['EditZoneEntries'])){ + $this->dialog= new servDNSeditZoneEntries($this->config,$this->dn,$this->ZoneObject); + } } /* Save Zone Entry Edit Dialog @@ -239,7 +256,7 @@ class servdnseditZone extends plugin } if((isset($_POST['AddMXRecord'])) && (!empty($_POST['StrMXRecord']))){ - $this->mXRecords[] = array("type"=>"mXRecord","inittype"=>"","value"=>trim($_POST['StrMXRecord']),"status"=>"new"); + $this->mXRecords[] = array("type"=>"mXRecord","value"=>trim($_POST['StrMXRecord'])); } /* Handle Post events */ @@ -250,17 +267,13 @@ class servdnseditZone extends plugin if((preg_match("/RemoveRecord_/",$name))&&($once)){ $once = false; $id= preg_replace("/RemoveRecord_/","",$name); - if($this->Records[$id]['status']!= "new"){ - $this->Records[$id]['status']= "deleted"; - }else{ - unset($this->Records[$id]); - } + unset($this->Records[$id]); } } /* Add new Zonerecord */ if(isset($_POST['AddNewRecord'])){ - $this->Records[] = array("type"=>"aRecord","inittype"=>"","value"=>"","status"=>"new"); + $this->Records[] = array("type"=>"aRecord","value"=>""); } /* Fill in values */ @@ -328,16 +341,26 @@ class servdnseditZone extends plugin /* Check supplied data */ function check() { - $message= array(); + /* Call common method to give check the hook */ + $message= plugin::check(); + /* Check if zoneName is already in use */ $usedZones = $this->getUsedZoneNames(); - if(($this->isNew == true)||($this->zoneName != $this->InitiallyZoneName)||($this->ReverseZone != $this->InitiallyReverseZone)){ - if((isset($usedZones[$this->zoneName]))&&($this->zoneName != $this->InitiallyZoneName)){ + if(($this->isNew == true)||($this->zoneName != $this->InitialzoneName)||($this->ReverseZone != $this->InitialReverseZone)){ + /* if((isset($usedZones[$this->zoneName]))&&($this->zoneName != $this->InitialzoneName)){ $message[] =_("This zoneName is already in use"); } - if((in_array($this->ReverseZone,$usedZones))&&($this->ReverseZone != $this->InitiallyReverseZone)){ + if((in_array($this->ReverseZone,$usedZones))&&($this->ReverseZone != $this->InitialReverseZone)){ $message[] =_("This reverse zone is already in use"); - } + }*/ + } + + if(empty($this->zoneName)){ + $message[] =sprintf(_("Please choose a valid zone name.")); + } + + if(empty($this->ReverseZone)){ + $message[] =sprintf(_("Please choose a valid reverse zone name.")); } if(!preg_match("/\.$/",$this->sOAprimary)){ @@ -400,7 +423,7 @@ class servdnseditZone extends plugin if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){ if(isset($attr['tXTRecord'][0])){ $zn = preg_replace("/zoneName\=/","",$attr['tXTRecord'][0]); - $ret[$zn] = $this->FlipIp(preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0])); + $ret[$zn] =FlipIp(preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0])); } }else{ $ret[$attr['zoneName'][0]]=""; @@ -409,22 +432,6 @@ 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)); - $new = ""; - foreach($tmp as $section){ - $new .= $section."."; - } - return(preg_replace("/.$/","",$new)); - } - - /* Save to LDAP */ function save() { @@ -440,7 +447,10 @@ class servdnseditZone extends plugin $this->Records [] = $rec; } - $ret['Records'] = $this->Records; + $ret['RECORDS'] = $this->Records; + + $ret['InitialReverseZone']= $this->InitialReverseZone; + $ret['InitialzoneName'] = $this->InitialzoneName; return($ret); } @@ -460,8 +470,6 @@ class servdnseditZone extends plugin if($entry['type'] == "mXRecord") continue; - if($entry['status'] == "deleted") continue; - $changeStateForRecords.= "changeState('RecordTypeSelectedFor_".$key."');\n"; $changeStateForRecords.= "changeState('RecordValue_".$key."');\n"; $changeStateForRecords.= "changeState('RemoveRecord_".$key."');\n";