Code

Added new filter Method for OPI hosts
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 15 Mar 2010 16:35:30 +0000 (16:35 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 15 Mar 2010 16:35:30 +0000 (16:35 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16540 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/systems/admin/systems/class_filterOPSIHOSTS.inc [new file with mode: 0644]
gosa-plugins/systems/admin/systems/class_filterSYSTEMS.inc
gosa-plugins/systems/admin/systems/system-filter.xml

diff --git a/gosa-plugins/systems/admin/systems/class_filterOPSIHOSTS.inc b/gosa-plugins/systems/admin/systems/class_filterOPSIHOSTS.inc
new file mode 100644 (file)
index 0000000..767fe0c
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+
+class filterOPSIHOSTS {
+
+  static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
+  {
+    // Append opsi stuff ...
+    global $config;
+    $ui = get_userinfo();
+
+    echo $filter;
+
+    if(preg_match("/NETBOOT/", $filter) && 
+        class_available('opsi') &&
+        $base == $config->current['BASE']){
+
+      // Get filter regex ...
+      $regex = "";
+      if(preg_match("/\(cn=[^\)\$]*\)/", $filter)){
+        $regex = trim(preg_replace("/^.*\(cn=([^\)\$]*)\).*$/","\\1", $filter),"* ");
+      }
+
+      // Check ACLs and opsi handle
+      $opsi_acl = $ui->get_permissions($base,"opsi/opsiProperties");
+      $opsi = new opsi($config);
+      $objects = array();
+      if($opsi instanceof opsi && $opsi->enabled() && preg_match("/r/",$opsi_acl)){
+
+        // Get list of opsi hosts 
+        $opsi_clients = $opsi->get_hosts_for_system_management();
+        if($opsi->is_error()){
+          msg_dialog::display(_("Error"),msgPool::siError($opsi->get_error()),ERROR_DIALOG);
+        }else{
+          foreach($opsi_clients as $entry){
+            if(empty($regex) || preg_match('/'.preg_quote($regex,'/').'/i',$entry['cn'][0])){
+              $entry['objectClass'] = array("FAKE_OC_OpsiHost");
+              $item = array('count' => count($entry));
+              foreach($entry as  $name => $value){
+                $item[] = $name;
+                $item[$name] = $value;
+              }
+              $entries[] = $item;
+            }
+          }
+        }
+      }
+    }
+    return($entries);
+  }
+}
+
+?>
index 2d99d152f6e47e00e9a81315d60036295f403ef4..aa7dfbdc5410705df2228074cc8dabb4a166efff 100644 (file)
@@ -104,44 +104,6 @@ class filterSYSTEMS {
       }
     }
 
-    // Append opsi stuff ...
-    global $config;
-    $ui = get_userinfo();
-    if(preg_match("/FAIstate=__NETBOOT__/", $filter) && 
-        class_available('opsi') &&
-        $base == $config->current['BASE']){
-
-      // Get filter regex ...
-      $regex = "";
-      if(preg_match("/\(cn=[^\)\$]*\)/", $filter)){
-        $regex = trim(preg_replace("/^.*\(cn=([^\)\$]*)\).*$/","\\1", $filter),"* ");
-      }
-
-      // Check ACLs and opsi handle
-      $opsi_acl = $ui->get_permissions($base,"opsi/opsiProperties");
-      $opsi = new opsi($config);
-      $objects = array();
-      if($opsi instanceof opsi && $opsi->enabled() && preg_match("/r/",$opsi_acl)){
-
-        // Get list of opsi hosts 
-        $opsi_clients = $opsi->get_hosts_for_system_management();
-        if($opsi->is_error()){
-          msg_dialog::display(_("Error"),msgPool::siError($opsi->get_error()),ERROR_DIALOG);
-        }else{
-          foreach($opsi_clients as $entry){
-            if(empty($regex) || preg_match('/'.preg_quote($regex,'/').'/i',$entry['cn'][0])){
-              $entry['objectClass'] = array("FAKE_OC_OpsiHost");
-              $item = array('count' => count($entry));
-              foreach($entry as  $name => $value){
-                $item[] = $name;
-                $item[$name] = $value;
-              }
-              $entries[] = $item;
-            }
-          }
-        }
-      }
-    }
     return($entries);
   }
 }
index 48fa847962d84cf18a7b3c9fc7eaa9ef64e0891c..380c57ab9ec4e38b089e40877d333d80b3b43242 100644 (file)
       <backend>SYSTEMS</backend>
       <filter>(&amp;(objectClass=goServer)(cn=$))</filter>
     </query>
+    <query>
+      <backend>OPSIHOSTS</backend>
+      <filter>$</filter>
+    </query>
     <autocomplete>
       <attribute>cn</attribute>
       <frequency>0.5</frequency>