"Eins ist toll", "zwei" => "Zwei ist noch besser"); /* attribute list for save action */ var $ignore_account= TRUE; var $attributes = array("DISKcn","DISKdescription"); var $objectclasses= array(); var $DISKcn = ""; var $DISKdescription = ""; var $partitions = array(); var $UsedAttrs = array(); var $is_edit = false; var $old_cn = ""; var $status = "new"; var $deletePartitions = array(); var $FAIstate = ""; 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->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(); /* 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)) && $this->acl_is_removeable()){ $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" && $this->acl_is_removeable()){ if($this->partitions[$s_entry]['status'] == "edited"){ $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]); } $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']) && $this->acl_is_createable()){ 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); } $tmp = $this->plInfo(); $sacl = ""; foreach($tmp['plProvidedAcls'] as $name => $translated){ $acl = $this->getacl($name); $sacl .= $acl; if($this->FAIstate == "freezed"){ $acl = preg_replace("/w/","",$acl); } $smarty->assign($name."ACL",$acl); } $smarty->assign("allowSave",$sacl); $smarty->assign("sub_object_is_createable",$this->acl_is_createable()); /* 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"=>_("primary"),"logical"=>_("logical")); $FAIfsTypes = array("ext2","ext3","xfs","swap","reiser","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".$FAImountPoint." | "; $str .= "\n".$FAIpartitionSize." | "; $str .= "\n".$FAImountOptions." | "; $str .= "\n".$FAIfsOptions." | "; $changeState = "onClick=\"changeState('FAImountPoint_".$key."') ; ". "changeState('FAIpartitionSize_".$key."') ; ". "changeState('FAImountOptions_".$key."') ; ". "changeState('FAIfsType_".$key."') ; ". "changeState('FAIfsOptions_".$key."') ; \""; if($this->acl_is_writeable("FAIpartitionFlags")){ if($part['FAIpartitionFlags']!=false){ $str .= "\n"; }else{ $str .= "\n | "; } }else{ if($part['FAIpartitionFlags']!=false){ $str .= " | "._("False")." | "; }else{ $str .= ""._("True")." | "; } } if($this->acl_is_removeable()){ $str .= "\n"; }else{ $str .= "\n | "; } $str .= "\n |