Code

Added toggling of remove flag for packages
[gosa.git] / plugins / admin / fai / class_faiPartitionTableEntry.inc
index 9b21944a9f51a8dcfaae49021cfd75a9158f4e72..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);
@@ -81,6 +83,9 @@ class faiPartitionTableEntry extends plugin
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Fill templating stuff */
     $smarty     = get_smarty();
     $s_action   = "";
@@ -148,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 
      */
@@ -157,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));
@@ -170,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>";
@@ -196,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."' ".$dis.">";
+        $PartitionType = "<select name='FAIpartitionType_".$key."' id='FAIpartitionType_".$key."' ".$disableALL.">";
         foreach($PartitionTypes as $type){
           if($part['FAIpartitionType'] == $type){
             $PartitionType .="<option value='".$type."' selected >".$type."</option>";
@@ -212,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>";
@@ -225,25 +246,24 @@ 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."') ; ".
                                  "changeState('FAImountOptions_".$key."') ; ".
-                                 "changeState('FAIpartitionType_".$key."') ; ".
                                  "changeState('FAIfsType_".$key."') ; ".
                                  "changeState('FAIfsOptions_".$key."') ; \"";
   
 
         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>";    
       }
     }
@@ -277,7 +297,6 @@ class faiPartitionTableEntry extends plugin
       $tmp['rename']['from']  = $this->old_cn;
       $tmp['rename']['to']    = $this->DISK_cn;
     }
-
     return($tmp);
   }
 
@@ -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
@@ -327,7 +347,6 @@ class faiPartitionTableEntry extends plugin
   
       /* Skip all checks, if preserve is set */ 
       if($part['FAIpartitionFlags'] == "preserve"){
-        $this->partitions[$key]['FAIpartitionType'] = "preserve";
         $this->partitions[$key]['FAIfsType']        = "preserve";
         $this->partitions[$key]['FAIpartitionSize'] = "preserve";
         continue;
@@ -379,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);
   }