Code

Added class selector
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jun 2007 07:15:31 +0000 (07:15 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jun 2007 07:15:31 +0000 (07:15 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6710 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servDNSeditZone.inc
plugins/admin/systems/servdnseditzone.tpl

index 4d499e951f9f8b419ba6d0ee28aa1cdb3595eedf..3dbfcec3a6b049d9bea13755b9fc12fd39691ff1 100644 (file)
@@ -35,6 +35,7 @@ class servdnseditZone extends plugin
 
   var $InitialReverseZone       = "";
   var $InitialzoneName          = "";
+  var $NetworkClass                = "A" ; // One out of A,B,C
 
   var $dialog                   = false;
 
@@ -101,6 +102,20 @@ class servdnseditZone extends plugin
         $this->sOAserial = date("Ymd")."01";
       }
     }
+
+    /* Detect Network class */
+    if(!empty($this->ReverseZone)){
+      $addr = preg_replace("/^[^\/]+\//","",$this->ReverseZone);
+      if(preg_match("/^[0-9]*\.0\.0\.0$/",$addr)){
+        $this->NetworkClass = "A";
+      }
+      if(preg_match("/^[0-9]*\.[0-9]*\.0\.0$/",$addr)){
+        $this->NetworkClass = "B";
+      }
+      if(preg_match("/^[0-9]*\.[0-9]*\.[0-9]*\.0$/",$addr)){
+        $this->NetworkClass = "C";
+      }
+    }
   }
 
   /* TRansports the geiven Arraykey one position up*/
@@ -302,11 +317,11 @@ class servdnseditZone extends plugin
     }
 
     /* Assign records list */
-
-      $smarty->assign("NotNew", false);
-
+    $smarty->assign("NotNew", false);
     $smarty->assign("Mxrecords",  $div->DrawList());
     $smarty->assign("records"  ,  $this->generateRecordsList());
+    $smarty->assign("NetworkClass",  $this->NetworkClass);
+    $smarty->assign("NetworkClasses",  array("A"=>"A","B"=>"B","C"=>"C"));
 
     /* Display tempalte */
     $display.= $smarty->fetch(get_template_path('servdnseditzone.tpl', TRUE));
@@ -335,6 +350,11 @@ class servdnseditZone extends plugin
         $this->Records[$id]['value'] = $_POST['RecordValue_'.$id];
       }
     }
+
+     if(isset($_POST['NetworkClass'])){
+       $this->NetworkClass = $_POST['NetworkClass'];
+     }
+
   }
 
 
@@ -409,6 +429,38 @@ class servdnseditZone extends plugin
         $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']);
       }
     }
+
+    /* Check class for given Zone Address */
+    $addr = preg_replace("/^[^\/]+\//","",$this->ReverseZone);
+
+    /* Check for valid&complete IP address */
+    if(!is_ip($addr)){
+      $message[] = _("The given network address is not a valid, please specify a valid IP address.");
+    }
+  
+    /* Check if given address matches selected network class */
+    switch($this->NetworkClass){
+      case 'A': { 
+                  if(!preg_match("/^[0-9]*\.0\.0\.0$/",$addr)){
+                    $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this was x.0.0.0"));
+                  }
+                }
+                break;
+      case 'B': {
+                  if(!preg_match("/^[0-9]*\.[0-9]*\.0\.0$/",$addr)){
+                    $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this was x.x.0.0"));
+                  }
+                }
+                break;
+      case 'C': {
+                  if(!preg_match("/^[0-9]*\.[0-9]*\.[0-9]*\.0$/",$addr)){
+                    $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this was x.x.x.0"));
+                  }
+                }
+                break;
+      default : $message[] =sprintf(_("The given network class '%s' is not valid."),$this->NetworkClass);
+    }
+
     return ($message);
   }
 
index 8b22244edc57d4eb738060d29e67558e963e4961..99bf1c9c2c225326717098441d625e9af5052295 100644 (file)
                                        <td><input type="text" name="ReverseZone" value="{$ReverseZone}" {if $NotNew} disabled {/if}>
                                        </td>
                                </tr>
+                               <tr>
+                                       <td>{t}Network class{/t}
+                                       </td>
+                                       <td>
+                                               <select name="NetworkClass" {if $NotNew} disabled {/if}>
+                                                       {html_options options=$NetworkClasses selected=$NetworkClass }
+                                               </select>
+                                       </td>
+                               </tr>
                        </table>
                </td>
                <td style="vertical-align:top;">