Code

Fixed saving of releases
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Apr 2011 08:02:08 +0000 (08:02 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Apr 2011 08:02:08 +0000 (08:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20769 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 2330b8b93d726afd6a1ef0c465ed7174871977f5..5e2b8b8cb9a107f81cfdba01265d98dc3e11a038 100644 (file)
@@ -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;