Code

Fixed problems with the item selection
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 25 Oct 2010 13:09:20 +0000 (13:09 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 25 Oct 2010 13:09:20 +0000 (13:09 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20141 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc
gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementListing.inc
gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc

index 2113c46a1cac6fb95e569e76f3d938909dc9e19e..a4cc53143dbcf56dcd8378ca08ee9b6145d15816 100644 (file)
@@ -98,6 +98,21 @@ class ConfigManagementDataModel
         }
         return($res);
     }
+
+
+    function getItemById($id)
+    {
+        $path = NULL;
+        if(isset($this->idToPath[$id])){
+            $path = $this->idToPath[$id];
+        }else{
+            return(NULL);
+        }
+        if(isset($this->data['linear'][$path])){
+            return($this->data['linear'][$path]);
+        }
+        return(NULL);
+    }
 }
 
 ?>
index 6f6d48f44dbae7930d45ba322b25d37fe3a6dddf..c1d4c93e4fc9af1651fc05f4fb191cebd36a4f71 100644 (file)
@@ -7,7 +7,6 @@ class ConfigManagementListing extends management
 
     private $containerSelector = NULL;
     private $itemSelector = NULL;
-
     private $objectTypeStr = "";
 
     function __construct($config, $ui, $parent)
@@ -64,17 +63,13 @@ class ConfigManagementListing extends management
 
     function renderList()
     {
-        session::set('DEVICE_ITEMS', array());
-
         $headpage = $this->getHeadpage();
         $headpage->update();
         $smarty = get_smarty();
-        
         $smarty->assign("CONTAINER", $this->containerSelector->render());
         $smarty->assign("ITEM", $this->itemSelector->render());
         $display = $headpage->render();
         return($this->getHeader().$display);
-
     }
 
 
@@ -90,18 +85,81 @@ class ConfigManagementListing extends management
 
         }
         $this->objectTypeStr = $str;
-        $this->rebuildListing();
     }
 
-   
-    function rebuildListing()
+
+    function execute()
     {
+        // Ensure that html posts and gets are kept even if we see a 'Entry islocked' dialog.
+        $vars = array('/^act$/','/^listing/','/^PID$/','/^FILTER_PID$/');
+        session::set('LOCK_VARS_TO_USE',$vars);
+
+        pathNavigator::registerPlugin($this);
+
+        /* Display the copy & paste dialog, if it is currently open */
+        $ret = $this->copyPasteHandler("",array());
+        if($ret){
+            return($this->getHeader().$ret);
+        }
+
+        // Update filter
+        if ($this->filter) {
+            $this->filter->update();
+            session::global_set(get_class($this)."_filter", $this->filter);
+            session::set('autocomplete', $this->filter);
+        }
 
         // Handle actions (POSTs and GETs)
         $str = $this->handleActions($this->detectPostActions());
         if($str) return($this->getHeader().$str);
 
+        $items = $this->parent->getItemsToBeDisplayed();
+        session::set('CONFIG_ITEM', $items);
+
+        // Open single dialog objects
+        if(is_object($this->dialogObject)){
+            if(method_exists($this->dialogObject,'save_object')) $this->dialogObject->save_object();
+            if(method_exists($this->dialogObject,'execute')){
+                $display = $this->dialogObject->execute();
+                $display.= $this->_getTabFooter();
+                return($this->getHeader().$display);
+            }
+        }
+
+        // Display tab object.
+        if($this->tabObject instanceOf tabs || $this->tabObject instanceOf multi_plug){
+#      $this->tabObject->save_object();
+            $display = $this->tabObject->execute();
+            $display.= $this->_getTabFooter();
+            return($this->getHeader().$display);
+        }
+        // Set current restore base for snapshot handling.
+        if(is_object($this->snapHandler)){
+            $bases = array();
+            foreach($this->storagePoints as $sp){
+                $bases[] = $sp.$this->headpage->getBase();
+            }
+
+            // No bases specified? Try base
+            if(!count($bases)) $bases[] = $this->headpage->getBase();
+
+            $this->snapHandler->setSnapshotBases($bases);
+        }
+
+        // Create statistic table entry
+        stats::log('management', $class = get_class($this), $this->getAclCategories(),  $action = 'view',
+                $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
+
+        // Display list
+        $this->rebuildListing();
+        $str = $this->renderList();
+        return($str);
+    }    
+    
 
+   
+    function rebuildListing()
+    {
         // Build filter
         if (session::global_is_set(get_class($this)."_filter")){
             $filter= session::global_get(get_class($this)."_filter");
@@ -125,7 +183,7 @@ class ConfigManagementListing extends management
         // Register default actions
         $this->registerAction("new",    "newEntry");
         $this->registerAction("editEntry",  "editEntry");
-        $this->registerAction("open",       "openEntry");
+        $this->registerAction("edit",       "openEntry");
         $this->registerAction("apply",  "applyChanges");
         $this->registerAction("save",   "saveChanges");
         $this->registerAction("cancel", "cancelEdit");
@@ -153,6 +211,22 @@ class ConfigManagementListing extends management
     {
         $this->parent->editEntry($target);
     }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    
+
 } 
 
 ?>
index 73349b40f3fee97e40e520541e9f25a1c543fc51..de2289dfc1b1ff7d114c4ad232638ff1f8268571 100644 (file)
@@ -66,30 +66,9 @@ class newConfigManagement extends plugin
         $this->listing->save_object();
 
         // Get the selected distribution and release from the listing widget.
-        $this->selectedContainer = $this->listing->getSelectedContainer();
-        $this->selectedItem = $this->listing->getSelectedItem();
-  
-        // Get a list of all available distributions and releases.
-        $distList = $this->getDistList();
-        $releaseList = $this->getItemList();
-
-        // Ensure that we've valid values selected.
-        if(!isset($releaseList[$this->selectedItem])){
-            if(count($releaseList)){
-                $this->selectedItem = key($releaseList);
-            }else{
-                $this->selectedItem = "";
-            }
-        }
-
-        // Update list of items within the selected container. 
-        $this->updateItemList($this->selectedContainer);
-
-        // Transfer checked values back to the listing class.
-        $this->listing->setContainer($this->selectedContainer);
-        $this->listing->setItem($this->selectedItem);
-        $this->listing->setContainers($this->getDistList());
-        $this->listing->setItems($this->getItemList());
+        $cont = $this->listing->getSelectedContainer();
+        $item = $this->listing->getSelectedItem();
+        $this->setCurrentContainer($cont, $item);
     }
 
 
@@ -128,21 +107,57 @@ class newConfigManagement extends plugin
     }
 
 
