From: hickert Date: Wed, 27 Jun 2007 07:15:31 +0000 (+0000) Subject: Added class selector X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f95909e574b7095a22bd1a12c59095872b54727e;p=gosa.git Added class selector git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6710 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_servDNSeditZone.inc b/plugins/admin/systems/class_servDNSeditZone.inc index 4d499e951..3dbfcec3a 100644 --- a/plugins/admin/systems/class_servDNSeditZone.inc +++ b/plugins/admin/systems/class_servDNSeditZone.inc @@ -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); } 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} + + + + +