From db0ed272a09a5832e719e54cb95c288a1eee3304 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 9 Nov 2010 15:11:37 +0000 Subject: [PATCH] Updated class config::getRpcHandle -Allow to disable connection caching. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20205 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_GOsaRegistration.inc | 14 +++++++++++--- gosa-core/include/class_config.inc | 13 +++++++++---- gosa-core/include/class_jsonRPC.inc | 7 +++++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/gosa-core/include/class_GOsaRegistration.inc b/gosa-core/include/class_GOsaRegistration.inc index 2685bcabb..efadc48b3 100644 --- a/gosa-core/include/class_GOsaRegistration.inc +++ b/gosa-core/include/class_GOsaRegistration.inc @@ -1,12 +1,20 @@ config = $config; + } + + function isInstanceRegistered() + { + return(FALSE); + } +} ?> diff --git a/gosa-core/include/class_config.inc b/gosa-core/include/class_config.inc index a630ab8a9..ad4d2fc7c 100644 --- a/gosa-core/include/class_config.inc +++ b/gosa-core/include/class_config.inc @@ -316,7 +316,7 @@ class config { } - function getRpcHandle($connectUrl=NULL, $username=NULL, $userPassword=NULL, $authModeDigest=FALSE) + function getRpcHandle($connectUrl=NULL, $username=NULL, $userPassword=NULL, $authModeDigest=FALSE, $cache = TRUE) { // Get conenct information, if no info was given use the default values from gosa.conf $connectUrl = ($connectUrl !== NULL) ? $connectUrl : $this->get_cfg_value('core','gosaRpcServer'); @@ -325,10 +325,15 @@ class config { $authModeDigest = $authModeDigest; // Create jsonRPC handle on demand. - if(!isset($this->jsonRPChandle[$connectUrl][$username]) || !$this->jsonRPChandle[$connectUrl][$username]){ - $this->jsonRPChandle[$connectUrl][$username] = new jsonRPC($this, $connectUrl, $username, $userPassword, $authModeDigest); + if(!$cache){ + return(new jsonRPC($this, $connectUrl, $username, $userPassword, $authModeDigest)); + }else{ + + if(!isset($this->jsonRPChandle[$connectUrl][$username]) || !$this->jsonRPChandle[$connectUrl][$username]){ + $this->jsonRPChandle[$connectUrl][$username] = new jsonRPC($this, $connectUrl, $username, $userPassword, $authModeDigest); + } + return($this->jsonRPChandle[$connectUrl][$username]); } - return($this->jsonRPChandle[$connectUrl][$username]); } diff --git a/gosa-core/include/class_jsonRPC.inc b/gosa-core/include/class_jsonRPC.inc index e65cfbdc9..b9ded4fe3 100644 --- a/gosa-core/include/class_jsonRPC.inc +++ b/gosa-core/include/class_jsonRPC.inc @@ -93,8 +93,10 @@ class jsonRPC { // Try to login if($this->authModeDigest){ - if(!empty($this->username)) + if(!empty($this->username)){ curl_setopt($this->curlHandler, CURLOPT_USERPWD , "{$this->username}:{$this->userPassword}"); + } + curl_setopt($this->curlHandler, CURLOPT_HTTPAUTH , CURLAUTH_ANYSAFE); }else{ curl_setopt($this->curlHandler, CURLOPT_COOKIESESSION , TRUE); @@ -141,7 +143,8 @@ class jsonRPC { */ public function success() { - return(curl_errno($this->curlHandler) == 0 && $this->lastStats['http_code'] == 200); + return(curl_errno($this->curlHandler) == 0 || + (isset($this->lastStats['http_code']) && $this->lastStats['http_code'] == 200)); } -- 2.30.2