From 4f43b89367d6c9e7acd1699b796e0a6b527e8ac5 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 4 Jun 2010 12:22:06 +0000 Subject: [PATCH] Updated jsonRPC request handler - git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18845 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_jsonRPC.inc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/gosa-core/include/class_jsonRPC.inc b/gosa-core/include/class_jsonRPC.inc index 98c0d0bf1..91f1c2b0a 100644 --- a/gosa-core/include/class_jsonRPC.inc +++ b/gosa-core/include/class_jsonRPC.inc @@ -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) { -- 2.30.2