Code

Do not index items by their name, use an id instead.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 30 Sep 2010 09:41:31 +0000 (09:41 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 30 Sep 2010 09:41:31 +0000 (09:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19865 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc
gosa-plugins/goto/admin/systems/goto/Config/class_filterDeviceItems.inc

index d0b7ee41a28336e07308fac4857974f88630d25b..dd8c554afaf1ee3375d166f3535b1e96b8934fa6 100644 (file)
@@ -66,38 +66,38 @@ class DeviceConfig extends management
         $this->is_account = TRUE;
 
         // Set current item to 'root', this is the minimum to get things running.
-        $this->addItem($root,'root',array());
-        $this->setCurrentItem('root');
-        $this->setBase($this->baseToDN['root']);
+        $idRoot = $this->addItem($root,'root',array());
+        $this->setCurrentItem($idRoot);
+        $this->setBase($this->baseToDN[$idRoot]);
 
-        $this->addItem('PuppetModule','test1',
+        $id = $this->addItem('PuppetModule','test1',
                 array(
                     'dependency' => array('stulle','Wurst'),
                     'version' => '2.4-f',
                     'name'  => 'Thundebird',
                     'description' => 'Mozilla mail client')
                 );
-        $this->addItem('PuppetModule','test2',
+        $id = $this->addItem('PuppetModule','test2',
                 array(
                     'dependency' => array('Leipnitz','Dose'),
                     'version' => 1,
                     'name'  => 'Firefox',
                     'description' => 'Test Module')
                 );
-        $this->setCurrentItem('test1');
-        $this->addItem('PuppetTemplate','temp1',
+        $this->setCurrentItem($id);
+        $id = $this->addItem('PuppetTemplate','temp1',
                 array(
                     'name' => 'temp1', 
                     'data' => 'kekse.tpl')
                 );
-        $this->setCurrentItem('temp1');
-        $this->addItem('PuppetTemplate','tep1',
+        $this->setCurrentItem($id);
+        $id = $this->addItem('PuppetTemplate','tep1',
                 array(
                     'name' => 'tep1',
                     'data' => 'kekse.tpl')
                 );
 
-        $this->setCurrentItem('root');
+        $this->setCurrentItem($idRoot);
         $this->rebuildListing();
     }
 
@@ -148,7 +148,7 @@ class DeviceConfig extends management
             $this->itemContainerSelector = new releaseSelector(
                     $this->getContainerList(), 
                     $this->base, 
-                    $this->currentItemValues['root']['base']);
+                    $this->currentItemValues[0]['base']);
         }else{
             $this->itemContainerSelector->setBases($this->getContainerList());
         }
@@ -172,7 +172,7 @@ class DeviceConfig extends management
      */
     function getContainerList($array = NULL)
     {
-        $array = ($array == NULL)?$this->currentItemValues['root']: $array;
+        $array = ($array == NULL)?$this->currentItemValues[0]: $array;
         $ret[$array['base']] = $array['type'];
         if(count($array['children'])){
             foreach($array['children'] as $subItem){
@@ -317,18 +317,22 @@ class DeviceConfig extends management
 
         $base = (isset($current['base']))? ",".$current['base'] : '';
         $base = "{$type}={$name}{$base}";
+        $id = count($this->currentItemValues);
 
         $new = array(
                 'base' => $base,
                 'children' => array(),
+                'id' => $id, 
                 'type' => $type, 
                 'name' => $name, 
                 'values' => $values);
-        $this->currentItemValues[$name] = $new;
-        $current['children'][$name] = &$this->currentItemValues[$name];
 
-        $this->baseToDN[$name] = $base;
-        $this->baseToDN[$base] = $name;
+        $this->currentItemValues[$id] = $new;
+        $current['children'][$id] = &$this->currentItemValues[$id];
+
+        $this->baseToDN[$id] = $base;
+        $this->baseToDN[$base] = $id;
+        return($id);
     }
     
 
index f4ac031e60639a23fefe8eeca2c7e1322e37c3c8..b44d8d1dedbaf8636888a496534ad08dc8036f01 100644 (file)
@@ -31,15 +31,17 @@ class filterDeviceItems {
     {
         if(preg_match("/".$filter."/",$item['name'])){
             $entry = array();
-            $entry['dn'] = $item['name'];
+            $entry['dn'] = $item['id'];
             $entry[] = 'dn';
             $entry['cn'] = array($item['name'], 'count' => 1);
             $entry[] = 'cn';
+            $entry['id'] = array($item['id'], 'count' => 1);
+            $entry[] = 'id';
             $entry['description'] = array($item['type'], 'count' => 1);
             $entry[] = 'description';
             $entry['objectClass'] = array('FAKE_OC_DeviceItem','count' => 1);
             $entry[] = 'objectClass';
-            $entry['count'] = 3;
+            $entry['count'] = 4;
             $ret[] = $entry;
         }