From efe821d2f708e03f898622d65361af897639cbe0 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 27 Apr 2011 08:02:08 +0000 Subject: [PATCH] Fixed saving of releases git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20769 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../class_newConfigManagement.inc | 69 +++++++++++-------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc index 2330b8b93..5e2b8b8cb 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc @@ -788,41 +788,52 @@ class newConfigManagement extends plugin $this->listing->clearDialogObject(); }elseif($type == 'Release'){ - - // We've to create a new release + + // We've to update a release. + if($item){ + + // Check if we've to rename the item. + $path = $this->getReleasePart($item['parentPath']); + $curPath = $this->getReleasePart($item['path']); + $newPath = trim($path."/".$values['name'], '/'); + if($curPath != $newPath){ + $rpc = $this->config->getRpcHandle(); + $res = $rpc->renameRelease($curPath, $newPath); + if(!$rpc->success()){ + msg_dialog::display(_("Error"), sprintf(_("Failed to save release: %s"), $rpc->get_error()),ERROR_DIALOG); + return(NULL); + }else{ + $this->dataModel->moveItem($item['path'], $item['parentPath'].'/'.$values['name']); + $this->dataModel->setItemValues($item['path'], $values); + $this->listing->clearDialogObject(); + } + } + + + }else{ - // Build up the new release path. - $name = $values['name']; - $rPath = $this->getReleasePart($this->selectedContainer); - $newPath = trim($rPath."/".$name, '/'); - - // Detect the parent distribution - $dist = $this->getDistributionPath($this->selectedContainer); - $dist = preg_replace("#^/root/#", "", $dist); + // Build up the new release path. + $name = $values['name']; + $rPath = $this->getReleasePart($this->selectedContainer); + $newPath = trim($rPath."/".$name, '/'); - if(isset($item['name']) && $item['name'] != $values['name']){ - echo "Implement rename for releases"; - return; - } - - // Initiate the rpc request. - $rpc = $this->config->getRpcHandle(); - $res = $rpc->createRelease($dist, $newPath); - if(!$rpc->success()){ - msg_dialog::display(_("Error"), sprintf(_("Failed to save release: %s"), $rpc->get_error()),ERROR_DIALOG); - return(NULL); - }else{ + // Detect the parent distribution + $dist = $this->getDistributionPart($this->selectedContainer); - // We've successfully added the item, now add it to the tree. - $this->dataModel->addItem($type, $this->selectedContainer, $values['name'],array(), '-' ); + // Initiate the rpc request. + $rpc = $this->config->getRpcHandle(); + $res = $rpc->createRelease($dist, $newPath); + if(!$rpc->success()){ + msg_dialog::display(_("Error"), sprintf(_("Failed to save release: %s"), $rpc->get_error()),ERROR_DIALOG); + return(NULL); + }else{ - // Finally - close the dialog. - $this->listing->clearDialogObject(); + // We've successfully added/saved the item, now add it to the tree. + $this->dataModel->addItem($type, $this->selectedContainer, $values['name'],array(), '-' ); + $this->listing->clearDialogObject(); + } } - - $this->listing->clearDialogObject(); }else{ - echo "{$type} Cannot be saved yet"; $this->listing->clearDialogObject(); return; -- 2.30.2