Code

Added network class selector
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jun 2007 07:08:34 +0000 (07:08 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jun 2007 07:08:34 +0000 (07:08 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6708 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index e8bb14fe08d6408c7703ea6bb461f9f5aedacce0..c80a4c9b53be730dfdeda6638bebbcf4367a332d 100644 (file)
@@ -30,6 +30,7 @@ class servdnseditZone extends plugin
 
   var $InitialReverseZone       = "";
   var $InitialzoneName          = "";
+  var $NetworkClass                = "A" ; // One out of A,B,C
 
   var $dialog                   = false;
 
@@ -303,11 +304,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));
@@ -328,6 +329,10 @@ class servdnseditZone extends plugin
       }
     }
 
+    if(isset($_POST['NetworkClass'])){
+      $this->NetworkClass = $_POST['NetworkClass'];
+    }
+
     foreach(array("zoneName","ReverseZone") as $attr){
       if(isset($_POST[$attr])){
         $this->$attr = strtoupper($this->cn)."/".$_POST[$attr];
@@ -416,6 +421,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;">