From: hickert Date: Thu, 14 Apr 2011 13:36:19 +0000 (+0000) Subject: Added check to avoid overwriting items X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8756f2d9178bc408c5598af725ac35bfca3e0bf6;p=gosa.git Added check to avoid overwriting items git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20735 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc index a0d5cf78e..608c1344f 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc @@ -464,6 +464,16 @@ class newConfigManagement extends plugin } } + function getUsedNamesForPath($path) + { + $item = $this->dataModel->getItemByPath($path); + $names = array(); + foreach($item['children'] as $path => $data){ + $names[] = $data['name']; + } + return($names); + } + /*! \brief Edits a selected list item. */ @@ -557,6 +567,8 @@ class newConfigManagement extends plugin return; } + + if($this->cfgItemMap[$type] != 'root'){ // Save template engine modifications @@ -580,6 +592,13 @@ class newConfigManagement extends plugin // If this is a new item, then create it now. if($item == NULL){ + // Validate item name + $usedNames = $this->getUsedNamesForPath($this->selectedContainer); + if(in_array($values['name'],$usedNames)){ + echo 'The name is used'; + return; + } + // Add the new item $rpc = $this->config->getRpcHandle(); $res = $rpc->setConfigItem($release, $newItemPath, $type, $values); @@ -596,6 +615,15 @@ class newConfigManagement extends plugin } }else{ + // Validate item name + if($item['name'] != $values['name']){ + $usedNames = $this->getUsedNamesForPath($this->selectedContainer); + if(in_array($values['name'],$usedNames)){ + echo 'The name is used'; + return; + } + } + // Write the modifications back to the server. $rpc = $this->config->getRpcHandle(); $res = $rpc->setConfigItem($release, $oldItemPath, $type, $values);