Code

Removed debug output
[gosa.git] / include / functions_dns.inc
index abc92a23645701766b390aa7c11b55620b1eff80..4365eb7d458ae4373f749e0a07db0da2bd8665e6 100644 (file)
@@ -247,6 +247,7 @@ function getDNSZoneEntriesDiff($config,$newZones,$HostDn)
       $soa.=" ".$zone[$attr];
     }  
     $obj['sOARecord'] = trim($soa);
+    $obj['nSRecord'] = $zone['sOAprimary'];
 
     /* If reverse zone was renamed, move entry 
      */
@@ -273,6 +274,9 @@ function getDNSZoneEntriesDiff($config,$newZones,$HostDn)
     /* Add new Records 
      */
     foreach($zone['RECORDS'] as $rec){
+      if(!isset($obj[$rec['type']])||!is_array($obj[$rec['type']])){
+        $obj[$rec['type']] = array();
+      }
       $obj[$rec['type']][] = $rec['value'];
     }
 
@@ -303,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 
@@ -434,6 +438,13 @@ function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName)
   $del    = array();
   $move   = array();
 
+  /* Don't go further if there is nothing to do
+   * Is no account / was no account
+   */
+  if(($newEntry['exists'] == false )&& ($oldEntry['exists'] == false)){
+    return(array("move"=>$move,"add"=>$add,"del"=>$del));
+  }
+
   $zones              = getAvailableZones($config);
   $specialAttributes  = array("cNAMERecord","pTRRecord");
   $newRecords         = array();  // Used to remember which records are removed 
@@ -455,13 +466,6 @@ function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName)
     $newEntry['exists'] = false;
   }
 
-  /* Don't go further if there is nothing to do
-   * Is no account / was no account
-   */
-  if(($newEntry['exists'] == false )&& ($oldEntry['exists'] == false)){
-    return(array("move"=>$move,"add"=>$add,"del"=>$del));
-  }
-  
   /* If account was edited prepare some
    *  attributes & arrays ... if required add some 
    *  dns to $move 
@@ -479,7 +483,7 @@ function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName)
     /* Check if zoneName has changed 
      */   
     if(count($newEntry['RECORDS'])){
-      if($oldEntry['zoneName'] != $zoneName){
+      if($oldEntry['zoneName'] != $newEntry['zoneName']){
         $oldzoneDn = getDNSZoneDN($config,$oldEntry['zoneName']);
         $dn = "relativeDomainName=".$oldName.",".$oldzoneDn;
         $dn2= "relativeDomainName=".$oldName.",".$zoneDn;
@@ -567,7 +571,11 @@ function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName)
       $ptrObj = $baseObj;
       $reverseName = getNameFromMix($reverseNameMix);
       $ptrObj['zoneName']           = $reverseName;
-      $ptrObj['pTRRecord']          = $newName.".".$zoneName.".";
+      if(!preg_match("/\.$/",$newName)){
+        $ptrObj['pTRRecord']          = preg_replace("/\.\.$/",".",$newName.".".$zoneName.".");
+      }else{
+        $ptrObj['pTRRecord']          = preg_replace("/\.\.$/",".",$newName.".");
+      }
       $ptrObj['relativeDomainName'] = $rec['value'];
     
       $add[$PTRdn] = $ptrObj;