X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servDNSeditZoneEntries.inc;h=152aef84d89f777a32a73cc00590c835cc9c0f42;hb=d6a17677f5553b6ccef1e49bf600d67e02c2773d;hp=1b1f1f9b605382924f3dc11345d379d863cd1a53;hpb=461a4f0bc04bdb89bced2e52f678b2209f6cbae2;p=gosa.git diff --git a/plugins/admin/systems/class_servDNSeditZoneEntries.inc b/plugins/admin/systems/class_servDNSeditZoneEntries.inc index 1b1f1f9b6..152aef84d 100644 --- a/plugins/admin/systems/class_servDNSeditZoneEntries.inc +++ b/plugins/admin/systems/class_servDNSeditZoneEntries.inc @@ -8,198 +8,100 @@ class servDNSeditZoneEntries extends plugin var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes= array("zoneName"); - var $objectclasses= array("whatever"); + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array("whatever"); - var $Devices = array(); - var $InitDevices = array(); + var $Devices = array(); - var $FreeHosts = array(); - var $InitFreeHosts= array(); + var $zoneName = ""; // ZoneName of currently edited Zone + var $reverseName = ""; // ReverseZone of the currently edited Zone - var $zoneName = ""; // ZoneName of currently edited Zone - var $reverseName = ""; // ReverseZone of the currently edited Zone - - var $RecordTypes= array(); // Possible record type. They will be set in contrucktor - // and some types will be added later (cName/Ptr) + var $RecordTypes = array(); // Possible record type. + + var $disableDialog = false; // Dialog will be disabled, if this zone is new - function servDNSeditZoneEntries ($config, $dn= NULL,$zoneName,$reverseName,$RTypes) + function servDNSeditZoneEntries ($config,$dn, $zoneObject) { plugin::plugin ($config, $dn); /* Initialise class */ - $this->zoneName = $zoneName; - $this->reverseName = $reverseName; - $this->RecordTypes = $RTypes; - - /* Add records types which are not allowed in zones - */ - $this->RecordTypes['cNAMERecord'] = "relativeDomainName"; - $this->RecordTypes['pTRRecord'] = "relativeDomainName"; - $this->RecordTypes['tXTRecord'] = "tXTRecord"; - + $this->RecordTypes = getDnsRecordTypes(); + $this->dn = "zoneName=".$zoneObject['InitialzoneName'].",".$dn; + $this->zoneName = $zoneObject['InitialzoneName']; + $this->reverseName = $zoneObject['InitialReverseZone']; + /* Get ldap connection */ $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); - /* Get all objects using this zone - * Workstations / Terminals - */ - $res = $ldap->search("(&(objectClass=dNSZone)(|(zoneName=".$zoneName.")(zoneName=".$reverseName.".in-addr.arpa))(!(relativeDomainName=@)))"); - while($attrs = $ldap->fetch($res)){ - if(preg_match("/zoneName=/",$attrs['dn'])) continue; - foreach($this->RecordTypes as $atr => $val){ - if((isset($attrs[$atr])) && (is_array($attrs[$atr]))){ - unset($attrs[$val]['count']); - $dn = preg_replace("/^.*,cn/","cn",$attrs['dn']); - $this->Devices[$dn]['RECORDS'][$atr] = $attrs[$val]; - $this->Devices[$dn]['Type'] = "Exists"; - } - } - } - - /* Add additional informations - to all catched objects ( ObjectInformations) - */ - foreach($this->Devices as $dn => $Recs){ - $attrs = $ldap->fetch($ldap->cat($dn,array("objectClass","cn"))); - $this->Devices[$dn]['OBJECT'] = $attrs; - $this->Devices[$dn]['OrigCn'] = $attrs['cn'][0]; - } - - /* Add Free Hand entries - * Free hand entries are entries which are not directly assigned - * to an existing network object like a WS or a Terminal. - * They will be found in a subtree within this zone. - * For example : - * The object name is FreeHand1, - * zoneName=test.de,cn=server ... - * // ObjectContainer - * relativeDomainName=FreeHand1,zoneName=.... - * // Dns entry - * relativeDomainName=FreeHand1, relativeDomainName=FreeHand1,zoneName=.... - * // cName entry .... - * relativeDomainName=terminal12, relativeDomainName=FreeHand1,zone... + /* Get zone content */ - $ldap->cd ("zoneName=".$this->zoneName.",".$this->dn); - $ldap->ls ("(&(objectClass=dNSZone)(!(relativeDomainName=@)))","zoneName=".$this->zoneName.",".$this->dn,array("*")); - - $GetSubInformations = array(); + $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$this->dn,array("relativeDomainName")); + while($attrs = $ldap->fetch()){ - - unset($attrs[$val]['count']); - - $dn = $attrs['dn']; - - /* Split dn into relativeDomainNames - */ - $tmp = split("relativeDomainName=",trim(preg_replace("/,zoneName=.*$/","\\1",$dn))); - $tmp2 = array(); - foreach($tmp as $t){ - if(empty($t)) continue; - $tmp2[] = preg_replace("/,$/","",$t); - } - - /* Set object Name - */ - $cn = $tmp2[0]; - $dn = "relativeDomainName=".$cn.",zoneName=".$this->zoneName.",".$this->dn; - - /* Create entry - */ - $this->Devices[$dn]['OBJECT'] = $attrs; - $this->Devices[$dn]['OBJECT']['cn'][0] = $cn;//attrs['relativeDomainName']; - $this->Devices[$dn]['OBJECT']['OrigCn'] = $cn;//attrs['relativeDomainName'][0]; - $this->Devices[$dn]['Type'] = "Free"; - - $GetSubInformations [] = $dn; + $this->Devices[$attrs['relativeDomainName'][0]] = getDNSHostEntries($config,$attrs['relativeDomainName'][0],true); + $this->Devices[$attrs['relativeDomainName'][0]]['OrigCn'] = $attrs['relativeDomainName'][0]; } - - /* Get sub informations - CName or pTR records are stored in a sub entry. - - // The base entry with aRecords/tXTrecords/.... - relativeDomainName=Keks, relativeDomainName=Keks, zoneName=.... - // And the sub entries like this one - relativeDomainName=10.2.64.in-addr.arpa, relativeDomainName=Keks, zoneName =... - ( They can't be stored in a single entry, so i decided to store them this way ). - */ - foreach($GetSubInformations as $dn){ - $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$dn,array("*")); - while($attrs= $ldap->fetch()){ - foreach($this->RecordTypes as $atr => $val){ - if((isset($attrs[$atr])) && (is_array($attrs[$atr]))){ - unset($attrs[$val]['count']); - $this->Devices[$dn]['RECORDS'][$atr] = $attrs[$val]; - } - } - } + $ldap->cat($this->dn,array("objectClass")); + + $this->disableDialog = true; + if(count($this->Devices)|| $ldap->count()){ + $this->disableDialog = false; } - - $this->Devices; - $this->InitDevices = $this->Devices; } function execute() { - plugin::execute(); + plugin::execute(); + /* Check posts for operations ... */ $once = true; foreach($_POST as $name => $value){ - + /* Add a new Record in given object */ - if((preg_match("/^AddRecord_/",$name)) && ($once)){ - $once = false; - $tmp = preg_replace("/^AddRecord_/","",$name); - $tmp = preg_replace("/_.*$/","",$tmp); - $tmp2 = split("\|",$tmp); - $dn = base64_decode($tmp2[0]); - $record = $tmp2[1]; - $numrec = $tmp2[2]; - - $this->Devices[$dn]['RECORDS'][$record][] = ""; + $tmp = preg_replace("/^.*_(.*)_.*$/","\\1",$name); + $tmp2 = split("\|",$tmp); + + /* Add new host entry + */ + if((preg_match("/^UserRecord_?/",$name)) && ($once)){ + $once = false; + $entry = getDNSHostEntries($this->config,"",true); + $entry['exists'] = true; + $entry['zoneName'] = strtoupper($this->attrs['cn'][0])."/".$this->zoneName; + $entry['RECORDS'][] = array("type" => "aRecord" , "value"=>""); + $this->Devices[_("New entry")] = $entry; } - + + if(count($tmp2) != 2) continue; + + $Name = base64_decode($tmp2[0]); + $RecordID = $tmp2[1]; + + /* Add new REcord + */ + if((preg_match("/^AddRecord_/",$name)) && ($once)){ + $once = false; + $this->Devices[$Name]['RECORDS'][] = $this->Devices[$Name]['RECORDS'][$RecordID]; + } + /* Remove record from given dn */ if((preg_match("/^RemoveRecord_/",$name)) && ($once)){ $once = false; - $tmp = preg_replace("/^RemoveRecord_/","",$name); - $tmp = preg_replace("/_.*$/","",$tmp); - $tmp2 = split("\|",$tmp); - - $dn = base64_decode($tmp2[0]); - $record = $tmp2[1]; - $numrec = $tmp2[2]; - - unset($this->Devices[$dn]['RECORDS'][$record][$numrec]); - - if(count($this->Devices[$dn]['RECORDS'][$record]) == 0){ - unset($this->Devices[$dn]['RECORDS'][$record]); - if(count($this->Devices[$dn]['RECORDS']) ==0){ - unset($this->Devices[$dn]); - } + if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ + unset($this->Devices[$Name]['RECORDS'][$RecordID]); } - - } - - /* Don't know how i should implement this ... - */ - if((preg_match("/^UserRecord_/",$name)) && ($once)){ - $once = false; - $tmp['RECORDS']['aRecord'][0] = 'empty'; - $tmp['Type'] = 'Free'; - $tmp['OBJECT']['cn'][0] = 'Free'; - $this->Devices[] = $tmp; } + } /* Fill templating stuff */ @@ -211,263 +113,159 @@ class servDNSeditZoneEntries extends plugin $table .= $this->generateRecordConfigurationRow($key); } + $smarty->assign("disableDialog",$this->disableDialog); $smarty->assign("table",$table);; $display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE)); return($display); } - - /* Create html table out of given entry - */ - function generateRecordConfigurationRow($obj_dn){ - - /* get some basic inforamtions - */ - $obj = $this->Devices[$obj_dn]; - $objectName = $obj['OBJECT']['cn'][0]; - /* Set title - */ - if($obj['Type'] == "Free"){ - $str = "

