Code

Added ability to copy disks and package lists
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Dec 2007 14:39:23 +0000 (14:39 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Dec 2007 14:39:23 +0000 (14:39 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8047 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_faiPackage.inc
plugins/admin/fai/class_faiPartitionTable.inc

index 840a5ae9262015d2e6db104ac3e8cc5eb9cb3ffc..bcd5eaaf69bb268efd336b177c41bfe7f44a8481 100644 (file)
@@ -55,6 +55,7 @@ class faiPackage extends plugin
 
   var $FAIstate         = "";
   var $view_logged      = FALSE;
+  var $base;
 
   var $FAIinstallMethods  = array( "install", "ninstall", "remove", 
       "dselect-upgrade", "taskinst", "taskrm",
@@ -464,6 +465,19 @@ class faiPackage extends plugin
   /* Save to LDAP */
   function save()
   {
+
+    /* Assemble release name */
+    if($this->FAIdebianRelease == "ClearFromCopyPaste"){
+      $tmp= preg_replace('/,ou=fai,ou=configs,ou=systems,.*$/', '', $_SESSION['faifilter']['branch']);
+      $tmp= preg_replace('/ou=/', '', $tmp);
+      $rev= array_reverse(split(',', $tmp));
+      $this->FAIdebianRelease= "";
+      foreach ($rev as $part){
+        $this->FAIdebianRelease.= "/$part";
+      }
+      $this->FAIdebianRelease= preg_replace('#^/#', '', $this->FAIdebianRelease);
+    }
+
     plugin::save();
 
     $ldap = $this->config->get_ldap_link();
@@ -551,6 +565,80 @@ class faiPackage extends plugin
           ));
   }
 
+
+
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+
+    if(isset($source['FAIstate'][0])){
+      $this->FAIstate = $source['FAIstate'][0];
+    }
+
+    $this->FAIdebianRelease = "ClearFromCopyPaste";
+
+    if(isset($source['FAIpackage'])){
+      unset($source['FAIpackage']['count']);
+      foreach($source['FAIpackage'] as $pkg){
+        $this->usedPackages[$pkg] = $pkg;
+      }
+      ksort($this->usedPackages);
+    }else{
+      $this->usedPackages = array();
+    }
+
+    if((isset($source['FAIdebianSection']))&&(is_array($source['FAIdebianSection']))){
+      $this->FAIdebianSection = array();
+      for($i = 0 ; $i < $source['FAIdebianSection']['count'] ; $i ++){
+        $this->FAIdebianSection[$source['FAIdebianSection'][$i]]=$source['FAIdebianSection'][$i];
+      }
+    }
+
+    /* Create one filter with all package names, 
+       instead of calling $ldap->search for every single package 
+     */
+    $PackageFilter = "";
+    foreach($this->usedPackages as $name){
+      $PackageFilter .= "(FAIpackage=".$name.")";
+    }
+    $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))";
+
+    /* Search for configuration objects */ 
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($source['dn']);
+    $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate"));
+
+    /* Walk through configurations and append them to our list of ConfiguredPackages */
+    while($attr = $ldap->fetch()){
+
+      /* Skip objects, that are tagged as removed */
+      if(isset($object['FAIstate'][0])){
+        if(preg_match("/removed$/",$attr['FAIstate'][0])){
+          continue;
+        }
+      }
+
+      $tmp =array(); 
+      $tmp['Name']  = $attr['FAIvariable'][0];
+      $tmp['Type']  = $attr['FAIvariableType'][0];
+
+      if (isset($attr['FAIvariableContent'][0])){
+        if(!in_array($attr['FAIvariableType'],array("multiselect"))){
+          $tmp['Value'] = $attr['FAIvariableContent'][0];
+        }else{
+          $content = array();        
+          unset($attr['FAIvariableContent']['count']);
+          foreach($attr['FAIvariableContent'] as $attr){
+            $tmp['Value'][] = $attr;
+          }
+        }
+        $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
+      }
+    }
+  }
+
+
   function getServerInfos()
   {
     $ret = array();
index 031c5a4d4f0c4a7667f04eb2702144614a5c34a4..216d6c3ed1e257395fd65276e4449cc80b66d35a 100644 (file)
@@ -531,6 +531,74 @@ 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 
+     */
+    $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();
+    }
+
+    /* 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;
+          }
+        }
+
+        /* 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];
+          }
+        }
+
+        /* Append fetched partitions
+         */
+        $partition['status']="edited";
+        $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition; 
+      }  
+    }
+    ksort($this->disks);
+  }
+
+
   /* Return plugin informations for acl handling */ 
   static function plInfo()
   {