Code

Fixed problem with not clickable buttons in fai package error msgs
[gosa.git] / plugins / admin / fai / class_faiPartitionTableEntry.inc
index bef8d646bb235b2d5499b48498c7a64d2f86d967..1223d9e598e1ed1245dc188074ac4bfb1225d7d2 100644 (file)
@@ -9,11 +9,11 @@ class faiPartitionTableEntry extends plugin
 
   /* attribute list for save action */
   var $ignore_account= TRUE;
-  var $attributes   = array("DISK_cn","DISK_description");
+  var $attributes   = array("DISKcn","DISKdescription");
   var $objectclasses= array();
 
-  var $DISK_cn              = "";
-  var $DISK_description     = "";
+  var $DISKcn              = "";
+  var $DISKdescription     = "";
   
   var $partitions           = array();
   var $UsedAttrs            = array();
@@ -73,18 +73,19 @@ class faiPartitionTableEntry extends plugin
       }
 
       /* Set default attributes */
-      $this->DISK_cn          = $disk['cn'];
-      $this->DISK_description = $disk['description'];
+      $this->DISKcn          = $disk['cn'];
+      $this->DISKdescription = $disk['description'];
       $this->partitions       = $disk['partitions'];
       $this->is_edit          = true;
       $this->old_cn           = $disk['cn'];
     }
   }
 
+
   function execute()
   {
-       /* Call parent execute */
-       plugin::execute();
+    /* Call parent execute */
+    plugin::execute();
 
     /* Fill templating stuff */
     $smarty     = get_smarty();
@@ -122,7 +123,8 @@ class faiPartitionTableEntry extends plugin
      */
     if($s_action == "remove" && $this->acl_is_removeable()){
       if($this->partitions[$s_entry]['status'] == "edited"){
-        $this->deletePartitions[]= $this->partitions[$s_entry];
+        $this->deletePartitions[$s_entry]= $this->partitions[$s_entry];
+        $this->deletePartitions[$s_entry]['FAIpartitionNr']=$s_entry;
         unset($this->partitions[$s_entry]);
       }else{
         unset($this->partitions[$s_entry]);
@@ -178,7 +180,7 @@ class faiPartitionTableEntry extends plugin
   {
     /* Define Arrays with allowed syntax */
     $PartitionTypes   = array("primary"=>_("primary"),"logical"=>_("logical"));
-    $FAIfsTypes       = array("ext2","ext3","xfs","swap","reiserfs","dosfat16","winfat32");
+    $FAIfsTypes       = array("ext2","ext3","xfs","swap","reiser","dosfat16","winfat32");
 
     /* Display Header */
     $str = "<table summary='' style='width:100%'>";
@@ -304,7 +306,7 @@ class faiPartitionTableEntry extends plugin
   function save()
   {
     $tmp = array();
-    $tmp['cn']          = $this->DISK_cn;
+    $tmp['cn']          = $this->DISKcn;
 
     /* Attach partitions */
     foreach($this->partitions as $key=>$val) {
@@ -317,14 +319,14 @@ class faiPartitionTableEntry extends plugin
       $this->partitions[$key."-delete"]['status']="delete";
     }
 
-    $tmp['description'] = $this->DISK_description;
+    $tmp['description'] = $this->DISKdescription;
     $tmp['partitions']  = $this->partitions;
     $tmp['status']      = $this->status;
 
     /* If hdd name has changed, tell partitionTable to rename it */
-    if(($this->is_edit)&&($this->old_cn != $this->DISK_cn)){
+    if(($this->is_edit)&&($this->old_cn != $this->DISKcn)){
       $tmp['rename']['from']  = $this->old_cn;
-      $tmp['rename']['to']    = $this->DISK_cn;
+      $tmp['rename']['to']    = $this->DISKcn;
     }
     return($tmp);
   }
@@ -333,6 +335,8 @@ class faiPartitionTableEntry extends plugin
   /* Save data to object */
   function save_object()
   {
+
+
     if((isset($_POST['TableEntryFrameSubmitted'])) && ($this->FAIstate != "freeze") ){
       plugin::save_object();
 
@@ -358,7 +362,12 @@ class faiPartitionTableEntry extends plugin
   {
     /* Call common method to give check the hook */
     $message= plugin::check();
-   
+  
+    /* Check for an empty disk name */
+    if(empty($this->DISKcn)){
+      $message[] = _("Please specify a valid disc name.");
+    }
+       
     /* check every partition.
      * if there is an invalid value defined, append an errorstr to message
      */
@@ -382,7 +391,7 @@ class faiPartitionTableEntry extends plugin
         $message[]=sprintf(_("please enter a unique mount point for partition %s"),($key));
       }
 
-      if($part['FAIfsType']!="swap"){
+      if($part['FAIfsType']!="swap" && $part['FAImountPoint'] != "-"){
         if((empty($part['FAImountPoint']))||(!((preg_match("/^\/.*/",$part['FAImountPoint']))||(preg_match("/^swap$/",$part['FAImountPoint']))))){
           $message[]=sprintf(_("Please enter a valid mount point for partition %s." ),($key));
         }
@@ -402,13 +411,13 @@ class faiPartitionTableEntry extends plugin
                 $message[]= sprintf(_("Please enter a valid partition size for partition %s."),($key));
                 break;
         case 1:
-                if (!is_id(is_id($tmp[0]))){
+                if (!is_id(is_id($tmp[0])) &&(!empty($tmp[1]))){
                   $message[]= sprintf(_("Please enter a valid partition size for partition %s."),($key));
                 }
                 break;
                 
         case 2:
-                if((!is_id($tmp[0]))||(!is_id($tmp[1]))){
+                if((!is_id($tmp[0]))&&(!is_id($tmp[1])) &&(!empty($tmp[1]))){
                   $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); 
                 }elseif($tmp[0]>=$tmp[1]){
                   $message[]=sprintf(_("Please enter a valid range for partition %s."),($key));
@@ -451,8 +460,8 @@ class faiPartitionTableEntry extends plugin
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
-            "cn"                => _("Name"),
-            "description"       => _("Description"),
+            "DISKcn"           => _("Name"),
+            "DISKdescription"  => _("Description"),
             "FAIpartitionType"  => _("Partition type"),
             "FAIpartitionNr"    => _("Partition no."),
             "FAIfsType"         => _("File system type"),