Code

Fixed FAI classes
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Aug 2008 11:59:39 +0000 (11:59 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Aug 2008 11:59:39 +0000 (11:59 +0000)
-... 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
gosa-plugins/fai/admin/fai/class_faiHook.inc
gosa-plugins/fai/admin/fai/class_faiHookEntry.inc
gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc
gosa-plugins/fai/admin/fai/class_faiProfile.inc
gosa-plugins/fai/admin/fai/class_faiScript.inc
gosa-plugins/fai/admin/fai/class_faiScriptEntry.inc
gosa-plugins/fai/admin/fai/class_faiTemplate.inc
gosa-plugins/fai/admin/fai/class_faiTemplateEntry.inc
gosa-plugins/fai/admin/fai/class_faiVariable.inc
gosa-plugins/fai/admin/fai/class_faiVariableEntry.inc

index e409a868f98ac9015aad5d11f8a6ad9d90ddf2b5..fedbbfa62c2bab03ec67dffbe1ae1a52e5498bba 100644 (file)
@@ -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"));
     }
 
index 9ae982c296160c1899921f16445f58ffd9faa6cc..141fc5e3d7ba9bb7f94137ebb870736e1a6ef890 100644 (file)
@@ -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])){
index 2fcff5700f066bb83405e6d4f740d552236d8506..d258586bc0f096d64668330c74745186ceb0bb65 100644 (file)
@@ -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);
index caee87bdd1f8f11b96101faebfb6a5fb736612ac..0efc24c103d918707367f568079cf81cc2846e8c 100644 (file)
@@ -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
index 130c00b655d9b208b1df4c786ef294b2fe965801..601b2f1b2dfb296c33990d8753b0d5603dd82355 100644 (file)
@@ -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 
index a76e749ebee431a1e283de37efece9d7b05770a2..fe28af277f9940572a0ab65e8f1a0687cddb5a26 100644 (file)
@@ -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])){
index 91c04d67bfba5905f459772c6d4c756ed264bb56..2667a0de137aebb284d7b18aafdc7723ae9027c9 100644 (file)
@@ -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"));
     }
 
index acff161996f4c5d2444a5821d994d949894e58e2..7b5b94890c6084bf9bf32f385f418473f6a8a8d4 100644 (file)
@@ -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]);
index 5a4ab856b54f5b6ddaaba8496f536f548f0c5fac..b71bf4bce40672b82c6cba1f9605709ee4f2e409 100644 (file)
@@ -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 {
index 1ace86d1b5a4bebbfc1d125d2ce2099f5e3daf0c..c915d1f41b0486ae499b19df1b98b3d47167a4d3 100644 (file)
@@ -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];
index 5ee011c4481d218708c9d8186b8d39bee13eafe8..dd88739559bbda247393bf731682347c82ecd506 100644 (file)
@@ -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);
   }