Code

Updated dns edit zone entries.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 12 Sep 2007 06:56:13 +0000 (06:56 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 12 Sep 2007 06:56:13 +0000 (06:56 +0000)
- Removed 'Add Ptrrecord' icon
- Hide Reverse entries.
- Automatically update and add ptrrecords

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7273 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servDNSeditZoneEntries.inc

index f317e1fb62ad191fa28ef9f5916ff72b8b896ea6..c63aa2b7fae02a12412da6b3cbad0876410a5270 100644 (file)
@@ -29,6 +29,10 @@ class servDNSeditZoneEntries extends plugin
     if(isset($this->RecordTypes['nSRecord'])){
       unset($this->RecordTypes['nSRecord']);
     }
+    /* Remove nSRecord from listed types */
+    if(isset($this->RecordTypes['pTRRecord'])){
+      unset($this->RecordTypes['pTRRecord']);
+    }
 
     $this->dn           = "zoneName=".getNameFromMix($zoneObject['InitialzoneName']).",".$dn; 
     $this->zoneName     = $zoneObject['InitialzoneName'];
@@ -60,7 +64,7 @@ class servDNSeditZoneEntries extends plugin
   {
     plugin::execute();
 
-
+    print_a($this->Devices);
 
     /* Fill templating stuff */
     $smarty= get_smarty();
@@ -83,6 +87,7 @@ class servDNSeditZoneEntries extends plugin
     /* Check posts for operations ...  
      */
     $once = true;
+    $ptr_updates = array();
     foreach($_POST as $name => $value){
 
       /* Add a new Record in given object  
@@ -122,22 +127,6 @@ class servDNSeditZoneEntries extends plugin
           unset($this->Devices[$Name]['RECORDS'][$RecordID]);
         }
       }
-
-      /* Add PTR record 
-       */
-      if((preg_match("/^AddPtr_/",$name)) && ($once)){
-        $once   = false;
-        if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){
-          $tmp = $this->Devices[$Name]['RECORDS'][$RecordID];
-          $ip = $tmp['value'];
-          $match = preg_replace("/^[^\/]*+\//","",$this->reverseName);
-          $ip = preg_replace("/^".normalizePreg($match)."/","",$ip);
-          $ip = preg_replace("/^\./","",$ip);
-          $tmp['type'] = "pTRRecord";
-          $tmp['value'] = $ip;
-          $this->Devices[$Name]['RECORDS'][] = $tmp;
-        }
-      }
     }
 
     /* Possible attributes posted 
@@ -158,7 +147,33 @@ class servDNSeditZoneEntries extends plugin
        */          
       if(preg_match("/ValueSelection_/",$name)){
         if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){
+         
+          /* Update value */ 
+          $old = $this->Devices[$Name]['RECORDS'][$RecordID]['value'];
           $this->Devices[$Name]['RECORDS'][$RecordID]['value'] = $value;
+
+          /* Handle pTRRecord */
+          if(!isset($ptr_updates[$Name]) && $this->Devices[$Name]['RECORDS'][$RecordID]['type'] == "aRecord"){
+    
+            $found = false;
+            $ip = $value;
+            $match = preg_replace("/^[^\/]*+\//","",$this->reverseName);
+            $ip = preg_replace("/^".normalizePreg($match)."/","",$ip);
+            $ip = preg_replace("/^\./","",$ip);
+
+            foreach($this->Devices[$Name]['RECORDS'] as $key => $dev){
+              if($dev['type'] == "pTRRecord"){
+                $ptr_updates[$Name] = $Name;
+                $this->Devices[$Name]['RECORDS'][$key]['value'] = $ip;
+                $found = true;
+                break;
+              }
+            }
+            if(!$found){
+              $dev = array('type'=> 'pTRRecord', 'value' => $ip);
+              $this->Devices[$Name]['RECORDS'][] = $dev;
+            }
+          }
         }
       }
 
@@ -388,6 +403,11 @@ class servDNSeditZoneEntries extends plugin
     $str.= "<table cellspacing='0' cellpadding='0'>";
     foreach($obj['RECORDS'] as $id => $record){
 
+      /* Skip not selectable entries */
+      if(!isset($this->RecordTypes [$record['type']])) {
+        continue;
+      }
+
       /* Create unique post name
        */
       $name = base64_encode($objKey)."|".$id;
@@ -416,12 +436,12 @@ class servDNSeditZoneEntries extends plugin
           <input type='image' name='RemoveRecord_".$name."' src='images/edittrash.png'      alt='"._("Remove")."' title='"._("Remove")."'>
         ";
 
-        if($record['type'] == "aRecord"){
-          $str .="<input type='image' name='AddPtr_".$name."' src='images/network.png' 
-                    alt='"._("Add PTR")."' title='"._("Add PTR record")."'>";
-        }else{
-          $str .= "<img src='images/empty.png' alt=''>";
-        }
+#        if($record['type'] == "aRecord"){
+#          $str .="<input type='image' name='AddPtr_".$name."' src='images/network.png' 
+#                    alt='"._("Add PTR")."' title='"._("Add PTR record")."'>";
+#        }else{
+#          $str .= "<img src='images/empty.png' alt=''>";
+#        }
 
       $str.=
         "</td>