".sprintf(_("Settings for free host entry # %s"),($obj_dn +1))." :

"; - }else{ - $str = "

".sprintf(_("Settings for '%s'"),$obj_dn)." :

"; - } - - $hostNameOnce = true; - /* Walk through all defined records + function save_object() + { + /* Possible attributes posted */ - $str.= ""; - foreach($obj['RECORDS'] as $id => $types){ + foreach($_POST as $name => $value){ - /* Create table + /* Extract informations out of post name */ - foreach($types as $key => $type){ + $tmp = preg_replace("/^.*_/","\\1",$name); + $tmp2 = split("\|",$tmp); + + if(count($tmp2) != 2) continue; - /* Create unique post name - */ - $name = base64_encode($obj_dn)."|".$id."|".$key; - - $str .= " - - - - - - "; - } - } - $str .="
"; - - if($hostNameOnce){ - $hostNameOnce = false; - $str .=""; - }else{ - $str .=$objectName; - } - - $str .=" - - ".$this->createRecordTypeSelection($id,$name)." - - - - - - - -
"; - return($str); - } + $Name = base64_decode($tmp2[0]); + $RecordID = $tmp2[1]; - /* Create selectbox with all available option types - */ - function createRecordTypeSelection($id,$refID,$isFreeRecord =false){ - if(!$isFreeRecord){ - $str = "\n"; - } - foreach($this->RecordTypes as $type => $atr) { - if($id == $type){ - $str .="\n"; - }else{ - $str .="\n"; + /* Check for value change + */ + if(preg_match("/ValueSelection_/",$name)){ + if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ + $this->Devices[$Name]['RECORDS'][$RecordID]['value'] = $value; + } } - } - $str.= "\n"; - return($str); - } - function remove_from_parent() - { - } + /* record type changed + */ + if(preg_match("/^RecordTypeSelection_/",$name)){ + if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ + $this->Devices[$Name]['RECORDS'][$RecordID]['type'] = $value; + } + } + } + + /* check for renamed entries + */ + foreach($_POST as $name => $value){ - function save_object() - { - /* Save all form fields - */ + /* Extract informations out of post name + */ + $tmp = preg_replace("/^.*_/","\\1",$name); + $tmp2 = split("\|",$tmp); + + if(count($tmp2) != 2) continue; - /* Possible attributes posted - */ - $actions = array("RenameHost_","ValueSelection_"); - foreach($_POST as $name=>$value){ + $Name = base64_decode($tmp2[0]); + $RecordID = $tmp2[1]; - foreach($actions as $act){ - /* Check if attribute was posted - */ - if(preg_match("/".$act."/",$name)){ - - /* Extract informations out of postname - */ - $action = $act; - $tmp = preg_replace("/^".$action."/","",$name); - $tmp = preg_replace("/_.*$/","",$tmp); - $tmp2 = split("\|",$tmp); - - $dn = base64_decode($tmp2[0]); - $record = $tmp2[1]; - $numrec = $tmp2[2]; - - // entry value was psoted - if($act == "ValueSelection_"){ - $this->Devices[$dn]['RECORDS'][$record][$numrec] = $value; - }elseif($act == "RenameHost_"){ - $tmp = array(); - foreach($this->Devices as $dnn => $dev){ - if($dn == $dnn){ - continue; - } - if(isset($dev['OrigCn'])){ - $n1 = strtolower($dev['OrigCn']); - $tmp[$n1] = $n1; - } - $n2 = strtolower($dev['OBJECT']['cn'][0]); - $tmp[$n2] = $n2; - } + /* Host renamed + */ + if(preg_match("/RenameHost_/",$name)){ + if((isset($this->Devices[$Name])) && ($Name != $value)){ - if(!isset($tmp[strtolower($value)])){ - $this->Devices[$dn]['OBJECT']['cn'][0] = $value; - } + if(isset($this->Devices[$value])){ + print_red(sprintf(_("Can't rename '%s' to '%s' there is already an entry with the same name in our zone editing dialog."),$Name,$value)); + }else{ + $this->Devices[$value] = $this->Devices[$Name]; + unset($this->Devices[$Name]); } } } } - foreach($_POST as $name => $value){ - - /* Check if attribute was posted - */ - if(preg_match("/^RecordTypeSelection_/",$name)){ - - /* Extract informations out of postname - */ - $action = "RecordTypeSelection_"; - $tmp = preg_replace("/^".$action."/","",$name); - $tmp = preg_replace("/_.*$/","",$tmp); - $tmp2 = split("\|",$tmp); - - $dn = base64_decode($tmp2[0]); - $record = $tmp2[1]; - $numrec = $tmp2[2]; - - if($record != $value){ - $str = $this->Devices[$dn]['RECORDS'][$record][$numrec]; - unset($this->Devices[$dn]['RECORDS'][$record][$numrec]); - $this->Devices[$dn]['RECORDS'][$value][] = $str; - } - } - } } + /* check something */ function check() { - $message= array(); - + /* Call common method to give check the hook */ + $message= plugin::check(); + $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); - - foreach($this->Devices as $devDN => $device){ - /* check: if given name for Free Hand entry is valid. - * cn exists ? invalid characters ? ... - */ - if($device['Type'] == "Free"){ - $cn = $device['OBJECT']['cn'][0]; + $names = array(); + foreach($this->Devices as $DevName => $device){ - $ldap->search("(cn=".$cn.")",array("cn")); - if($ldap->count()){ - $message[] = sprintf(_("The name '%s' can't be used as free hand entry, the name is already used in this ldap tree."),$cn); - } - } + /* Don't need to check empty values ... */ + if(!count($device['RECORDS'])) continue; /* Checking entry name */ - if(!is_uid($device['OBJECT']['cn'][0])){ - $message[] = sprintf(_("Entry name '%s' contains invalid characters."), $device['OBJECT']['cn'][0]); - + if((!is_uid($DevName)) | (empty($DevName))){ + $message[] = sprintf(_("Entry name '%s' contains invalid characters."), $DevName); } - /* Check if we have renamed the server, hich we are currently editing. - * reset the value and display a message. + /* Renaming check for existing devices */ - if(strcmp($devDN,$this->dn) ==0 ){ - $new = $device['OBJECT']['cn'][0]; - $old = $this->InitDevices[$devDN]['OBJECT']['cn'][0]; - - if($new != $old){ - $message[] = sprintf(_("Can't rename the server '%s' to '%s', the server contains this zone."),$old,$new); + if(isset($device['OrigCn']) && ($DevName != $device['OrigCn'] )){ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); + if($ldap->count()){ + $message[] = sprintf(_("Can not rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$DevName); + } + }elseif(!isset($device['OrigCn'])){ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); + if($ldap->count()){ + $message[] = sprintf(_("Can not create '%s',the destination name already exists."),$DevName); } } - - /* Renaming check for existing devices + /* Check names */ - if(($device['Type'] == "Exists") && ($device['OrigCn'] != $device['OBJECT']['cn'][0])){ - $cn = $device['OBJECT']['cn'][0]; - - $ldap->search("(cn=".$cn.")",array("cn")); - if($ldap->count()){ - $message[] = sprintf(_("Can't rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$cn); - } - - if(!is_uid($cn)){ - $message[] = sprintf(_("Can't rename '%s' to '%s',the destination name contains invalid characters."),$device['OrigCn'],$cn); - } + if(!isset($names[$DevName])){ + $names[$DevName] = ""; + }else{ + $message[] = sprintf(_("The name '%s' is used more than once."),$DevName); } + /* Names should be written in lowercase + */ +# if(strtolower($DevName) != $DevName){ +# $message[] = sprintf(_("The host name '%s' should be written in lowercase."), $DevName); +# } + /* Check records */ $singleEntries = array("cNAMERecord","pTRRecord"); + $tmp = array(); $tmp2 = array(); - foreach($device['RECORDS'] as $type => $entries){ - + foreach($device['RECORDS'] as $Num => $Rec){ + /* Check for multiple use of unique record types */ - if((in_array($type,$singleEntries)) && (count($entries) > 1)){ - $message[] = sprintf(_("The record type '%s' is a unique type and can't be defined twice."),$type); + if(in_array($Rec['type'],$singleEntries)){ + if(!isset($tmp[$Rec['type']])){ + $tmp[$Rec['type']] = ""; + }else{ + $message[] = sprintf(_("The record type '%s' is a unique type and can't be defined twice."),$type); + } } /* Check for empty / duplicate entries in record array - */ - $tmp = array(); - foreach($entries as $entry){ - - /* Check for empty records - */ - if(empty($entry)){ - $message[] = sprintf(_("There is an empty '%s' for host '%s'."),$type,$device['OBJECT']['cn'][0]); - } + */ + if(empty($Rec['value'])){ + $message[] = sprintf(_("There is an empty '%s' for host '%s'."),$Rec['type'],$DevName); + } - /* Check for duplicate record entries - */ - if(!isset($tmp[$entry])){ - $tmp[$entry]= 'test'; - }else{ - $message[] = sprintf(_("There is a duplicate entry in '%s' for '%s'."),$type,$device['OBJECT']['cn'][0]); - } + /* Check for duplicate record entries + */ + if(!isset($tmp[$Rec['type']][$Rec['value']])){ + $tmp[$Rec['type']][$Rec['value']] = ""; + }else{ + $message[] = sprintf(_("There is a duplicate entry in '%s' for '%s'."),$Rec['type'],$DevName); } } } @@ -476,25 +274,37 @@ class servDNSeditZoneEntries extends plugin function save() { - /* Set all initial records to array() - This means they will be removed from the entry - if they won't be overwritten + if($this->disableDialog) return; + + $todo = array(); + + /* Create todolist */ - foreach($this->InitDevices as $dn => $obj){ - $attrs[$dn]= array(); - foreach($obj['RECORDS'] as $rectype => $records){ - $attrs[$dn][$rectype] = array(); + foreach($this->Devices as $name => $dev){ + if(isset($dev['OrigCn'])){ + if(count($dev['RECORDS'])){ + $todo[] = getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name); + }else{ + $dev['exists'] = false; + $todo[] = getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name); + } + }else{ + if(count($dev['RECORDS'])){ + $todo[] = getDNSHostEntriesDiff($this->config,"",$dev,$name); + }else{ + $dev['exists'] = false; + $todo[] = getDNSHostEntriesDiff($this->config,"",$dev,$name); + } } } - /* Add new entries - */ - foreach($this->Devices as $dn => $obj){ - foreach($obj['RECORDS'] as $rectype => $records){ - $attrs[$dn][$rectype] = array(); - foreach($records as $rec){ - $attrs[$dn][$rectype][] = $rec; - } + $tmp = array(); + $tmp['del'] = array(); + $tmp['add'] = array(); + $tmp['move'] = array(); + foreach($todo as $to){ + foreach($to as $type => $entries){ + $tmp[$type] = array_merge($tmp[$type],$entries); } } @@ -503,215 +313,111 @@ class servDNSeditZoneEntries extends plugin $ldap = $this->config->get_ldap_link(); $ldap->cd ($this->config->current['BASE']); - /* Generate 'T odo' :-) + /* move follwoing entries */ - $tmp = ($this->generate_LDAP_entries($attrs)); + foreach($tmp['move'] as $src => $dst){ + $this->recursive_move($src,$dst); + } - /* Delete all objects which should be delted - */ - foreach($tmp['del'] as $key => $ntr){ - $ldap->rmdir_recursive($key); + /* Delete dns */ + foreach($tmp['del'] as $dn => $del){ + $ldap->cd($dn); + $ldap->rmdir_recursive($dn); } - /* Add append new / updated entries + /* Add || Update new DNS entries */ - foreach($tmp['addupdate'] as $key => $attrs){ - $ldap->cat($key); - if($ldap->count() > 0){ - $ldap->cd($key); - $ldap->modify($attrs); + foreach($tmp['add'] as $dn => $attrs){ + $ldap->cd($dn); + $ldap->cat($dn, array('dn')); + if(count($ldap->fetch())){ + $ldap->cd($dn); + $ldap->modify ($attrs); }else{ - $ldap->cd($this->config->current['BASE']); - $ldap->cd($key); - $ldap->add($attrs); + $ldap->cd($dn); + $ldap->add($attrs); } - - /* Display errors ... - */ - if($ldap->error != "Success"){ - echo "
".$ldap->error."
"; - print_a($attrs); - echo $key; - } - } - - /* Rename entries - !! Terminals / WS / etc will be renamed too - */ - foreach($tmp['rename'] as $old => $new){ - $ldap->cat($old); - $this->recursive_move($old,$new); } } - /* This function creates an array with following indexs - * 'delete' for all dns which should be deleted recursivly - * 'addupdated' Contains all entries which should be written - * 'rename' Contains all dns which should be renamed + /* Create html table out of given entry */ - function generate_LDAP_entries($objs) - { - - $entries = array(); - $delete = array(); - $rename = array(); + function generateRecordConfigurationRow($objKey){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); + /* Get some basic informations + */ + $obj = $this->Devices[$objKey]; + $objectName = $objKey; - /* these entries are added to base object ... + /* Abort if emtpy */ - $normal = array("mDRecord","aRecord","tXTRecord","mXRecord","hInfoRecord","mInfoRecord","aFSDBRecord","SigRecord","KeyRecord","aAAARecord","nSRecord", - "LocRecord","nXTRecord","sRVRecord","nAPTRRecord","kXRecord","certRecord","a6Record","dSRecord","sSHFPRecord","rRSIGRecord","nSECRecord"); + if(count($obj['RECORDS']) == 0) return ""; - /* Create t odo + /* Set title */ - foreach($objs as $dn => $recs){ + $str= "
"; - /* Check if object must be renamed - */ - if(isset($this->Devices[$dn]['OrigCn'])){ - if($this->Devices[$dn]['OBJECT']['cn'][0] != $this->Devices[$dn]['OrigCn']){ - $newdn = str_replace("cn=".$this->Devices[$dn]['OrigCn'], "cn=".$this->Devices[$dn]['OBJECT']['cn'][0],$this->Devices[$dn]['OBJECT']['dn']); - $rename[$this->Devices[$dn]['OBJECT']['dn']] = $newdn; - $rename["relativeDomainName=".$this->Devices[$dn]['OrigCn'].",".$newdn] = "relativeDomainName=".$this->Devices[$dn]['OBJECT']['cn'][0].",".$newdn; - } - } + $hostNameOnce = true; - /* Get basic info - */ - if(isset($this->Devices[$dn])){ - $obj = $this->Devices[$dn]; - }else{ - $obj = NULL; - } + /* Walk through all defined records + */ + $str.= ""; + foreach($obj['RECORDS'] as $id => $record){ - /* If is valid entry + /* Create unique post name */ - if($obj != NULL){ - - /* Both type must be handled different - * Free / Exists - */ - if($obj["Type"] == "Free"){ - $objectName = $obj['OBJECT']['cn'][0]; - }else{ - $objectName = $obj['OrigCn']; - } + $name = base64_encode($objKey)."|".$id; - - /* If type is Free, check - */ - if($obj['Type'] == "Free"){ - - /* Remove entry, if it was renamed - */ - if(isset($obj['OBJECT']['OrigCn'])){ - if($obj['OBJECT']['cn'][0] != $obj['OBJECT']['OrigCn']){ - $delete["relativeDomainName=".$obj['OBJECT']['OrigCn'].",zoneName=".$this->zoneName.",".$this->dn]=""; - } - } - - /* Add new entry - */ - $dn = "relativeDomainName=".$objectName.",zoneName=".$this->zoneName.",".$this->dn; - $dn2 = $dn; + $str .= " + + + + "; + } + $str .="
\n"; - $ldap->cat($dn); - if($ldap->count() == 0){ - $entries[$dn]['objectClass'] = array("top","dNSZone"); - $entries[$dn]['zoneName'] = $this->zoneName; - $entries[$dn]['relativeDomainName'] = $objectName; - } - } + /* Only first host entry name should be editable + */ + if($hostNameOnce){ + $hostNameOnce = false; + $str .="\n"; } - /* Calculate records ... + /* Create rest. Selectbox, icons ... */ - foreach($recs as $type => $rec){ - - /* Simply add normal entries - */ - if($obj != NULL){ - if(in_array($type,$normal)){ - $ldap->cat('relativeDomainName='.$objectName.','.$dn); - - /* Append objectFrame if object doesn't exists in ldap - */ - if($ldap->count() == 0) { - $entries['relativeDomainName='.$objectName.','.$dn]['objectClass'] = array("top","dNSZone"); - $entries['relativeDomainName='.$objectName.','.$dn]['zoneName'] = $this->zoneName; - $entries['relativeDomainName='.$objectName.','.$dn]['relativeDomainName'] = $objectName; - } - $entries['relativeDomainName='.$objectName.','.$dn][$type] = $rec ; - } + $str .=" + + ".$this->createRecordTypeSelection($record['type'],$name)." + + + + + +
"; + return($str); + } - /* Special handling for cNAMERecords - */ - if($type == "cNAMERecord"){ - - $useDn = $dn; - if($obj['Type'] == "Free"){ - $useDn = $dn2; - } - - if(isset($this->InitDevices[$useDn]['RECORDS']['cNAMERecord'])){ - foreach($this->InitDevices[$useDn]['RECORDS']['cNAMERecord'] as $warmal){ - $delete['relativeDomainName='.$warmal.','.$useDn] = ""; - } - } - foreach($rec as $r){ - if(!empty($r)){ - $entries['relativeDomainName='.$r.','.$useDn]['objectClass'] = array("top","dNSZone"); - $entries['relativeDomainName='.$r.','.$useDn]['zoneName'] = $this->zoneName; - $entries['relativeDomainName='.$r.','.$useDn]['cNAMERecord'] = $objectName; - $entries['relativeDomainName='.$r.','.$useDn]['relativeDomainName'] = $r; - } - } - } - /* Special handling for ptrrecord - */ - if($type == "pTRRecord"){ - - $useDn = $dn; - if($obj['Type'] == "Free"){ - $useDn = $dn2; - } - - if(isset($this->InitDevices[$dn]['RECORDS']['pTRRecord'])){ - foreach($this->InitDevices[$dn]['RECORDS']['pTRRecord'] as $warmal){ - $delete['relativeDomainName='.$warmal.','.$useDn] = ""; - } - } - foreach($rec as $r){ - if(!empty($r)){ - $entries['relativeDomainName='.$r.','.$useDn]['pTRRecord'] = $objectName; - $entries['relativeDomainName='.$r.','.$useDn]['zoneName'] = $this->reverseName.".in-addr.arpa"; - $entries['relativeDomainName='.$r.','.$useDn]['relativeDomainName'] = $r; - $entries['relativeDomainName='.$r.','.$useDn]['objectClass'] = array("top","dNSZone"); - } - } - } - } - if($obj == NULL){ - $obj = $this->InitDevices[$dn]; - if($obj['Type'] == "Free"){ - $delete['relativeDomainName='.$objectName.','.$dn] = ""; - }else{ - $ldap->cd($dn); - $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$dn,array("relativeDomainName")); - while($attrs = $ldap->fetch()){ - $delete[$attrs['dn']] = ""; - } - } - } + /* Create selectbox with all available option types + */ + function createRecordTypeSelection($id,$refID){ + $str = "\n"; + return($str); + } + + + function remove_from_parent() + { } }