From c6588d148304515609843d9885c3babc0ff5ebaf Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 7 Apr 2011 12:30:32 +0000 Subject: [PATCH] Updated saving of config Items git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20662 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../class_ConfigManagementListing.inc | 14 +++- .../class_newConfigManagement.inc | 65 ++++++++++++++----- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc index e02848aeb..787964448 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc @@ -180,7 +180,7 @@ class ConfigManagementListing extends management $img = $images[$i++]; $items .= "". - " add_{$item}". + " new_{$item}". " entry". " {$img}". " ". @@ -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); diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc index 6910f6559..5f56ac0bb 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc @@ -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(); + } } } } -- 2.30.2