Code

Updated Config Item mangement, we are now able to set Acls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 19 May 2011 07:00:22 +0000 (07:00 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 19 May 2011 07:00:22 +0000 (07:00 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20870 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/DeviceConfig-list.xml
gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagement.inc
gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementDataModel.inc
gosa-plugins/goto-ng/admin/newConfigManagement/class_filterConfigManagement.inc

index 883cfb1dcb5b860ea6fe324af0eb6975064f6836..d3a1b6ec2540650a986fe7c1960c7775826874c4 100644 (file)
@@ -79,7 +79,7 @@
       <name>remove</name>
       <type>entry</type>
       <image>images/lists/trash.png</image>
-      <acl>ConfigManagement/cfgItem[w]</acl>
+      <acl>ConfigManagement/ConfigManagement[createFAICD:w]</acl>
       <label>Remove item</label>
     </action>
 
index a54591923ac71724427f05a1b895e65c46506e8b..b474d4ece18718c502f6ab782426b34543e8d8fe 100644 (file)
@@ -520,7 +520,7 @@ class ConfigManagement extends plugin
     function openEntry($ids)
     {
         $id = $ids[0];
-        $item = $this->dataModel->getItemById($id);
+        $item = $this->dataModel->getItemByDn($id);
         $this->setCurrentContainer($item['path']);
         return;
     }
@@ -532,7 +532,7 @@ class ConfigManagement extends plugin
     function removeEntry($ids)
     {
         foreach($ids as $id){
-            $item = $this->dataModel->getItemById($id);
+            $item = $this->dataModel->getItemByDn($id);
 
             // Is an config item.
             if($this->cfgItemMap[$item['type']] != 'root'){
@@ -612,7 +612,10 @@ class ConfigManagement extends plugin
      */
     function editEntry($ids)
     {
-        $item = $this->dataModel->getItemById($ids[0]);
+        $item = $this->dataModel->getItemByDn($ids[0]);
+
+        if(!$item) return;
+
         $release = $this->getReleasePart($item['path']);
         $path = $this->getItemPath($item['path']);
         $method = $this->cfgItemMap[$item['type']];
index d50b3f71b8ce414d8261687a4795588f7fa71ee3..d73e35f06d0227c2b6ff655294e20fe0d6d9ac9e 100644 (file)
@@ -5,6 +5,7 @@ class ConfigManagementDataModel
     public $data = array();
     public $typeToPath = array();
     public $idToPath = array();
+    public $dnToPath = array();
 
     function __construct()
     {
@@ -30,12 +31,13 @@ class ConfigManagementDataModel
         $toParentPath = preg_replace("/\/[^\/]*$/","", $to);
         $parentTo = &$this->data['linear'][$toParentPath];
         $parentToDn = $parentTo['dn'];
+        $dn = rtrim("cn={$name},{$parentToDn}",',');
 
         // 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}",',');
+        $parentTo['children'][$to]['dn']= $dn;
 
         // Unset the source path
         unset($parentFrom['children'][$from]);
@@ -47,6 +49,7 @@ class ConfigManagementDataModel
         // Update id->Path mapping
         $id = $this->data['linear'][$to]['id'];
         $this->idToPath[$id] = $to;
+        $this->dnToPath[$dn] = $to;
 
     }
 
@@ -94,6 +97,7 @@ class ConfigManagementDataModel
         $this->data['linear'][$entryPath] = &$parentItem[$entryPath];
 
         $this->idToPath[$entryId] = $entryPath;
+        $this->idToPath[$entryDn] = $entryPath;
         $this->typeToPath[$type][$name] = $entryPath;
     
         return($entryId);
@@ -168,6 +172,20 @@ class ConfigManagementDataModel
         }
         return(NULL);
     }
+
+    function getItemByDn($dn)
+    {
+        $path = NULL;
+        if(isset($this->dnToPath[$dn])){
+            $path = $this->dnToPath[$dn];
+        }else{
+            return(NULL);
+        }
+        if(isset($this->data['linear'][$path])){
+            return($this->data['linear'][$path]);
+        }
+        return(NULL);
+    }
 }
 
 ?>
index db43ea525fc1a6dde4b86c7defc06ef770c2fb64..fce191f9313b58a181f3d2060e12aadf50a14479 100644 (file)
@@ -18,7 +18,7 @@ class filterConfigManagement {
         $ret = array();
         if($data['path'] != "/root"){
             $back = array(); 
-            $back['dn'] = $data['id'];
+            $back['dn'] = $data['dn'];
             $back[] = 'dn';
             $back['cn'] = array('.', 'count' => 1);
             $back[] = 'cn';
@@ -40,7 +40,7 @@ class filterConfigManagement {
     {
         if(preg_match("/".$filter."/",$item['name'])){
             $entry = array();
-            $entry['dn'] = $item['id'];
+            $entry['dn'] = $item['dn'];
             $entry[] = 'dn';
             $entry['cn'] = array($item['name'], 'count' => 1);
             $entry[] = 'cn';