Code

Added property class to get_cfg_requests
[gosa.git] / gosa-core / include / class_configRegistry.inc
index 7520310d7f0acc3b7555a24c4a83263627bbd260..0f623ee08366720af8f7c422d76a23d7750183fa 100644 (file)
@@ -4,8 +4,6 @@ class configRegistry{
 
     public $config = NULL;
     public $properties = array();
-    public $mapByClass = array();
-    public $mapPropertyToClass = array();
     public $ldapStoredProperties = array(); 
     public $fileStoredProperties = array(); 
     public $classToName = array(); 
@@ -30,9 +28,8 @@ class configRegistry{
         $this->ldapStoredProperties = array();
         $this->fileStoredProperties = array();
         $this->properties = array();
-        $this->mapByClass = array();
-        $this->mapPropertyToClass = array();
-        
+        $this->mapByName = array();
+
         // Search for config flags defined in the config file (TAB section)
         foreach($this->config->data['TABS'] as $tabname => $tabdefs){
             foreach($tabdefs as $info){
@@ -80,7 +77,7 @@ class configRegistry{
             }
             $this->status = 'finished';
         }
+
         global $class_mapping;
         foreach ($class_mapping as $cname => $path){
             $cmethods = get_class_methods($cname);
@@ -115,9 +112,8 @@ class configRegistry{
     {
         $id = count($this->properties);
         $this->properties[$id] = new gosaProperty($this,$class,$data);
-        $this->mapByName[$class][$data['name']] = $id;
-        $this->mapByClass[$class][] = $id;
-        $this->mapPropertyToClass[$id] = $class;
+        $p = strtolower("{$class}::{$data['name']}");
+        $this->mapByName[$p] = $id;
     }
 
     public function getAllProperties()
@@ -126,13 +122,18 @@ class configRegistry{
     }
 
     function propertyExists($class,$name)
-    {
-        return(isset($this->mapByName[$class][$name]));
+    {       
+        $p = strtolower("{$class}::{$name}");
+        return(isset($this->mapByName[$p]));
     }
 
     private function getId($class,$name)
     {
-        return($this->mapByName[$class][$name]);    
+        $p = strtolower("{$class}::{$name}");
+        if(!isset($this->mapByName[$p])){
+            return(-1);
+        }       
+        return($this->mapByName[$p]);    
     }
 
     function getProperty($class,$name)
@@ -166,6 +167,7 @@ class configRegistry{
         foreach($this->properties as $prop){
             $prop->save();
         }
+        $this->reload(TRUE);
     }
 }
 
@@ -221,12 +223,14 @@ class gosaProperty
         if(isset($this->parent->ldapStoredProperties[$this->class][$this->name])){
             $this->setStatus('ldap');
             $this->value = $this->parent->ldapStoredProperties[$this->class][$this->name];
+            return;
         }
 
         // Second check for values in the config file.
         if(isset($this->parent->fileStoredProperties[$this->class][strtolower($this->name)])){
             $this->setStatus('file');
             $this->value = $this->parent->fileStoredProperties[$this->class][strtolower($this->name)];
+            return;
         }
 
         // If there still wasn't found anything then fallback to the default.
@@ -275,16 +279,16 @@ class gosaProperty
             if(!$ldap->count()){
                 $ldap->cd($dn);
                 $data = array(
-                            'cn' => $this->class, 
-                            'objectClass' => array('top','gosaConfig'),
-                            'gosaSetting' => $this->name.":".$this->value);
+                        'cn' => $this->class, 
+                        'objectClass' => array('top','gosaConfig'),
+                        'gosaSetting' => $this->name.":".$this->value);
 
                 $ldap->add($data);
-                if($ldap->success()){
-                    $this->status = 'ldap';
-                }else{
+                if(!$ldap->success()){
                     echo $ldap->get_error();
                 }
+                $this->_restoreCurrentValue();
+
             }else{
                 $attrs = $ldap->fetch();
                 $data = array();
@@ -300,11 +304,10 @@ class gosaProperty
                 if(!$found) $data['gosaSetting'][] = "{$this->name}:{$this->value}";
                 $ldap->cd($dn);
                 $ldap->modify($data);
-                if($ldap->success()){
-                    $this->status = 'ldap';
-                }else{
+                if(!$ldap->success()){
                     echo $ldap->get_error();
                 }
+                $this->_restoreCurrentValue();
             } 
         }elseif($this->getStatus() == 'removed'){
             $ldap = $this->parent->config->get_ldap_link();
@@ -322,11 +325,10 @@ class gosaProperty
             }
             $ldap->cd($dn);
             $ldap->modify($data);
-            if($ldap->success()){
-                $this->_restoreCurrentValue();
-            }else{
+            if(!$ldap->success()){
                 echo $ldap->get_error();
             }
+            $this->_restoreCurrentValue();
         }
     }