Code

Updated saving of config Items
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Apr 2011 12:30:32 +0000 (12:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Apr 2011 12:30:32 +0000 (12:30 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20662 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc
gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc

index e02848aebafa1b3a93266e40ec03d7c3383b9c8e..7879644482067350a6c3c50295f6cef97b9a6e21 100644 (file)
@@ -180,7 +180,7 @@ class ConfigManagementListing extends management
                 $img = $images[$i++];
                 $items .=
                     "<action>".
-                    "    <name>add_{$item}</name>".
+                    "    <name>new_{$item}</name>".
                     "    <type>entry</type>".
                     "    <image>{$img}</image>".
                     "    <label>{$desc}</label>".
@@ -224,6 +224,13 @@ class ConfigManagementListing extends management
         $this->registerAction("cancelItemEdit", "closeDialogs");
         $this->registerAction("cancelItemAdd", "closeDialogs");
         $this->registerAction("saveItemChanges", "saveItemChanges");
+
+        if($this->parent){
+            foreach($this->parent->addableContainerItems as $item){
+                $this->registerAction("new_{$item}",    "newEntry");
+            }
+        }
+
     }
 
     function saveItemChanges()
@@ -236,6 +243,11 @@ class ConfigManagementListing extends management
 //        $this->parent->removeEntry($target);
     }
 
+    function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
+    {
+        $this->parent->newEntry(preg_replace("/^new_/", "", $action));
+    }
+
     function openEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
     {
         $this->parent->openEntry($target);
index 6910f6559b4b0baabe828a7f9d3afd304e875188..5f56ac0bb7f655dafdb673fc6000bc7433a7f79e 100644 (file)
@@ -452,27 +452,60 @@ class newConfigManagement extends plugin
         }
     }
 
+    function newEntry($type)
+    {
+        $method = $this->cfgItemMap[$type];
+        $this->setInstallMethod($method);
+        $this->TemplateEngine->setValues($type,array());
+        $this->listing->setDialogObject($this->TemplateEngine);
+        $this->currentObject = NULL;
+    }
+
     function saveItemChanges()
     {
         $item = $this->currentObject;
-        $this->listing->clearDialogObject();
-        $this->TemplateEngine->save_object();
-        $values = array();
-        foreach($this->TemplateEngine->getWidgets() as $w){
-            $values[$w->getName()] = $w->getValue();
-        }
-        $release = preg_replace("/^.*\//","",$item['values']['__release']);
-        $path = $item['values']['__path'];
-        $method = $this->cfgItemMap[$item['type']];
 
-        $rpc = $this->config->getRpcHandle();
-        $res = $rpc->setConfigItem($release, $path, $item['type'], $values);
-        if(!$rpc->success()){
-            msg_dialog::display(_("Error"), sprintf(_("Failed to load distributions: %s"), $rpc->get_error()),ERROR_DIALOG);
-            return(NULL);
+        if($item == NULL){
+            $this->TemplateEngine->save_object();
+            $release = preg_replace("/^.*\//","",$this->selectedContainer);
+            $type = $this->TemplateEngine->getItemType();
+            $values = array();
+            foreach($this->TemplateEngine->getWidgets() as $w){
+                $values[$w->getName()] = $w->getValue();
+            }
+            $path = "/".$values['name'];
+            $rpc = $this->config->getRpcHandle();
+            $res = $rpc->setConfigItem($release, $path, $type, $values);
+            if(!$rpc->success()){
+                msg_dialog::display(_("Error"), sprintf(_("Failed to load distributions: %s"), $rpc->get_error()),ERROR_DIALOG);
+                return(NULL);
+            }else{
+                //$item['values']['itemValues'] = $values;
+                //$this->dataModel->setItemValues($item['path'], $item['values']);
+                $this->listing->clearDialogObject();
+            }
+            print_a(array($release, $path, $type, $values));
         }else{
-            $item['values']['itemValues'] = $values;
-            $this->dataModel->setItemValues($item['path'], $item['values']);
+            $this->TemplateEngine->save_object();
+            $values = array();
+            foreach($this->TemplateEngine->getWidgets() as $w){
+                $values[$w->getName()] = $w->getValue();
+            }
+            $release = preg_replace("/^.*\//","",$item['values']['__release']);
+            $path = $item['values']['__path'];
+            $method = $this->cfgItemMap[$item['type']];
+
+            $rpc = $this->config->getRpcHandle();
+            $res = $rpc->setConfigItem($release, $path, $item['type'], $values);
+            print_a(array($release, $path, $item['type'], $values));
+            if(!$rpc->success()){
+                msg_dialog::display(_("Error"), sprintf(_("Failed to load distributions: %s"), $rpc->get_error()),ERROR_DIALOG);
+                return(NULL);
+            }else{
+                $item['values']['itemValues'] = $values;
+                $this->dataModel->setItemValues($item['path'], $item['values']);
+                $this->listing->clearDialogObject();
+            }
         }
     }
 }