summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b2bf161)
raw | patch | inline | side by side (parent: b2bf161)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 16 May 2011 06:41:25 +0000 (06:41 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 16 May 2011 06:41:25 +0000 (06:41 +0000) |
-Allow to enter partition size with its unit e.g. 100GB
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20828 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20828 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/goto/admin/systems/goto/Device/class_AddPartitionDialog.inc | patch | blob | history | |
gosa-plugins/goto/admin/systems/goto/Device/class_DevicePartition.inc | patch | blob | history |
diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_AddPartitionDialog.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_AddPartitionDialog.inc
index 76938fb9eaf2cf05360c096b06ea274e8c651e90..dea20dcb355b0cf1607d6698f836353b54d4a3cd 100644 (file)
}
}
+
+ /*! \brief Converts a given size string to its size-value in MB.
+ * E.g. '200TB' => '209715200' MB
+ */
+ function convertSize($size)
+ {
+ $map = array();
+ $map['/mb/i'] = 1;
+ $map['/m/i'] = 1;
+ $map['/gb/i'] = 1024;
+ $map['/g/i'] = 1024;
+ $map['/tb/i'] = 1024;
+ $map['/t/i'] = 1024;
+ $map['/pb/i'] = 1024;
+ $map['/p/i'] = 1024;
+ foreach($map as $key => $multiplicator){
+ if(preg_match($key, $size)){
+ $size = intval(preg_replace("/[^0-9]/", "", $size));
+ return($size * $multiplicator);
+ }
+ }
+ return(intval(preg_replace("/[^0-9]/", $size)));
+ }
+
/*! \brief Stores the changes back to the remote table model.
* @return TRUE on success else false.
$fsOptions = $this->v_fsOptions;
$group = $this->v_group;
$target = $this->v_mountPoint;
- $size = intval($this->v_size);
+ $size = $this->convertSize($this->v_size);
$encrypt = $this->v_encrypt;
$maxSize = NULL;
}
// Collect options
- $size = intval($this->p_size);
+ $size = $this->convertSize($this->p_size);
$maxSize = NULL;
if($this->p_size_options == 2){
$maxSize = $this->p_size_max_value;
diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_DevicePartition.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_DevicePartition.inc
index 5b975365d8106f568257ddf6d306fb5b97b371a9..a8e6da20c0d307121a0407bafe91169eb09da4bf 100644 (file)
function __convertPartSize($size)
{
$label = _("MB");
- if($size%1024 == 0){
- $size = $size/1024;
- $label = _("GB");
- }
- return($size."".$label);
+ return($size." ".$label);
}
}