Code

Do not allow to format or encrypt 'swap', 'pv.' or 'raid.' disks
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 12 May 2011 09:36:12 +0000 (09:36 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 12 May 2011 09:36:12 +0000 (09:36 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20814 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/Device/AddPartitionDialog.tpl
gosa-plugins/goto/admin/systems/goto/Device/class_AddPartitionDialog.inc
gosa-plugins/goto/admin/systems/goto/Device/class_DevicePartition.inc

index 03597c8c6471abb2e85523fba2b0ef3cb6242089..8e077657e210d4ab0b45d9e1fc972338cf43241b 100644 (file)
                     </tr>
                     <tr>
                         <td>{t}Encrypt{/t}</td>
-                        <td><input type="checkbox" name="p_encrypt" {if $p_encrypt_selected} checked {/if}></td>
+                        {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"}
+                            <td><input disabled type="checkbox" name="p_encrypt"></td>
+                        {else}
+                            <td><input type="checkbox" name="p_encrypt" {if $p_encrypt_selected} checked {/if}></td>
+                        {/if}
+                    </tr>
+                    <tr>
+                        <td>{t}Format{/t}</td>
+                        {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"}
+                            <td><input disabled type="checkbox" name="p_format"></td>
+                        {else}
+                            <td><input type="checkbox" name="p_format" {if $p_format_selected} checked {/if}></td>
+                        {/if}
                     </tr>
                 </table>
             </td>
index ce55f3564aed1b8647f599bd4f0ca6249ff0d80a..cef1e124cade1f374ec6add4c88a9d83e8ab7a63 100644 (file)
@@ -48,6 +48,7 @@ class AddPartitionDialog
 
     // Partition properties
     public $p_size = 1000;
+    public $p_format = FALSE;
     public $p_fsType = 'ext3';
     public $p_mountPoint = '';
     public $p_used_disk = array();
@@ -61,7 +62,7 @@ class AddPartitionDialog
 
     // Partitions attributes
     public $p_attributes = array("p_size", "p_fsType", "p_mountPoint", "p_forcePrimary", "p_encrypt", 
-            "p_size_options", "p_size_max_value", "p_used_disk");
+            "p_size_options", "p_size_max_value", "p_used_disk", "p_format");
 
     // Raid device attributes
     public $r_attributes = array("r_fsType", "r_mountPoint", "r_raidLevel", "r_partitions", 
@@ -144,7 +145,7 @@ class AddPartitionDialog
         switch($this->selected_type){
             case PARTITION: {
                     $attrs = $this->p_attributes;
-                    $bool_attrs = array("p_forcePrimary", "p_encrypt");
+                    $bool_attrs = array("p_forcePrimary", "p_encrypt", "p_format");
                     break;
                 }
             case RAID_DEVICE: {
@@ -198,7 +199,7 @@ class AddPartitionDialog
         switch($this->selected_type){
             case PARTITION: {
                     $attrs = $this->p_attributes;
-                    $bool_attrs = array("p_forcePrimary", "p_encrypt");
+                    $bool_attrs = array("p_forcePrimary", "p_encrypt", "p_format");
                     break;
                 }
             case RAID_DEVICE: {
@@ -372,7 +373,7 @@ class AddPartitionDialog
                 $maxSize = $this->p_size_max_value;
             }
             $grow = $this->p_size_options == 1;
-            $format = FALSE;
+            $format = $this->p_format == 1;
             $boot = FALSE;
             $primary = $this->p_forcePrimary;
             $fsType = $this->p_fsType;
@@ -390,6 +391,7 @@ class AddPartitionDialog
                 }
                 $target = $target.str_pad($id, 2, '0', STR_PAD_LEFT);
                 $fsType = $fsOptions = NULL;
+                $encrypt = $format = FALSE;
             }else
 
             // We've to create a raid disk
@@ -401,12 +403,14 @@ class AddPartitionDialog
                 }
                 $target = $target.str_pad($id, 2, '0', STR_PAD_LEFT);
                 $fsType = $fsOptions = NULL;
+                $encrypt = $format = FALSE;
             }else{
             
                 // Add normal-physical partition
                 $target = $this->p_mountPoint;
                 if($fsType == "swap"){
                     $target = "swap";
+                    $encrypt = $format = FALSE;
                 }
             }
 
index 4f18a8bbfbcd4f7cea364c311edf616910a9bd4e..d955479b5719feee0839af0c8d94ca3ce9b78938 100644 (file)
@@ -41,7 +41,8 @@ class DevicePartition
         $this->entryList->setEditable(false);
         $this->entryList->setWidth("100%");
         $this->entryList->setHeight("400px");
-        $this->entryList->setHeader(array(_("Type"),_("Target"),_("Size"),_("Uses device")." / "._("Used by"),_("Filesystem"), _("Options")));
+        $this->entryList->setHeader(array(_("Type"),_("Target"),_("Size"),_("Uses device")." / "._("Used by"),
+                    _("Filesystem"), _("Options"), _("Format"), "-"));
         $this->entryList->setColspecs(array('*','*','*', '*'));
         $this->entryList->setAcl('rwcdm');
         $this->entryList->setReorderable(FALSE);
@@ -231,6 +232,8 @@ class DevicePartition
                             $fsType = trim($fsType); 
                         }
 
+                        $formatImg = ($part['format']) ? image('images/true.png') : "";
+
                         // Add entry to the listing
                         $lData[] = array("data" => array(
                                     $str, 
@@ -238,14 +241,15 @@ class DevicePartition
                                     $this->__convertPartSize($part['size']),
                                     $device,
                                     $fsType,
-                                    $part['fsOptions']));
+                                    $part['fsOptions'],
+                                    $formatImg));
                     }
                 }
             }
         }
 
         // Updated columns length for all entries to avoid render errors.
-        $length = 6;
+        $length = 8;
         foreach($lData as $id => $entry){
             while(count($lData[$id]['data']) < $length){
                 $lData[$id]['data'][] = '';