"Eins ist toll", "zwei" => "Zwei ist noch besser"); /* attribute list for save action */ var $ignore_account= TRUE; var $attributes = array("DISK_cn","DISK_description"); var $objectclasses= array(); var $DISK_cn = ""; var $DISK_description = ""; var $partitions = array(); var $UsedAttrs = array(); var $is_edit = false; var $old_cn = ""; var $status = "new"; var $deletePartitions = array(); function faiPartitionTableEntry ($config, $dn= NULL,$usedDiskNames=array(),$disk=false) { plugin::plugin ($config, $dn); $this->UsedAttrs = array("cn","description","FAIpartitionType","FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize", "FAImountOptions","FAIfsOptions","FAIpartitionFlags"); /* Default status is new */ $this->status = "new"; /* We want to edit an entry */ if($disk){ /* Set disk status */ $this->status = $disk['status']; /* Walk through partitions */ foreach($disk['partitions'] as $name => $values){ /* If a partition is already marked as delete, attach it to deletePartitions only. */ if($values['status'] == "delete"){ unset($disk['partitions'][$name]); $this->deletePartitions[]=$values; }else{ /* Set status, to know which partition must be deleted from ldap new : Neu partition entry // save edited : Update partition entry in ldap deleted: Remove partition from ldap */ /* If status is not new, set to edit mode. * New means that this partition currently wasn't saved to ldap. */ if($disk['partitions'][$name]['status']!="new"){ $disk['partitions'][$name]['status']="edited"; } $disk['partitions'][$name]['old_cn']= $disk['partitions'][$name]['cn']; /* Assign empty attributes, if attribute is missing */ foreach($this->UsedAttrs as $attr){ if(!isset($values[$attr])){ $disk['partitions'][$name][$attr]=""; } } } } /* Set default attributes */ $this->DISK_cn = $disk['cn']; $this->DISK_description = $disk['description']; $this->partitions = $disk['partitions']; $this->is_edit = true; $this->old_cn = $disk['cn']; } } function execute() { /* Fill templating stuff */ $smarty = get_smarty(); $s_action = ""; $s_entry = ""; $display = ""; /* Assign values * And Checkbox selection */ foreach($this->attributes as $attrs){ $smarty->assign($attrs,$this->$attrs); if($this->$attrs){ $smarty->assign($attrs."CHK"," "); }else{ $smarty->assign($attrs."CHK"," disabled "); } } /* Check all Posts if there is something usefull for us, * For example : Delete is posted as Delete_1 * The number specifies the index we want to delete */ foreach($_POST as $name => $value){ if(preg_match("/Delete_.*/",$name)){ $tmp = split("_",$name); $s_action = "remove"; $s_entry = $tmp[1]; } } /* To remove a partition we unset the index posted. * We must sort the index again, else we possibly got problems * with partitions order. */ if($s_action == "remove"){ if($this->partitions[$s_entry]['status'] == "edited"){ $this->deletePartitions[]= $this->partitions[$s_entry]; unset($this->partitions[$s_entry]); }else{ unset($this->partitions[$s_entry]); } $tmp= array(); foreach($this->partitions as $part){ $tmp[count($tmp)+1]=$part; } $this->partitions = $tmp; } /* To add a partitions we only append an empty * array to the already defined partitions. */ if(isset($_POST['AddPartition'])){ foreach($this->UsedAttrs as $attr){ $tmp[$attr] = ""; } $tmp["old_cn"] = ""; $tmp['status']="new"; $this->partitions[count($this->partitions)+1]=$tmp; } /* $setup contains a table with the partitions. */ $smarty->assign("setup", $this->generateParts()); foreach($this->attributes as $attr){ $smarty->assign($attr,$this->$attr); } /* The user can't change a diskname * if we are currently in edit mode for the specified disk */ // if($this->is_edit){ // $smarty->assign("DISK_cnACL"," disabled "); // }else{ $smarty->assign("DISK_cnACL",""); // } /* Fetch template and show the result */ $display.= $smarty->fetch(get_template_path('faiPartitionTableEntry.tpl', TRUE)); return($display); } function generateParts() { /* Define Arrays with allowed syntax */ $PartitionTypes = array("primary","logical"); $FAIfsTypes = array("ext2","ext3","xfs","swap","reiserfs","dosfat16","winfat32"); /* Display Header */ $str = "
"._("Type")." | "; $str .= ""._("FS type")." | "; $str .= ""._("Mount point")." | "; $str .= ""._("Size in MB")." | "; $str .= ""._("Mount options")." | "; $str .= ""._("FS option")." | "; $str .= ""._("Preserve")." | "; $str .= ""; $str .= " | |
".$PartitionType." | "; $str .= "\n".$FAIfsType." | "; $str .= "\n"; $str .= "\n | "; $str .= "\n | "; $str .= "\n | "; $changeState = "onClick=\"changeState('FAImountPoint_".$key."') ; ". "changeState('FAIpartitionSize_".$key."') ; ". "changeState('FAImountOptions_".$key."') ; ". "changeState('FAIfsType_".$key."') ; ". "changeState('FAIfsOptions_".$key."') ; \""; if($part['FAIpartitionFlags']!=false){ $str .= "\n | "; }else{ $str .= "\n | "; } $str .= "\n | "; $str .= "\n |