Code

Updated model
[gosa.git] / include / class_ConfigManager.inc
index 8c40ea19f2a5bcd03ebff34fc768590cd3ae4f53..4840a83ac120c782bf4d096ce903460eeb5bb3a7 100644 (file)
@@ -65,15 +65,15 @@ class ConfigManager {
 
 
        public function setSection($name){
+    $this->section= $name;
+
                if (isset($this->config[$name])){
-                       $this->section= $name;
                        $this->current= &$this->config[$name];
                        return TRUE;
-               } else {
-                       $this->section= "";
-                       $this->current= NULL;
-                       return FALSE;
-               }
+    } else {
+      $this->current= array();
+      return FALSE;
+    }
        }
 
 
@@ -86,14 +86,16 @@ class ConfigManager {
        }
 
 
-       public function getValue($name){
-               if (!$this->current){
+       public function getValue($name, $default= ""){
+               if (!$this->section){
                        throw new ConfigManagerException(_("Can't get value without current section set!"));
                }
                
                if (isset($this->current[$name])){
                        return $this->current[$name];
-               } else {
+               } elseif ($default) {
+      return $default;
+    } else {
                        return NULL;
                }
        }