summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 75a8fe0)
raw | patch | inline | side by side (parent: 75a8fe0)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 14 Apr 2011 12:11:37 +0000 (12:11 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 14 Apr 2011 12:11:37 +0000 (12:11 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20729 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementDataModel.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementDataModel.inc
index 16dd8fcc072272903fbacfae5867892d091f4aaa..d742056f1398894b43f07e564662e1b97985c9b2 100644 (file)
return($this->data);
}
+ function moveItem($from, $to)
+ {
+ // Get source entries
+ $itemFrom = &$this->data['linear'][$from];
+ $parentFrom = &$this->data['linear'][$itemFrom['parentPath']];
+
+ // Extract 'to' informations out of the path.
+ $name = preg_replace("/^.*\//","", $to);
+ $toParentPath = preg_replace("/\/[^\/]*$/","", $to);
+ $parentTo = &$this->data['linear'][$toParentPath];
+ $parentToDn = $parentTo['dn'];
+
+ // Append the 'from' entry to the 'to' parent children.
+ $parentTo['children'][$to] = $parentFrom['children'][$from];
+ $parentTo['children'][$to]['path']= $to;
+ $parentTo['children'][$to]['name']= $name;
+ $parentTo['children'][$to]['dn']= rtrim("cn={$name},{$parentToDn}",',');
+
+ // Unset the source path
+ unset($parentFrom['children'][$from]);
+ unset($this->data['linear'][$from]);
+
+ // Append the linear entry.
+ $this->data['linear'][$to] = &$parentTo['children'][$to];
+ }
+
function removeItem($path)
{
$item = &$this->data['linear'][$path];
diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc
index faa9f1e93829406b1279cf377b88553e2817a3a1..1d6f9a02327f3bcb8e1f25666676f8d32e76f63c 100644 (file)
return;
}
- // Null means a new object has to be added.
- if($item == NULL){
+ if($this->cfgItemMap[$type] != 'root'){
// Save template engine modifications
$this->TemplateEngine->save_object();
$release = preg_replace("/^.*\//","", $this->getReleasePath($this->selectedContainer));
- // Collect modified values
+ // Get values to be saved
$values = array();
foreach($this->TemplateEngine->getWidgets() as $w){
$values[$w->getName()] = $w->getValue();
}
- // Create the elements target path
- $path = $this->getItemPath($this->selectedContainer)."/".$values['name'];
-
- // Add the new item
- $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{
+ // Get paths
+ $newPath = $this->selectedContainer."/".$values['name'];
+ $newItemPath = $this->getItemPath($this->selectedContainer)."/".$values['name'];
+ if($item){
+ $oldPath = $item['path'];
+ $oldItemPath = $this->getItemPath($item['path']);
+ }
- // We've successfully added the item, now add it to the tree.
- $this->dataModel->addItem($type, $this->selectedContainer, $values['name'],array(), '-' );
+ // If this is a new item, then create it now.
+ if($item == NULL){
- // Finally - close the dialog.
- $this->listing->clearDialogObject();
- }
- }else{
+ // Add the new item
+ $rpc = $this->config->getRpcHandle();
+ $res = $rpc->setConfigItem($release, $newItemPath, $type, $values);
+ if(!$rpc->success()){
+ msg_dialog::display(_("Error"), sprintf(_("Failed to load distributions: %s"), $rpc->get_error()),ERROR_DIALOG);
+ return(NULL);
+ }else{
- // Collect modified values.
- $this->TemplateEngine->save_object();
- $values = array();
- foreach($this->TemplateEngine->getWidgets() as $w){
- $values[$w->getName()] = $w->getValue();
- }
+ // We've successfully added the item, now add it to the tree.
+ $this->dataModel->addItem($type, $this->selectedContainer, $values['name'],array(), '-' );
- // Get the items release & path info
- $release = preg_replace("/^.*\//","", $this->getReleasePath($item['path']));
- $path = $this->getItemPath($item['path']);
-
- // Write the modifications back to the server.
- $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);
+ // Finally - close the dialog.
+ $this->listing->clearDialogObject();
+ }
}else{
-
- // Update the data model
- $item['values'] = $values;
- $this->dataModel->setItemValues($item['path'], $item['values']);
- $this->listing->clearDialogObject();
+
+ // Write the modifications back to the server.
+ $rpc = $this->config->getRpcHandle();
+ $res = $rpc->setConfigItem($release, $oldItemPath, $type, $values);
+ if(!$rpc->success()){
+ msg_dialog::display(_("Error"), sprintf(_("Failed to load distributions: %s"), $rpc->get_error()),ERROR_DIALOG);
+ return(NULL);
+ }else{
+
+ // Update the data model
+ $item['values'] = $values;
+
+ $this->dataModel->setItemValues($item['path'], $item['values']);
+ $this->dataModel->moveItem($oldPath, $newPath);
+ $this->listing->clearDialogObject();
+ }
}
}
}