Code

Updated DeviceConfig
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Sep 2010 11:31:37 +0000 (11:31 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Sep 2010 11:31:37 +0000 (11:31 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19828 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig-filter.xml
gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig-list.xml
gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc
gosa-plugins/goto/admin/systems/goto/Config/class_filterDeviceItems.inc

index 1517fa48159e469d1ce9d6a1be15f7af88f1d748..183ddd4ce52a3a8456fcbf7590a69e8bf4bd17f1 100644 (file)
@@ -14,8 +14,7 @@
     <label>Default filter</label>
     <query>
       <backend>DeviceItems</backend>
-      <filter>-
-      </filter>
+      <filter>$</filter>
     </query>
     <autocomplete>
       <attribute>cn</attribute>
index 447f6fae977327a4ae7f8a44edac618913ec2456..9cd8299e895724ce62ee8efd1e8381a3b8adcb42 100644 (file)
@@ -48,7 +48,7 @@
       <label>Description</label>
       <sortAttribute>description</sortAttribute>
       <sortType>string</sortType>
-      <value>%{filter:link(row,dn,pid,state,description)}</value>
+      <value>%{filter:link(row,dn,"%s",description,pid)}</value>
       <export>true</export>
     </column>
 
index 21a4f89ccca4d14484cff5d0e19f337ee015e301..75cba72cfae1003cd4ca1598bc27c197454a0d94 100644 (file)
@@ -148,6 +148,7 @@ class DeviceConfig extends management
      */
     function renderList()
     {
+        session::set('DEVICE_ITEMS', $this->currentItemValues);
         $this->rebuildListing();
         $filter = $this->getFilter();
         $headpage = $this->getHeadpage();
index b8a14b3e9fda83e55481595e225d903c340d3710..17c62fd0c9a006f0284245b8e59fd7e445fa29dd 100644 (file)
@@ -4,23 +4,44 @@ class filterDeviceItems {
 
     static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
     {
-        print_a(array($base, $scope, $filter, $attributes, $category, $objectStorage));
+        // Walk through the data array till we reach the correct level, then 
+        //  create the list of entries.
+        $data = session::get('DEVICE_ITEMS');
+        foreach(array_reverse(preg_split("/[,]*cn=/", $base,0,PREG_SPLIT_NO_EMPTY)) as $name){
+            $data = $data[$name]['children'];            
+        }
+
+        // Add entries 
         $ret = array();
+        $filter = preg_replace("/\*/",'.*', $filter);
+        foreach($data as $item){
+            filterDeviceItems::addEntry($ret, $item, $scope == 'sub', $filter);
+        }
+        return($ret);
+    }
 
-        $entry = array();
-        $entry['dn'] = 'cn=test,cn=/';
-        $entry[] = 'dn';
-        $entry['cn'] = array('test', 'count' => 1);
-        $entry[] = 'cn';
-        $entry['description'] = array('test-item', 'count' => 1);
-        $entry[] = 'description';
-        $entry['objectClass'] = array('FAKE_OC_DeviceItem','count' => 1);
-        $entry[] = 'objectClass';
-        $entry['count'] = 4;
+    static function addEntry(&$ret, $item, $recursive = FALSE, $filter)
+    {
+        if(preg_match("/".$filter."/",$item['name'])){
+            $entry = array();
+            $entry['dn'] = $item['name'];
+            $entry[] = 'dn';
+            $entry['cn'] = array($item['name'], 'count' => 1);
+            $entry[] = 'cn';
+            $entry['description'] = array($item['type'], 'count' => 1);
+            $entry[] = 'description';
+            $entry['objectClass'] = array('FAKE_OC_DeviceItem','count' => 1);
+            $entry[] = 'objectClass';
+            $entry['count'] = 4;
+            $ret[] = $entry;
+        }
 
+        if($recursive && isset($item['children']) && count($item['children'])){
+            foreach($item['children'] as $item){
+                filterDeviceItems::addEntry($ret, $item, $recursive,$filter);
+            }
+        }
 
-        $ret[] = $entry;
-        return($ret);
     }
 }