From a68e1d89a7d3259bf1f0e59d049e897cd797a99e Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 27 Jun 2007 07:08:34 +0000 Subject: [PATCH] Added network class selector git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6708 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/class_servDNSeditZone.inc | 43 +++++++++++++++++-- plugins/admin/systems/servdnseditzone.tpl | 9 ++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/plugins/admin/systems/class_servDNSeditZone.inc b/plugins/admin/systems/class_servDNSeditZone.inc index e8bb14fe0..c80a4c9b5 100644 --- a/plugins/admin/systems/class_servDNSeditZone.inc +++ b/plugins/admin/systems/class_servDNSeditZone.inc @@ -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); } diff --git a/plugins/admin/systems/servdnseditzone.tpl b/plugins/admin/systems/servdnseditzone.tpl index 8b22244ed..99bf1c9c2 100644 --- a/plugins/admin/systems/servdnseditzone.tpl +++ b/plugins/admin/systems/servdnseditzone.tpl @@ -15,6 +15,15 @@ + + {t}Network class{/t} + + + + + -- 2.30.2