Code

Updated fai partition stuff
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 7 Aug 2009 10:10:25 +0000 (10:10 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 7 Aug 2009 10:10:25 +0000 (10:10 +0000)
-Fixed handling of disk sizes

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14001 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc
gosa-plugins/fai/admin/fai/class_faiPartition.inc

index 6d4448ee439957c13968cb97f733dd6cefd0c344..4d4b42968e94282fed8bd1ee39c32a21dddafda8 100644 (file)
@@ -701,6 +701,7 @@ class faiDiskEntry extends plugin
     if(preg_match("/[^a-z0-9_\-]/i",$d)){
       $message[] = msgPool::invalid(_("Name"),$d,"/[a-z0-9_\-]/i");
     }
+
     return ($message);
   }
 
index fe1d5277cd3e30fcdcff7025a6cae5e17529b606..059ebda2b7162e13b3b0b4b5c6c27d56ba9d4e60 100644 (file)
@@ -86,14 +86,14 @@ class faiPartition extends plugin
          * remaining                * -
          */
         // Fixed
-        if(preg_match("/^[0-9]*(KB|MB|GB|TB|PB|%)$/",$this->FAIpartitionSize)){
+        if(preg_match("/^[0-9]{1,}(KB|MB|GB|TB|PB|%|)$/",$this->FAIpartitionSize)){
           $this->sizeStart = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\1",$this->FAIpartitionSize);
           $this->sizeStart_Type = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\2",$this->FAIpartitionSize);
           $this->FAIpartitionSizeType = "fixed";
         }else
 
         // Dynamic range
-        if(preg_match("/^[0-9]*(KB|MB|GB|TB|PB|%)-[0-9]*(KB|MB|GB|TB|PB|%)$/",$this->FAIpartitionSize)){
+        if(preg_match("/^[0-9]{1,}(KB|MB|GB|TB|PB|%|)-[0-9]{1,}(KB|MB|GB|TB|PB|%|)$/",$this->FAIpartitionSize)){
           $this->sizeStart = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%).*$/","\\1",$this->FAIpartitionSize);
           $this->sizeStart_Type = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%).*$/","\\2",$this->FAIpartitionSize);
           $this->sizeStop = preg_replace("/^[^\-]*\-([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\1",$this->FAIpartitionSize);
@@ -102,9 +102,16 @@ class faiPartition extends plugin
         }else
 
         // Dynamic range
-        if(preg_match("/^\-$/",$this->FAIpartitionSize)){
+        if(preg_match("/^(0|)\-$/",$this->FAIpartitionSize)){
           $this->FAIpartitionSizeType = "remaining";
+        }
 
+        // Ensure that we've a valid value type selected.
+        if(!preg_match("/(KB|MB|GB|TB|PB|%)/",$this->sizeStart_Type)){
+          $this->sizeStart_Type = "MB";
+        }
+        if(!preg_match("/(KB|MB|GB|TB|PB|%)/",$this->sizeStop_Type)){
+          $this->sizeStop_Type = "MB";
         }
 
         /* Check for encrypted partitions
@@ -405,7 +412,7 @@ class faiPartition extends plugin
           $ret['FAIpartitionSize'] = $this->sizeStart.$this->sizeStart_Type."-".  
             $this->sizeStop.$this->sizeStop_Type;break; 
         case 'remaining' : 
-          $ret['FAIpartitionSize'] = "-";break; 
+          $ret['FAIpartitionSize'] = "0-";break; 
         default: trigger_error("Unknown partition size!");
       }