diff --git a/plugins/admin/fai/class_faiPartitionTableEntry.inc b/plugins/admin/fai/class_faiPartitionTableEntry.inc
index 64c716be4dd88e6f3274609f8957e33a10e7b65e..cc2c0619c966a059d67f13eb06aaa35dfa0fda1a 100644 (file)
var $status = "new";
var $deletePartitions = array();
+ var $FAIstate = "";
+
function faiPartitionTableEntry ($config, $dn= NULL,$usedDiskNames=array(),$disk=false)
{
plugin::plugin ($config, $dn);
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty = get_smarty();
$s_action = "";
$this->partitions = $tmp;
}
-
/* To add a partitions we only append an empty
* array to the already defined partitions.
*/
$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
*/
$smarty->assign("DISK_cnACL","");
// }
+
+
/* Fetch template and show the result
*/
$display.= $smarty->fetch(get_template_path('faiPartitionTableEntry.tpl', TRUE));
function generateParts()
{
/* Define Arrays with allowed syntax */
- $PartitionTypes = array("primary","logical");
- $FAIfsTypes = array("ext2","ext3","xfs","swap","reiserfs","dos fat 16","win fat 32");
+ $PartitionTypes = array("primary"=>_("primary"),"logical"=>_("logical"));
+ $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>";
* To be able to check the posts later, we append a key to each single postfield. like cn_1 ... cn_2
*/
foreach($this->partitions as $key => $part){
+
+ $dis = "";
+ if($part['FAIpartitionFlags'] == "preserve"){
+ $dis = " disabled ";
+ }
+
+ $disableALL = "";
+ if($this->FAIstate =="freeze"){
+ $disableALL = " disabled ";
+ }
+
if($part['status']!="delete"){
/* Generate Partition select box
*/
- $PartitionType = "<select name='FAIpartitionType_".$key."'>";
- foreach($PartitionTypes as $type){
+ $PartitionType = "<select name='FAIpartitionType_".$key."' id='FAIpartitionType_".$key."' ".$disableALL.">";
+ foreach($PartitionTypes as $type => $PTname){
if($part['FAIpartitionType'] == $type){
- $PartitionType .="<option value='".$type."' selected >".$type."</option>";
+ $PartitionType .="<option value='".$type."' selected >".$PTname."</option>";
}else{
- $PartitionType .="<option value='".$type."'>".$type."</option>";
+ $PartitionType .="<option value='".$type."'>".$PTname."</option>";
}
}
$PartitionType.="</select>";
/* Generate fsType select box
*/
- $FAIfsType= "<select name='FAIfsType_".$key."'>";
+ $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>";
}
$FAIfsType.="</select>";
- $str .= "<tr>";
- $str .= "<td>".$PartitionType."</td>";
- $str .= "<td>".$FAIfsType."</td>";
- $str .= "<td><input name='FAImountPoint_".$key."' value='".$part['FAImountPoint']."' ></td>";
- $str .= "<td><input name='FAIpartitionSize_".$key."' value='".$part['FAIpartitionSize']."' size=12></td>";
- $str .= "<td><input name='FAImountOptions_".$key."' value='".$part['FAImountOptions']."' style='width:100px;'></td>";
- $str .= "<td><input name='FAIfsOptions_".$key."' value='".$part['FAIfsOptions']."' style='width:100px;'></td>";
+ $str .= "\n<tr>";
+ $str .= "\n<td>".$PartitionType."</td>";
+ $str .= "\n<td>".$FAIfsType."</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('FAIfsType_".$key."') ; ".
+ "changeState('FAIfsOptions_".$key."') ; \"";
+
+
if($part['FAIpartitionFlags']!=false){
- $str .= "<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' checked></td>";
+ $str .= "\n<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' checked ".$changeState." ".$disableALL."></td>";
}else{
- $str .= "<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve'></td>";
+ $str .= "\n<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' ".$changeState." ".$disableALL."></td>";
}
- $str .= "<td><input type='submit' name='Delete_".$key."' value='"._("Remove")."'></td>";
- $str .= "</tr>";
+ $str .= "\n<td><input type='submit' name='Delete_".$key."' value='"._("Remove")."' ".$disableALL."></td>";
+ $str .= "\n</tr>";
}
}
$str.="</table>";
$tmp['rename']['from'] = $this->old_cn;
$tmp['rename']['to'] = $this->DISK_cn;
}
-
return($tmp);
}
/* Save data to object */
function save_object()
{
- if(isset($_POST['TableEntryFrameSubmitted'])){
+ if((isset($_POST['TableEntryFrameSubmitted'])) && ($this->FAIstate != "freeze") ){
plugin::save_object();
/* Check base attributes */
/* Check supplied data */
function check()
{
- $message= array();
+ /* Call common method to give check the hook */
+ $message= plugin::check();
- /* Check descriptions
- */
- if(empty($this->DISK_description)){
- $message[] = _("Please enter a description for your disk.");
- }
-
/* check every partition.
* if there is an invalid value defined, append an errorstr to message
*/
}
foreach($this->partitions as $key => $part){
-
- if(in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint'])){
+
+ /* Skip all checks, if preserve is set */
+ if($part['FAIpartitionFlags'] == "preserve"){
+ $this->partitions[$key]['FAIfsType'] = "preserve";
+ $this->partitions[$key]['FAIpartitionSize'] = "preserve";
+ continue;
+ }
+
+ if((in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint']))&&($part['FAIfsType']!="swap")){
$message[]=sprintf(_("please enter a unique mount point for partition %s"),($key));
}
- 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));
+ if($part['FAIfsType']!="swap"){
+ 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));
+ }
}
-
if($part['FAIfsType'] == "swap"){
if(in_array($part['FAIfsType'],$alreadyUsed['FAIfsType'])){
$message[]=sprintf(_("File system type 'swap' is already used, change file system type for partition %s."),$key);
}
}
+ if(($part['FAIfsType'] == "swap")&&(!empty($part['FAImountPoint']))&&($part['FAImountPoint']!="swap")){
+ $message[]=_("Please use 'swap' as mount point, if 'swap' is used as fs-type.");
+ }
$tmp = split("-",$part['FAIpartitionSize']);
switch (count($tmp)){
}
}
+ $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);
}