Code

Updated FAI object copy & paste.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 18 Jul 2008 12:39:49 +0000 (12:39 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 18 Jul 2008 12:39:49 +0000 (12:39 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11715 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiHook.inc
gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc
gosa-plugins/fai/admin/fai/class_faiScript.inc
gosa-plugins/fai/admin/fai/class_faiTemplate.inc
gosa-plugins/fai/admin/fai/class_faiVariable.inc

index 246bb794261dbbbf01bc083250a70791e36b7f6e..589d67933e3c2dc0e07c6c8309b0c22be9d01415 100644 (file)
@@ -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;
     }
   }
index 878c4833ac63626843e0c9d607c9ab6ef2ce1b2f..5fd7530c0169105bd162b6443258c9d3abc5a0ab 100644 (file)
@@ -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);
   }
index a835d5190bb128afb2c7a65946c7db50a4d9e467..35151bd137c446813cc58259c86455b7c8321658 100644 (file)
@@ -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;
     }
   }
 
index 6a8513d45757f4a40cbad13abbd1039c6f0eb4ba..136ed45c46696266b98e2fa1c5bc05ead7067a26 100644 (file)
@@ -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;
     }
   }
index 9390146c6688ce550fa67e0658db124bc2b1b685..17688c3f6470c8a86f624d26f6ce24c2f81d0242 100644 (file)
@@ -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;
     }
   }