Code

Updated FAI template entry.
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiPartitionTableEntry.inc
index 2524c97cc6bc3d417fd9c9b686d8b74025b4e695..0efc24c103d918707367f568079cf81cc2846e8c 100644 (file)
@@ -67,9 +67,6 @@ class faiPartitionTableEntry extends plugin
 
           if (preg_match('/^_/', $disk['partitions'][$name]['FAIfsType'])){
             $disk['partitions'][$name]['FAIfsType']= preg_replace('/^_/', '', $disk['partitions'][$name]['FAIfsType']);
-            $disk['partitions'][$name]['FAIencrypted']= true;
-          } else {
-            $disk['partitions'][$name]['FAIencrypted']= false;
           }
         }
       }
@@ -112,7 +109,7 @@ class faiPartitionTableEntry extends plugin
      * The number specifies the index we want to delete
      */
     foreach($_POST as $name => $value){
-      if((preg_match("/Delete_.*/",$name)) && $this->acl_is_removeable()){
+      if((preg_match("/Delete_.*/",$name)) && $this->acl_is_removeable() && !preg_match("/freeze/i",$this->FAIstate)){
         $tmp = split("_",$name);
         $s_action = "remove";
         $s_entry  = $tmp[1]; 
@@ -123,7 +120,7 @@ class faiPartitionTableEntry extends plugin
      * We must sort the index again, else we possibly got problems 
      * with partitions order.
      */
-    if($s_action == "remove" && $this->acl_is_removeable()){
+    if($s_action == "remove" && $this->acl_is_removeable() && !preg_match("/freeze/i",$this->FAIstate)){
       if($this->partitions[$s_entry]['status'] == "edited"){
         $this->deletePartitions[$s_entry]= $this->partitions[$s_entry];
         $this->deletePartitions[$s_entry]['FAIpartitionNr']=$s_entry;
@@ -141,12 +138,11 @@ class faiPartitionTableEntry extends plugin
     /* To add a partitions we only append an empty 
      *  array to the already defined partitions.
      */
-    if(isset($_POST['AddPartition']) && $this->acl_is_createable()){
+    if(isset($_POST['AddPartition']) && $this->acl_is_createable() && !preg_match("/freeze/i",$this->FAIstate)){
       foreach($this->UsedAttrs as $attr){
         $tmp[$attr]                = "";     
       }
       $tmp["old_cn"]               = "";     
-      $tmp["FAIencrypted"] = FALSE;     
       $tmp['status']="new";
       $this->partitions[count($this->partitions)+1]=$tmp;
     }
@@ -161,17 +157,12 @@ class faiPartitionTableEntry extends plugin
     $tmp = $this->plInfo();
     $sacl = "";
     foreach($tmp['plProvidedAcls'] as $name => $translated){
-
-      $acl = $this->getacl($name);
-      $sacl .= $acl;
-      if($this->FAIstate == "freezed"){
-        $acl = preg_replace("/w/","",$acl);
-      }
+      $acl = $this->getacl($name, preg_match("/freeze/i",$this->FAIstate));
       $smarty->assign($name."ACL",$acl);
     }
-    $smarty->assign("allowSave",$sacl);
    
     $smarty->assign("sub_object_is_createable",$this->acl_is_createable());
+    $smarty->assign("freeze",preg_match("/freeze/i",$this->FAIstate));
  
     /* Fetch template and show the result
      */
@@ -196,7 +187,6 @@ class faiPartitionTableEntry extends plugin
       $str .= "<td><b>"._("Mount options")."</b></td>";
       $str .= "<td><b>"._("FS option")."</b></td>";
       $str .= "<td><b>"._("Preserve")."</b></td>";
-      $str .= "<td><b>"._("Encrypted")."</b></td>";
       $str .= "<td>&nbsp;</td>";
       $str .= "</tr>";
     }
@@ -287,22 +277,12 @@ class faiPartitionTableEntry extends plugin
           }else{
             $str .= "\n<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' ".$changeState." ".$disableALL."></td>";
           }
-          if($part['FAIencrypted']!=false){
-            $str .= "\n<td><input type='checkbox' name='FAIencrypted_".$key."' value='encrypted' checked></td>";
-          }else{
-            $str .= "\n<td><input type='checkbox' name='FAIencrypted_".$key."' value='encrypted'></td>";
-          }
         }else{
           if($part['FAIpartitionFlags']!=false){
             $str .= "<td>"._("False")."</td>";
           }else{
             $str .= "<td>"._("True")."</td>";
           }
-          if($part['FAIencrypted']!=false){
-            $str .= "<td>"._("False")."</td>";
-          }else{
-            $str .= "<td>"._("True")."</td>";
-          }
         }
         if($this->acl_is_removeable()){
           $str .= "\n<td><input type='submit' name='Delete_".$key."' value='"._("Remove")."' ".$disableALL."></td>";    
@@ -327,10 +307,6 @@ class faiPartitionTableEntry extends plugin
 
     /* Attach partitions */
     foreach($this->partitions as $key=>$val) {
-      if (isset($this->partitions[$key]['FAIencrypted']) && $this->partitions[$key]['FAIencrypted']){
-        unset ($this->partitions[$key]['FAIencrypted']);
-        $this->partitions[$key]['FAIfsType']= "_".$this->partitions[$key]['FAIfsType'];
-      }
       $this->partitions[$key]['FAIpartitionNr']=$key;
     }
 
@@ -372,15 +348,6 @@ class faiPartitionTableEntry extends plugin
           }
         }
 
-        if($this->acl_is_writeable("FAIencrypted")){
-
-          if(isset($_POST["FAIencrypted_".$key])){
-            $this->partitions[$key]["FAIencrypted"] = $_POST["FAIencrypted_".$key];
-          }else{
-            $this->partitions[$key]["FAIencrypted"] = false;
-          }
-        }
-
         /* Adapt ext3 to have -j option */
         if ($this->partitions[$key]["FAIfsType"] == "ext3") {
           $this->partitions[$key]["FAIfsOptions"]= preg_replace('/\s*-j\s*/', '', $this->partitions[$key]["FAIfsOptions"]);
@@ -399,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
@@ -452,9 +423,9 @@ class faiPartitionTableEntry extends plugin
                 break;
                 
         case 2:
-                if((!tests::is_id($tmp[0]))&&(!tests::is_id($tmp[1])) &&(!empty($tmp[1]))){
+                if( !tests::is_id($tmp[0]) && !tests::is_id($tmp[1]) && !empty($tmp[1]) ){
                   $message[]= msgPool::invalid(sprintf(_("partition %s size"),$key));
-                }elseif($tmp[0]>=$tmp[1]){
+                }elseif(!empty($tmp[1]) && $tmp[0]>=$tmp[1]){
                   $message[]= msgPool::invalid(sprintf(_("partition %s size"),$key));
                 }
                 break;
@@ -504,7 +475,6 @@ class faiPartitionTableEntry extends plugin
             "FAIpartitionSize"  => _("Partition size"),
             "FAImountOptions"   => _("Mount options"),
             "FAIfsOptions"      => _("File system options"),
-            "FAIencrypted"      => _("File system encryption"),
             "FAIpartitionFlags" => _("Partition flags"))
           ));
   }