Code

Updated config mangement list
[gosa.git] / gosa-core / plugins / admin / newConfigManagement / class_newConfigManagement.inc
index 8b7cf00d4be5cdb904ed0e8a2901f83440ce539b..4d5822c88b70dd83d07cd184bd31f481d6eebbd3 100644 (file)
@@ -110,16 +110,16 @@ class newConfigManagement extends plugin
                                 $rpc->get_error()),ERROR_DIALOG);
                 }else{
                     $this->dataModel->setItemStatus($path, 'käse');
+                    $rpc = $this->config->getRpcHandle();
+                    $res = $rpc->getPackages($data['name']);
+
+                    return;
                     foreach($res as $itemPath => $type){
                 
                         // Make names dataModel conform
-                        $itemPath = $path.preg_replace("/^\//","/root", $itemPath);
+                        $itemPath = $path.'/'.preg_replace("/^\//","/root", $itemPath);
                         $name = preg_replace("/^.*\//","",$itemPath);   
-
                         $itemPath = preg_replace("/\/[^\/]*$/","", $itemPath);
-
-                        print_a(array($type, $itemPath, $name));
                         $this->dataModel->addItem($type, $itemPath, $name); 
                     }
                 }
@@ -136,8 +136,10 @@ class newConfigManagement extends plugin
         // Get the selected release and store it in a session variable
         //  to allow the configFilter to access it and display the
         //  packages and items.
-        $item = $this->dataModel->getItemByPath($this->selectedItem);
+        $path = $this->selectedContainer.$this->selectedItem;
+        $item = $this->dataModel->getItemByPath($path);
         session::set('CONFIG_ITEM', $item);
+        $this->listing->setListingTypes($this->getListingTypes());
 
         return($this->listing->renderList());
     }
@@ -149,14 +151,11 @@ class newConfigManagement extends plugin
      */
     function getItemList()
     {
-        $data = $this->dataModel->getItemByPath('/root');
-        return($this->__recurseItem($data));
-        $res = array();
-        $dist = $this->selectedContainer;
-        $list = $this->dataModel->getItemsByType('Release');
-        foreach($list as $base => $entry){
-            if($entry['parentPath'] != $dist) continue;
-            $res[$entry['path']] = $entry['name'];
+        $data = $this->dataModel->getItemByPath($this->selectedContainer);
+        $res = array(""=>"/");
+        if($data['type'] != 'Release'){
+        }else{
+            $res = array_merge($res,$this->__recurseItem($data, array('Component'),$this->selectedContainer));
         }
         return($res);
     }
@@ -169,25 +168,22 @@ class newConfigManagement extends plugin
     function getDistList()
     {
         $data = $this->dataModel->getItemByPath('/root');
-        return($this->__recurseItem($data));
-       
-
-        $list = $this->dataModel->getItemsByType('Distribution');
-        $res = array();
-        foreach($list as $base => $entry){
-            $res[$entry['path']] = $entry['name'];
-        }
+        $res["/root"] = "/";
+        $res = array_merge($res,$this->__recurseItem($data, array('Distribution','Release')));
         return($res);
     }
     
 
-    function __recurseItem($item)
+    function __recurseItem($item, $types, $parent = "")
     {
         $res = array();
-        $res[$item['path']] = $item['type'];
+        if(in_array($item['type'], $types)){
+            $path = preg_replace("/".preg_quote($parent,'/')."/","",$item['path']);
+            $res[$path] = $item['name'];
+        }
         if(count($item['children'])){
             foreach($item['children'] as $child){
-                $res = array_merge($res, $this->__recurseItem($child));
+                $res = array_merge($res, $this->__recurseItem($child, $types, $parent));
             }
         }
         return($res);
@@ -228,6 +224,24 @@ class newConfigManagement extends plugin
     }
 
 
+    function getListingTypes()
+    {
+        $types= array();
+        $types['Distribution']['objectClass'] = 'Distribution';
+        $types['Distribution']['label'] = _('Distribution');
+        $types['Distribution']['image'] = 'images/lists/edit.png';
+        $types['Distribution']['category'] = 'Device';
+        $types['Distribution']['class'] = 'Device';
+
+        $types['Release']['objectClass'] = 'Release';
+        $types['Release']['label'] = _('Release');
+        $types['Release']['image'] = 'images/lists/edit.png';
+        $types['Release']['category'] = 'Device';
+        $types['Release']['class'] = 'Device';
+        return($types);
+    }
+
+
     public static function plInfo()
     {
         return (array(