Code

Store currently selcted base in session
[gosa.git] / gosa-core / include / class_gosaSupportDaemon.inc
index b86f277aea1903cfe7b94622000dcc58bfa0113d..44d05cfe0d0e0e9628474e76c7c2b1a4cf4614d0 100644 (file)
@@ -46,13 +46,18 @@ class gosaSupportDaemon
     #FIXME: bad idea about referencing global variables from within classes
     global $config;
 
+    /* This should only be the case if we call this from setup.
+        __autoload() 
+     */
+    if(!is_object($config)) { return; }
+
     # load from config, store statically
-    if (isset($config->current['GOSA_SI'])){
+    if ($config->get_cfg_value("gosa_si") != ""){
 
       if ($this->s_host == ""){
-        $this->s_host= preg_replace("/^.*@([^:]+):.*$/", "$1", $config->current['GOSA_SI']);
-        $this->i_port= preg_replace("/^.*@[^:]+:(.*)$/", "$1", $config->current['GOSA_SI']);
-        $this->s_encryption_key = preg_replace("/^(.*)@[^:]+:.*$/", "$1", $config->current['GOSA_SI']);
+        $this->s_host= preg_replace("/^.*@([^:]+):.*$/", "$1", $config->get_cfg_value("gosa_si"));
+        $this->i_port= preg_replace("/^.*@[^:]+:(.*)$/", "$1", $config->get_cfg_value("gosa_si"));
+        $this->s_encryption_key = preg_replace("/^(.*)@[^:]+:.*$/", "$1", $config->get_cfg_value("gosa_si"));
       }
 
       $this->f_timeout = $timeout;
@@ -84,6 +89,16 @@ class gosaSupportDaemon
     return($this->is_connected);
   }
 
+  
+  /*! \brief  Returns TRUE whether we are connected or not 
+      @return BOOLEAN  Returns TRUE when connected else FALSE
+   */
+  public function is_connected()
+  {
+    return($this->is_connected);
+  }
+  
+
 
   /*! \brief  Disconnect from gosa daemon.
    */
@@ -827,6 +842,13 @@ class gosaSupportDaemon
         }
         if ($xml_elem['type'] == 'complete') {
 
+          $start_level = 1;
+          $test2 = &$params;
+          while($start_level < $xml_elem['level']) {
+            $test2 = &$test2[$level[$start_level]];
+            $start_level++;
+          }
+
           /* Save tag attributes too. 
               e.g. <tag attr="val">
            */
@@ -836,12 +858,6 @@ class gosaSupportDaemon
             }
           }
 
-          $start_level = 1;
-          $test2 = &$params;
-          while($start_level < $xml_elem['level']) {
-            $test2 = &$test2[$level[$start_level]];
-            $start_level++;
-          }
           if(!isset($test2[$xml_elem['tag']])){
             if(isset($xml_elem['value'])){
               $test2[$xml_elem['tag']] = $xml_elem['value'];
@@ -1898,6 +1914,11 @@ class gosaSupportDaemon
       $key = preg_replace("/^.*\n\n/sim","",$key);
       /* Remove footer */
       $key = preg_replace("/-----.*$/sim","",$key);
+    }elseif (!preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $key)) {
+      
+      /* Encode key if it is raw.
+       */
+      $key = base64_encode($key);
     }
 
     /* Create query