From a8a1d326e27f8c6c529740415566638c99efac47 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 13 Aug 2008 11:59:39 +0000 Subject: [PATCH] Fixed FAI classes -... to support 0 as object names too. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12208 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-plugins/fai/admin/fai/class_askClassName.inc | 2 +- gosa-plugins/fai/admin/fai/class_faiHook.inc | 2 +- gosa-plugins/fai/admin/fai/class_faiHookEntry.inc | 13 +++++++++---- .../fai/admin/fai/class_faiPartitionTableEntry.inc | 6 +++++- gosa-plugins/fai/admin/fai/class_faiProfile.inc | 4 ++-- gosa-plugins/fai/admin/fai/class_faiScript.inc | 2 +- .../fai/admin/fai/class_faiScriptEntry.inc | 9 +++++++-- gosa-plugins/fai/admin/fai/class_faiTemplate.inc | 2 +- .../fai/admin/fai/class_faiTemplateEntry.inc | 14 ++++++-------- gosa-plugins/fai/admin/fai/class_faiVariable.inc | 2 +- .../fai/admin/fai/class_faiVariableEntry.inc | 8 ++++++-- 11 files changed, 40 insertions(+), 24 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_askClassName.inc b/gosa-plugins/fai/admin/fai/class_askClassName.inc index e409a868f..fedbbfa62 100644 --- a/gosa-plugins/fai/admin/fai/class_askClassName.inc +++ b/gosa-plugins/fai/admin/fai/class_askClassName.inc @@ -142,7 +142,7 @@ class askClassName extends plugin $message[] = msgPool::invalid(_("Name"),preg_replace("/ /","_",$this->ClassName),"/[^_]/"); } - if(empty($this->ClassName)){ + if($this->ClassName == ""){ $message[]= msgPool::required(_("Name")); } diff --git a/gosa-plugins/fai/admin/fai/class_faiHook.inc b/gosa-plugins/fai/admin/fai/class_faiHook.inc index 9ae982c29..141fc5e3d 100644 --- a/gosa-plugins/fai/admin/fai/class_faiHook.inc +++ b/gosa-plugins/fai/admin/fai/class_faiHook.inc @@ -488,7 +488,7 @@ class faiHook extends plugin $tmp = array(); $attributes = array_merge($this->sub_Load_Later,$this->subAttributes); foreach($attributes as $attrs){ - if(empty($obj[$attrs])){ + if($obj[$attrs] == ""){ $obj[$attrs] = array(); } if(!is_array($obj[$attrs])){ diff --git a/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc b/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc index 2fcff5700..d258586bc 100644 --- a/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc @@ -145,12 +145,17 @@ class faiHookEntry extends plugin $message[]= msgPool::duplicated(_("Name")); } - if(empty($this->FAIscript)) { - $message[]= msgPool::required(_("Script")); + $c = trim($this->cn); + if($c == ""){ + $message[] = msgPool::required(_("Name")); + } + if(preg_match("/[^a-z0-9_\-]/i",$c)){ + $message[] = msgPool::invalid(_("Name"),$c,"/[a-z0-9_\-]/i"); } - if(empty($this->cn)){ - $message[]= msgPool::required(_("Name")); + $s = trim($this->FAIscript); + if($s == ""){ + $message[]= msgPool::required(_("Script")); } return ($message); diff --git a/gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc b/gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc index caee87bdd..0efc24c10 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc @@ -366,9 +366,13 @@ class faiPartitionTableEntry extends plugin $message= plugin::check(); /* Check for an empty disk name */ - if(empty($this->DISKcn)){ + $d = trim($this->DISKcn); + if($d == "" ){ $message[] = msgPool::required(_("Name")); } + if(preg_match("/[^a-z0-9_\-]/i",$d)){ + $message[] = msgPool::invalid(_("Name"),$d,"/[a-z0-9_\-]/i"); + } /* check every partition. * if there is an invalid value defined, append an errorstr to message diff --git a/gosa-plugins/fai/admin/fai/class_faiProfile.inc b/gosa-plugins/fai/admin/fai/class_faiProfile.inc index 130c00b65..601b2f1b2 100644 --- a/gosa-plugins/fai/admin/fai/class_faiProfile.inc +++ b/gosa-plugins/fai/admin/fai/class_faiProfile.inc @@ -391,8 +391,8 @@ class faiProfile extends plugin $message[]=_("No class specified for this profile!"); } - if(empty($this->cn)){ - $message[]= msgPool::invalid(_("Name")); + if($this->cn == ""){ + $message[]= msgPool::required(_("Name")); } /* Ensure that we do not overwrite an allready existing entry diff --git a/gosa-plugins/fai/admin/fai/class_faiScript.inc b/gosa-plugins/fai/admin/fai/class_faiScript.inc index a76e749eb..fe28af277 100644 --- a/gosa-plugins/fai/admin/fai/class_faiScript.inc +++ b/gosa-plugins/fai/admin/fai/class_faiScript.inc @@ -543,7 +543,7 @@ class faiScript extends plugin $attributes = array_merge($this->sub_Load_Later,$this->subAttributes); foreach($attributes as $attrs){ - if(empty($obj[$attrs])){ + if($obj[$attrs] == ""){ $obj[$attrs] = array(); } if(!is_array($obj[$attrs])){ diff --git a/gosa-plugins/fai/admin/fai/class_faiScriptEntry.inc b/gosa-plugins/fai/admin/fai/class_faiScriptEntry.inc index 91c04d67b..2667a0de1 100644 --- a/gosa-plugins/fai/admin/fai/class_faiScriptEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiScriptEntry.inc @@ -137,11 +137,16 @@ class faiScriptEntry extends plugin $message[] = msgPool::duplicated(_("Name")); } - if(empty($this->cn)){ + $c = trim($this->cn); + if($c == ""){ $message[] = msgPool::required(_("Name")); } + if(preg_match("/[^a-z0-9_\-]/i",$c)){ + $message[] = msgPool::invalid(_("Name"),$c,"/[a-z0-9_\-]/i"); + } - if(empty($this->FAIscript)){ + $s = trim($this->FAIscript); + if($s == ""){ $message[]= msgPool::required(_("Script")); } diff --git a/gosa-plugins/fai/admin/fai/class_faiTemplate.inc b/gosa-plugins/fai/admin/fai/class_faiTemplate.inc index acff16199..7b5b94890 100644 --- a/gosa-plugins/fai/admin/fai/class_faiTemplate.inc +++ b/gosa-plugins/fai/admin/fai/class_faiTemplate.inc @@ -472,7 +472,7 @@ class faiTemplate extends plugin $tmp = array(); $attributes = array_merge($this->sub_Load_Later,$this->subAttributes); foreach($attributes as $attrs){ - if(empty($obj[$attrs])){ + if($obj[$attrs] == ""){ $obj[$attrs] = array(); } $tmp[$attrs] =($obj[$attrs]); diff --git a/gosa-plugins/fai/admin/fai/class_faiTemplateEntry.inc b/gosa-plugins/fai/admin/fai/class_faiTemplateEntry.inc index 5a4ab856b..b71bf4bce 100644 --- a/gosa-plugins/fai/admin/fai/class_faiTemplateEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiTemplateEntry.inc @@ -200,22 +200,20 @@ class faiTemplateEntry extends plugin $message[]= msgPool::invalid(_("Destination path"),"","","/path"); } - $b = basename($this->FAItemplatePath); - if(empty($b)){ + $b = trim(basename($this->FAItemplatePath)); + if($b == ""){ $message[] = msgPool::required(_("File name")); } - if(empty($this->user)){ + if($this->user == ""){ $message[] = msgPool::required(_("User")); - } - elseif(preg_match("/[^0-9a-z]/i",$this->user)){ + }elseif(preg_match("/[^0-9a-z]/i",$this->user)){ $message[] = msgPool::invalid(_("User"),$this->user,"/[0-9a-z]/"); } - if(empty($this->group)){ + if($this->group == ""){ $message[] = msgPool::required(_("Group")); - } - elseif (!tests::is_uid($this->group)){ + }elseif (!tests::is_uid($this->group)){ if (strict_uid_mode()){ $message[]= msgPool::invalid(_("Group"), $this->group, "/[a-z0-9_-]/"); } else { diff --git a/gosa-plugins/fai/admin/fai/class_faiVariable.inc b/gosa-plugins/fai/admin/fai/class_faiVariable.inc index 1ace86d1b..c915d1f41 100644 --- a/gosa-plugins/fai/admin/fai/class_faiVariable.inc +++ b/gosa-plugins/fai/admin/fai/class_faiVariable.inc @@ -334,7 +334,7 @@ class faiVariable extends plugin $tmp = array(); foreach($this->subAttributes as $attrs){ - if(empty($obj[$attrs])){ + if($obj[$attrs] == ""){ $obj[$attrs] = array(); } $tmp[$attrs] = $obj[$attrs]; diff --git a/gosa-plugins/fai/admin/fai/class_faiVariableEntry.inc b/gosa-plugins/fai/admin/fai/class_faiVariableEntry.inc index 5ee011c44..dd8873955 100644 --- a/gosa-plugins/fai/admin/fai/class_faiVariableEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiVariableEntry.inc @@ -93,10 +93,14 @@ class faiVariableEntry extends plugin if($this->FAIvariableContent == "") { $message[]= msgPool::required(_("Content")); } - - if(empty($this->cn)){ + + $c = trim($this->cn); + if($c == ""){ $message[] = msgPool::required(_("Name")); } + if(preg_match("/[^a-z0-9_\-]/i",$c)){ + $message[] = msgPool::invalid(_("Name"),$c,"/[a-z0-9_\-]/i"); + } return ($message); } -- 2.30.2