Code

Added opsi filter
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 31 Mar 2010 07:12:44 +0000 (07:12 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 31 Mar 2010 07:12:44 +0000 (07:12 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17413 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiManagement.inc
gosa-plugins/fai/admin/fai/class_filterOPSIPackages.inc [new file with mode: 0644]
gosa-plugins/fai/admin/fai/fai-filter.xml

index 5146f091e93042877fcfba4f5475028a27955065..2d00aedf64e98d949bd4c80924025a47fe0c24d0 100644 (file)
@@ -86,7 +86,7 @@ class faiManagement extends management
         get_ou('faiTemplateRDN'));
 
     // Build filter
-    if (session::global_is_set(get_class($this)."_filter")){
+    if (0 && session::global_is_set(get_class($this)."_filter")){
       $filter= session::global_get(get_class($this)."_filter");
     } else {
       $filter = new filter(get_template_path("fai-filter.xml", true));
diff --git a/gosa-plugins/fai/admin/fai/class_filterOPSIPackages.inc b/gosa-plugins/fai/admin/fai/class_filterOPSIPackages.inc
new file mode 100644 (file)
index 0000000..19de355
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+
+class filterOPSIPackages extends filterLDAP{
+
+  static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
+  {
+    global $config;
+    $ui = get_userinfo();
+    $ldap = $config->get_ldap_link();
+    $ldap->cd($config->current['BASE']);
+
+    // Append opsi stuff ...
+    if(class_available('opsi') && $base == get_ou("faiBaseRDN").$config->current['BASE']){
+      $opsi = new opsi($config);
+      $objects = array();
+      if($opsi instanceof opsi && $opsi->enabled()){
+        $opsi_acl = $ui->get_permissions($base,"opsi/opsiProperties");
+        if(preg_match("/r/",$opsi_acl)){
+          $err = FALSE;
+
+          $n_pro = $opsi->get_netboot_products();
+          $err |= $opsi->is_error();
+          foreach($n_pro as $name => $data){
+            $entry = array(
+                "cn" => $name,
+                "description" => $data['DESC'],
+                "type" => "opsi_netboot");
+            $objects[$name]['opsi_netboot'] = $entry;
+          }
+          $l_pro = $opsi->get_local_products();
+          $err |= $opsi->is_error();
+          foreach($l_pro as $name => $data){
+            $entry = array("cn" => $name,
+                "description" => $data['DESC'],
+                "type" => "opsi_local");
+            $objects[$name]["opsi_local"] = $entry;
+          }
+          if($err){
+            msg_dialog::display(_("Error"),msgPool::siError($opsi->get_error()),ERROR_DIALOG);
+          }
+        }
+      }
+      $cn_filter = "";
+      if(preg_match("/^.*cn=([^)]*).*/",$filter)){
+        $cn_filter = trim(preg_replace("/^.*cn=([^)]*).*/","\\1",$filter),"*");
+      }
+
+      foreach($objects as $name => $data)
+      {
+        $data = array_pop($data);
+        if(!empty($cn_filter) && !preg_match("/".preg_quote($cn_filter,'/')."/",  $data['cn'])){
+          continue;
+        }
+        $item =array();
+
+        $item['objectClass']  = array('count' => 2, $data['type'],"FAKE_OC_OPSI");
+        $item[] = 'objectClass';
+        $item['cn']  = $data['cn'];
+        $item[] = 'cn';
+        $item['description']  = $data['description'];
+        $item[] = 'description';
+        $item['dn']  = $data['cn'];
+        $item[] = 'dn';
+        $item['TYPES']  = array($data['type']);
+        $item[] = 'TYPES';
+        $item['count'] = '5';
+        $entries[] = $item;
+
+      }
+    }
+    return($entries);
+  }
+}
+?>
index d90bdd20ca4524d0cfd902cd9e248ab2281af48a..006a3d778c6fdf186f2b0c6e3e75a87f5ac27198 100644 (file)
@@ -32,7 +32,7 @@
       </filter>
     </query>
     <query>
-      <backend>FAI</backend>
+      <backend>OPSIPackages</backend>
       <filter>cn=$</filter>
     </query>
     <autocomplete>