Code

Added toggling of remove flag for packages
[gosa.git] / plugins / admin / fai / class_faiPartitionTableEntry.inc
index c7d71d62c71b8f5177b5c1b31e80830795c87e21..7ff8798d1e152f4f9d5a3a7d3bbb68390113a461 100644 (file)
@@ -22,6 +22,8 @@ class faiPartitionTableEntry extends plugin
   var $status               = "new";
   var $deletePartitions     = array();
 
+  var $FAIstate             = "";
+
   function faiPartitionTableEntry ($config, $dn= NULL,$usedDiskNames=array(),$disk=false)
   {
     plugin::plugin ($config, $dn);
@@ -83,6 +85,7 @@ class faiPartitionTableEntry extends plugin
   {
        /* Call parent execute */
        plugin::execute();
+
     /* Fill templating stuff */
     $smarty     = get_smarty();
     $s_action   = "";
@@ -150,6 +153,15 @@ class faiPartitionTableEntry extends plugin
       $smarty->assign($attr,$this->$attr);
     }
 
+    foreach($this->UsedAttrs as $attr){
+      if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){
+        $smarty->assign($attr."ACL"," disabled ");
+      }else{
+        $smarty->assign($attr."ACL","  ");
+      }
+    }
+
+
     /* The user can't change a diskname 
      *  if we are currently in edit mode for the specified disk 
      */
@@ -159,6 +171,8 @@ class faiPartitionTableEntry extends plugin
       $smarty->assign("DISK_cnACL","");
 //    }
 
+  
+
     /* Fetch template and show the result
      */
     $display.= $smarty->fetch(get_template_path('faiPartitionTableEntry.tpl', TRUE));
@@ -172,7 +186,7 @@ class faiPartitionTableEntry extends plugin
     $FAIfsTypes       = array("ext2","ext3","xfs","swap","reiserfs","dosfat16","winfat32");
 
     /* Display Header */
-    $str = "<table style='width:100%'>";
+    $str = "<table summary='' style='width:100%'>";
     if (count($this->partitions)){
       $str .= "<tr>";
       $str .= "<td>"._("Type")."</td>";
@@ -198,10 +212,15 @@ class faiPartitionTableEntry extends plugin
         $dis = " disabled ";
       }
 
+      $disableALL = "";
+      if($this->FAIstate =="freeze"){
+        $disableALL = " disabled ";
+      }
+
       if($part['status']!="delete"){
         /* Generate Partition select box  
          */
-        $PartitionType = "<select name='FAIpartitionType_".$key."' id='FAIpartitionType_".$key."' >";
+        $PartitionType = "<select name='FAIpartitionType_".$key."' id='FAIpartitionType_".$key."' ".$disableALL.">";
         foreach($PartitionTypes as $type){
           if($part['FAIpartitionType'] == $type){
             $PartitionType .="<option value='".$type."' selected >".$type."</option>";
@@ -214,7 +233,7 @@ class faiPartitionTableEntry extends plugin
 
         /* Generate fsType select box  
          */
-        $FAIfsType= "<select name='FAIfsType_".$key."' id='FAIfsType_".$key."' ".$dis.">";
+        $FAIfsType= "<select name='FAIfsType_".$key."' id='FAIfsType_".$key."' ".$dis." ".$disableALL.">";
         foreach($FAIfsTypes as $type){
           if($part['FAIfsType'] == $type){
             $FAIfsType  .="<option value='".$type."' selected >".$type."</option>";
@@ -227,10 +246,10 @@ class faiPartitionTableEntry extends plugin
         $str .= "\n<tr>";
         $str .= "\n<td>".$PartitionType."</td>";
         $str .= "\n<td>".$FAIfsType."</td>";
-        $str .= "\n<td><input name='FAImountPoint_".$key."'    ".$dis."  value='".$part['FAImountPoint']."'    id='FAImountPoint_".$key."'></td>";
-        $str .= "\n<td><input name='FAIpartitionSize_".$key."'  ".$dis." value='".$part['FAIpartitionSize']."' id='FAIpartitionSize_".$key."' size=12></td>";
-        $str .= "\n<td><input name='FAImountOptions_".$key."'  ".$dis."  value='".$part['FAImountOptions']."'  id='FAImountOptions_".$key."' style='width:100px;'></td>";
-        $str .= "\n<td><input name='FAIfsOptions_".$key."'     ".$dis."  value='".$part['FAIfsOptions']."'     id='FAIfsOptions_".$key."' style='width:100px;'></td>";
+        $str .= "\n<td><input name='FAImountPoint_".$key."'  ".$disableALL."  ".$dis."  value='".$part['FAImountPoint']."'    id='FAImountPoint_".$key."'></td>";
+        $str .= "\n<td><input name='FAIpartitionSize_".$key."' ".$disableALL." ".$dis." value='".$part['FAIpartitionSize']."' id='FAIpartitionSize_".$key."' size=12></td>";
+        $str .= "\n<td><input name='FAImountOptions_".$key."' ".$disableALL."  ".$dis."  value='".$part['FAImountOptions']."'  id='FAImountOptions_".$key."' style='width:100px;'></td>";
+        $str .= "\n<td><input name='FAIfsOptions_".$key."'   ".$disableALL."  ".$dis."  value='".$part['FAIfsOptions']."'     id='FAIfsOptions_".$key."' style='width:100px;'></td>";
 
         $changeState = "onClick=\"changeState('FAImountPoint_".$key."') ; ".
                                  "changeState('FAIpartitionSize_".$key."') ; ".
@@ -240,11 +259,11 @@ class faiPartitionTableEntry extends plugin
   
 
         if($part['FAIpartitionFlags']!=false){
-          $str .= "\n<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' checked ".$changeState."></td>";
+          $str .= "\n<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' checked ".$changeState." ".$disableALL."></td>";
         }else{
-          $str .= "\n<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' ".$changeState."></td>";
+          $str .= "\n<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' ".$changeState." ".$disableALL."></td>";
         }
-        $str .= "\n<td><input type='submit' name='Delete_".$key."' value='"._("Remove")."'></td>";
+        $str .= "\n<td><input type='submit' name='Delete_".$key."' value='"._("Remove")."' ".$disableALL."></td>";
         $str .= "\n</tr>";    
       }
     }
@@ -285,7 +304,7 @@ class faiPartitionTableEntry extends plugin
   /* Save data to object */
   function save_object()
   {
-    if(isset($_POST['TableEntryFrameSubmitted'])){
+    if((isset($_POST['TableEntryFrameSubmitted'])) && ($this->FAIstate != "freeze") ){
       plugin::save_object();
 
       /* Check base attributes */
@@ -311,7 +330,8 @@ class faiPartitionTableEntry extends plugin
   /* Check supplied data */
   function check()
   {
-    $message= array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
    
     /* check every partition.
      * if there is an invalid value defined, append an errorstr to message
@@ -378,6 +398,16 @@ class faiPartitionTableEntry extends plugin
       }      
     }
 
+    $cnt = 0;
+    foreach($this->partitions as $key => $part){
+      if($part['FAIpartitionType'] == "primary"){
+        $cnt ++ ; 
+      }
+    }
+    if($cnt > 3){
+      $message[] = _("You have more than 3 primary partition table entries in your configuration, please check your configuration twice.");
+    }
+
     return ($message);
   }