From 227c0f2f4832e113f7d0cb1d8251e6d98e8ef84f Mon Sep 17 00:00:00 2001 From: cajus Date: Tue, 9 May 2006 11:49:31 +0000 Subject: [PATCH] Fixed problems while saving phones and net devices git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3232 594d385d-05f5-0310-b6e9-bd551577e9d8 --- TODO | 4 ++++ include/functions.inc | 6 +++++ .../admin/systems/class_componentGeneric.inc | 9 ++++++++ plugins/admin/systems/class_phoneGeneric.inc | 23 +++++++------------ 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/TODO b/TODO index 11317ec03..c22c3c563 100644 --- a/TODO +++ b/TODO @@ -30,6 +30,10 @@ Target for 2.4.1: * Fix fai objects to generate tags if needed (sub objects, phone me...) +* Add macAddress replacement for tc's and servers, too + +* What about unitTag's when moving objects? + Target for 2.5: =============== diff --git a/include/functions.inc b/include/functions.inc index e051a3948..92f858105 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -879,6 +879,12 @@ function is_uid($uid) } +function is_ip($ip) +{ + return preg_match("/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/", $ip); +} + + function is_id($id) { if ($id == ""){ diff --git a/plugins/admin/systems/class_componentGeneric.inc b/plugins/admin/systems/class_componentGeneric.inc index 3b1f4168b..7ac18845e 100644 --- a/plugins/admin/systems/class_componentGeneric.inc +++ b/plugins/admin/systems/class_componentGeneric.inc @@ -138,6 +138,15 @@ class componentGeneric extends plugin $message[]= _("The required field 'Component name' is not set."); } + /* To check for valid ip*/ + if($this->netConfigDNS->ipHostNumber == ""){ + $message[]= _("The required field IP address is empty."); + } else { + if (!is_ip($this->netConfigDNS->ipHostNumber)){ + $message[]= _("The field IP address contains an invalid address."); + } + } + $ui= get_userinfo(); $acl= get_permissions ($this->dn, $ui->subtreeACL); $acl= get_module_permission($acl, "component", $this->dn); diff --git a/plugins/admin/systems/class_phoneGeneric.inc b/plugins/admin/systems/class_phoneGeneric.inc index 65cb290a5..000969000 100644 --- a/plugins/admin/systems/class_phoneGeneric.inc +++ b/plugins/admin/systems/class_phoneGeneric.inc @@ -279,20 +279,13 @@ class phoneGeneric extends plugin $this->dn= "cn=".$this->cn.",ou=phones,ou=systems,".$this->base; /* To check for valid ip*/ - $num="(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])"; - -// if(in_array("goFonDefaultIP",$this->usedattrs[$this->selected_categorie])){ -// if (!preg_match("/^$num\\.$num\\.$num\\.$num$/", $this->goFonDefaultIP)){ -// $message[]= _("Wrong IP format in field goFonDefaultIP."); -// } -// } - -// /* Check for valid number */ -// if(in_array("goFonDefaultIP",$this->usedattrs[$this->selected_categorie])){ -// if((strlen($this->goFonQualify))!=(strlen((int)($this->goFonQualify)))){ -// $message[]= _("The given value for 'Response timeout' is not a valid number."); -// } -// } + if($this->netConfigDNS->ipHostNumber == ""){ + $message[]= _("The required field IP address is empty."); + } else { + if (!is_ip($this->netConfigDNS->ipHostNumber)){ + $message[]= _("The field IP address contains an invalid address."); + } + } if ($this->cn == "" && chkacl ($this->acl, "cn") == ""){ $message[]= _("The required field 'Phone name' is not set."); @@ -385,7 +378,7 @@ class phoneGeneric extends plugin $ldap->cd($this->dn); $this->cleanup(); -$ldap->modify ($this->attrs); + $ldap->modify ($this->attrs); // $user_phone_reload $ldap->cd ($this->config->current['BASE']); -- 2.30.2