Code

Updated jsonRPC request handler
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 4 Jun 2010 12:22:06 +0000 (12:22 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 4 Jun 2010 12:22:06 +0000 (12:22 +0000)
-

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18845 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_jsonRPC.inc

index 98c0d0bf1c919b5582e11764c31c8ef184ae76e0..91f1c2b0a82a57e33ec49432f96151e968317203 100644 (file)
@@ -6,6 +6,7 @@ class jsonRPC {
     private $config;
     private $id;
     private $lastStats = array();
+    private $lastAction = "none";
 
     public function __construct($config, $debug = false) 
     {
@@ -59,13 +60,27 @@ class jsonRPC {
 
     public function __destruct()
     {
-        curl_close($this->curlHandler);
+        if($this->curlHandler){
+             curl_close($this->curlHandler);
+        }
     }
 
     public function __call($method,$params) 
     {
         // Check if handle is still valid!
-        if(! $this->curlHandler) $this->__login();
+        if(!$this->curlHandler && $this->lastAction != 'login'){
+             $this->__login();
+        }
+
+        $response = $this->request($method,$params);
+        return($response['result']);
+    }
+
+    
+    private function request($method, $params)
+    {
+        // Set last action 
+        $this->lastAction = $method;
 
         // Reset stats of last request.
         $this->lastStats = array();
@@ -89,9 +104,10 @@ class jsonRPC {
 
         // Set current result stats.
         $this->lastStats = curl_getinfo($this->curlHandler);
-        return($response['result']);
+    
+        return($response);
     }
-
+    
 
     public static function getHttpStatusCodeMessage($code)
     {