+
+    function setCurrentContainer($cont, $item)
+    {
+        $this->selectedContainer = $cont;
+        $this->selectedItem = $item;
+
+        // Get a list of all available distributions and releases.
+        $distList = $this->getDistList();
+        $releaseList = $this->getItemList();
+
+        // Ensure that we've valid values selected.
+        if(!isset($releaseList[$this->selectedItem])){
+            if(count($releaseList)){
+                $this->selectedItem = key($releaseList);
+            }else{
+                $this->selectedItem = "";
+            }
+        }
+
+        // Update list of items within the selected container. 
+        $this->updateItemList($this->selectedContainer);
+
+        // Transfer checked values back to the listing class.
+        $this->listing->setContainer($this->selectedContainer);
+        $this->listing->setItem($this->selectedItem);
+        $this->listing->setContainers($this->getDistList());
+        $this->listing->setItems($this->getItemList());
+    }
+
+
     /*! \brief  Generate the HTML content for this plugin.
      *          Actually renders the listing widget..
      */
     function execute()
     {
-
         // Get the selected release and store it in a session variable
         //  to allow the configFilter to access it and display the
         //  packages and items.
-        $path = $this->selectedContainer.$this->selectedItem;
-        $item = $this->dataModel->getItemByPath($path);
-        session::set('CONFIG_ITEM', $item);
+        $res = $this->listing->execute();
         $this->listing->setListingTypes($this->getListingTypes());
 
-        return($this->listing->execute());
+        return($res);
+    }
+
+    
+    function getItemsToBeDisplayed()
+    {
+
+        $path = $this->selectedContainer.$this->selectedItem;
+        $item = $this->dataModel->getItemByPath($path);
+        return($item);
     }
 
 
@@ -250,21 +265,32 @@ class newConfigManagement extends plugin
 
 
 
-    function editEntry($id)
+    function editEntry($ids)
     {
-        print_a($id);
+        foreach($ids as $id){
+            echo "<br>Edit {$id}";
+        }
     }
 
 
-    function removeEntry($id)
+    function removeEntry($ids)
     {
-        print_a($id); 
+        foreach($ids as $id){
+            echo "<br>Remove {$id}";
+        }
     }
 
 
-    function openEntry($id)
+    function openEntry($ids)
     {
-        print_a($id); 
+        foreach($ids as $id){
+            $item = $this->dataModel->getItemById($id);
+            if($item){
+                if(in_array($item['type'], array('Distribution', 'Release', 'Component'))){
+                    $this->setCurrentContainer($item['path'], $this->selectedContainer);
+                }
+            }
+        }
     }