From ee0d98ece7dc6102d3f734bdfa1a27821ba635f7 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 18 Jul 2008 12:39:49 +0000 Subject: [PATCH] Updated FAI object copy & paste. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11715 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-plugins/fai/admin/fai/class_faiHook.inc | 22 ++---- .../fai/admin/fai/class_faiPartitionTable.inc | 78 +++++++------------ .../fai/admin/fai/class_faiScript.inc | 31 +++----- .../fai/admin/fai/class_faiTemplate.inc | 22 ++---- .../fai/admin/fai/class_faiVariable.inc | 36 +++------ 5 files changed, 56 insertions(+), 133 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiHook.inc b/gosa-plugins/fai/admin/fai/class_faiHook.inc index 246bb7942..589d67933 100644 --- a/gosa-plugins/fai/admin/fai/class_faiHook.inc +++ b/gosa-plugins/fai/admin/fai/class_faiHook.inc @@ -532,29 +532,17 @@ class faiHook extends plugin /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); + $res = FAI::get_all_objects_for_given_base($this->dn,"(&(objectClass=FAIclass)(objectClass=".$this->subClass."))"); + foreach($res as $obj){ - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); + /* Skip not relevant objects */ + if(!preg_match("/".normalizePreg($this->dn)."$/i",$obj['dn'])) continue; - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ $objects = array(); $objects['status'] = "edited"; - $objects['dn'] = $object['dn']; + $objects['dn'] = $obj['dn']; $objects = $this->get_object_attributes($objects,$this->subAttributes); $objects = $this->get_object_attributes($objects,$this->sub_Load_Later); - $this->SubObjects[$objects['cn']] = $objects; } } diff --git a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc index 878c4833a..5fd7530c0 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc @@ -495,66 +495,40 @@ class faiPartitionTable extends plugin function PrepareForCopyPaste($source) { plugin::PrepareForCopyPaste($source); - /* Get FAIstate - */ - if(isset($source['FAIstate'][0])){ - $this->FAIstate = $source['FAIstate'][0]; - } - /* Read all disks from ldap taht are defined fot this partition table + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); - $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))",array("*")); - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - $this->disks[$object['cn'][0]]['status'] = "edited"; - $this->disks[$object['cn'][0]]['dn'] = $object['dn']; - $this->disks[$object['cn'][0]]['cn'] = $object['cn'][0]; - if(isset($object['description'][0])){ - $this->disks[$object['cn'][0]]['description'] = $object['description'][0]; - }else{ - $this->disks[$object['cn'][0]]['description'] = ""; - } - $this->disks[$object['cn'][0]]['partitions'] = array(); + $res = FAI::get_all_objects_for_given_base($this->dn,"(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))"); + foreach($res as $obj){ + + /* Skip not relevant objects */ + if(!preg_match("/".normalizePreg($this->dn)."$/i",$obj['dn'])) continue; + + $objects = array(); + $objects['description'] = ""; + $objects['status'] = "edited"; + $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 + /* read all partitions for each disk */ foreach($this->disks as $name => $disk){ - $ldap->cd ($disk['dn']); - $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionEntry))",array("*")); - while($partition = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($partition['FAIstate'][0])){ - if(preg_match("/removed$/",$partition['FAIstate'][0])){ - continue; - } - } + $res = FAI::get_all_objects_for_given_base($disk['dn'],"(&(objectClass=FAIclass)(objectClass=FAIpartitionEntry))"); + foreach($res as $obj){ - /* remove count ... from ldap result - */ - foreach($partition as $key=>$val){ - if((is_numeric($key))||($key=="count")||($key=="dn")){ - unset($partition[$key]); - }else{ - $partition[$key] = $val[0]; - } - } + /* Skip not relevant objects */ + if(!preg_match("/".normalizePreg($disk['dn'])."$/i",$obj['dn'])) continue; - /* Append fetched partitions - */ - $partition['status']="edited"; - $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition; - } + $objects = array(); + $objects['status'] = "edited"; + $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); } diff --git a/gosa-plugins/fai/admin/fai/class_faiScript.inc b/gosa-plugins/fai/admin/fai/class_faiScript.inc index a835d5190..35151bd13 100644 --- a/gosa-plugins/fai/admin/fai/class_faiScript.inc +++ b/gosa-plugins/fai/admin/fai/class_faiScript.inc @@ -591,30 +591,19 @@ class faiScript extends plugin /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); - - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); + $res = FAI::get_all_objects_for_given_base($this->dn,"(&(objectClass=FAIclass)(objectClass=".$this->subClass."))"); + foreach($res as $obj){ - while($object = $ldap->fetch()){ + /* Skip not relevant objects */ + if(!preg_match("/".normalizePreg($this->dn)."$/i",$obj['dn'])) continue; - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } + $objects = array(); + $objects['status'] = "edited"; + $objects['dn'] = $obj['dn']; + $objects = $this->get_object_attributes($objects,$this->subAttributes); + $objects = $this->get_object_attributes($objects,$this->sub_Load_Later); + $this->SubObjects[$objects['cn']] = $objects; } - - /* Set status for save management */ - $objects = array(); - $objects['status'] = "edited"; - $objects['dn'] = $object['dn']; - $objects = $this->get_object_attributes($objects,$this->subAttributes); - $objects = $this->get_object_attributes($objects,$this->sub_Load_Later); - - $this->SubObjects[$objects['cn']] = $objects; } } diff --git a/gosa-plugins/fai/admin/fai/class_faiTemplate.inc b/gosa-plugins/fai/admin/fai/class_faiTemplate.inc index 6a8513d45..136ed45c4 100644 --- a/gosa-plugins/fai/admin/fai/class_faiTemplate.inc +++ b/gosa-plugins/fai/admin/fai/class_faiTemplate.inc @@ -512,29 +512,17 @@ class faiTemplate extends plugin /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); + $res = FAI::get_all_objects_for_given_base($this->dn,"(&(objectClass=FAIclass)(objectClass=".$this->subClass."))"); + foreach($res as $obj){ - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); + /* Skip not relevant objects */ + if(!preg_match("/".normalizePreg($this->dn)."$/i",$obj['dn'])) continue; - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ $objects = array(); $objects['status'] = "edited"; - $objects['dn'] = $object['dn']; + $objects['dn'] = $obj['dn']; $objects = $this->get_object_attributes($objects,$this->subAttributes); $objects = $this->get_object_attributes($objects,$this->sub_Load_Later); - $this->SubObjects[$objects['cn']] = $objects; } } diff --git a/gosa-plugins/fai/admin/fai/class_faiVariable.inc b/gosa-plugins/fai/admin/fai/class_faiVariable.inc index 9390146c6..17688c3f6 100644 --- a/gosa-plugins/fai/admin/fai/class_faiVariable.inc +++ b/gosa-plugins/fai/admin/fai/class_faiVariable.inc @@ -388,33 +388,17 @@ class faiVariable extends plugin /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } + $res = FAI::get_all_objects_for_given_base($this->dn,"(&(objectClass=FAIclass)(objectClass=".$this->subClass."))"); + foreach($res as $obj){ - /* Set status for save management */ - foreach($this->subAttributes as $attrs){ - if(!isset($object[$attrs][0])){ - $this->SubObjects[$object['cn'][0]][$attrs]=""; - }else{ - $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; - } - } - foreach($this->sub64coded as $codeIt){ - $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); - } - $this->SubObjects[$object['cn'][0]]['status'] = "edited"; - $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; + /* Skip not relevant objects */ + if(!preg_match("/".normalizePreg($this->dn)."$/i",$obj['dn'])) continue; + + $objects = array(); + $objects['status'] = "edited"; + $objects['dn'] = $obj['dn']; + $objects = $this->get_object_attributes($objects,$this->subAttributes); + $this->SubObjects[$objects['cn']] = $objects; } } -- 2.30.2