From 2b61d544049468e2be82463ad2e24be0a4403bd5 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 10 Aug 2009 11:41:27 +0000 Subject: [PATCH] Simplified copy & paste for partitions. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14029 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiPartitionTable.inc | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc index f21e5e012..e82838b29 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc @@ -763,37 +763,13 @@ class faiPartitionTable extends plugin /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ - $res = FAI::get_all_objects_for_given_base($source['dn'],"(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))"); - foreach($res as $obj){ - /* Skip not relevant objects */ - if(!preg_match("/".preg_quote($source['dn'], '/')."$/i",$obj['dn'])) continue; - - $objects = array(); - $objects['description'] = ""; - $objects['dn'] = $obj['dn']; - $objects = $this->get_object_attributes($objects,$this->subAttributes); - $this->disks[$objects['cn']] = $objects; - $this->disks[$objects['cn']]['partitions'] = array(); - } - - /* read all partitions for each disk + /* To be sure to copy disks and partitions correctly, just create a + * new PartitionTable object and use the 'disks' attribute + * from this it. This is much easier and less code. */ - foreach($this->disks as $name => $disk){ - $res = FAI::get_all_objects_for_given_base($disk['dn'],"(&(objectClass=FAIclass)(objectClass=FAIpartitionEntry))"); - foreach($res as $obj){ - - /* Skip not relevant objects */ - if(!preg_match("/".preg_quote($disk['dn'], '/')."$/i",$obj['dn'])) continue; - - $objects = array(); - $objects['dn'] = $obj['dn']; - $objects = $this->get_object_attributes($objects,$this->subPartAttributes); - unset($objects['dn']);; - $this->disks[$name]['partitions'][$objects['FAIpartitionNr']] = $objects; - } - } - ksort($this->disks); + $obj = new faiPartitionTable($this->config, $source['dn']); + $this->disks = $obj->disks; } -- 2.30.2